Have got logout working
This commit is contained in:
parent
01c6e9de87
commit
b7e0269e9d
7 changed files with 66 additions and 10 deletions
9
assets/js/controllers/logout.js
Normal file
9
assets/js/controllers/logout.js
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
import { Controller } from "@hotwired/stimulus"
|
||||
|
||||
export default class LogoutController extends Controller {
|
||||
async logout(ev) {
|
||||
ev.preventDefault();
|
||||
await fetch(`/logout`, { method: 'POST' });
|
||||
window.location.href = '/login';
|
||||
}
|
||||
}
|
||||
|
|
@ -3,8 +3,10 @@ import { Application } from "@hotwired/stimulus";
|
|||
import ToastController from "./controllers/toast";
|
||||
import PostlistController from "./controllers/postlist";
|
||||
import PosteditController from "./controllers/postedit";
|
||||
import LogoutController from "./controllers/logout";
|
||||
|
||||
window.Stimulus = Application.start()
|
||||
Stimulus.register("toast", ToastController);
|
||||
Stimulus.register("postlist", PostlistController);
|
||||
Stimulus.register("postedit", PosteditController);
|
||||
Stimulus.register("logout", LogoutController);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue