Move logout to POST route and controller with CSRF middleware. Add CsrfToken to home for logout
This commit is contained in:
@ -26,8 +26,7 @@ func Get(app *app.App) {
|
||||
slog.Info("serving static files from embedded file system /static")
|
||||
|
||||
// Pages
|
||||
http.HandleFunc("/", getController.ShowHome)
|
||||
http.HandleFunc("/login", getController.ShowLogin)
|
||||
http.HandleFunc("/register", getController.ShowRegister)
|
||||
http.HandleFunc("/logout", getController.Logout)
|
||||
http.HandleFunc("GET /", getController.ShowHome)
|
||||
http.HandleFunc("GET /login", getController.ShowLogin)
|
||||
http.HandleFunc("GET /register", getController.ShowRegister)
|
||||
}
|
||||
|
@ -15,6 +15,7 @@ func Post(app *app.App) {
|
||||
}
|
||||
|
||||
// User authentication
|
||||
http.HandleFunc("/register-handle", middleware.Csrf(postController.Register))
|
||||
http.HandleFunc("/login-handle", middleware.Csrf(postController.Login))
|
||||
http.HandleFunc("POST /register-handle", middleware.Csrf(postController.Register))
|
||||
http.HandleFunc("POST /login-handle", middleware.Csrf(postController.Login))
|
||||
http.HandleFunc("POST /logout", middleware.Csrf(postController.Logout))
|
||||
}
|
||||
|
Reference in New Issue
Block a user