add: logout handling

This commit is contained in:
$(pass /github/name)
2024-09-07 11:38:35 +02:00
parent c3944cb4aa
commit 4d6938de96
3 changed files with 82 additions and 8 deletions

View File

@@ -43,7 +43,13 @@ func (uc *UserController) CurrentUserHandler(c *gin.Context) {
c.JSON(http.StatusOK, user.Safe())
}
func (uc *UserController) LoginUser(c *gin.Context) {
func (uc *UserController) LogoutHandler(c *gin.Context) {
// just clear the JWT cookie
c.SetCookie("jwt", "", -1, "/", "", true, true)
c.JSON(http.StatusOK, gin.H{"message": "Logged out successfully"})
}
func (uc *UserController) LoginHandler(c *gin.Context) {
var input struct {
Email string `json:"email"`
Password string `json:"password"`