Remove authentication Cookies from Backend
This commit is contained in:
parent
4f72751ed6
commit
3da2e0f2f8
@ -23,7 +23,6 @@ type Handler struct {
|
||||
|
||||
const (
|
||||
expiration = 72
|
||||
authCookie = "authentication"
|
||||
)
|
||||
|
||||
// Serve starts the HTTP Server
|
||||
@ -76,9 +75,6 @@ func (h *Handler) Serve() {
|
||||
authenticated.Use(h.verifyLoginWithForbidden)
|
||||
authenticated.GET("/dashboard", h.dashboard)
|
||||
|
||||
user := authenticated.Group("/user")
|
||||
user.GET("/logout", logout)
|
||||
|
||||
budget := authenticated.Group("/budget")
|
||||
budget.POST("/new", h.newBudget)
|
||||
|
||||
|
@ -4,7 +4,6 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"git.javil.eu/jacob1123/budgeteer"
|
||||
"git.javil.eu/jacob1123/budgeteer/postgres"
|
||||
@ -16,7 +15,6 @@ func (h *Handler) verifyLogin(c *gin.Context) (budgeteer.Token, error) {
|
||||
tokenString = tokenString[7:]
|
||||
token, err := h.TokenVerifier.VerifyToken(tokenString)
|
||||
if err != nil {
|
||||
c.SetCookie(authCookie, "", -1, "", "", false, false)
|
||||
return nil, fmt.Errorf("verify token '%s': %w", tokenString, err)
|
||||
}
|
||||
|
||||
@ -65,14 +63,6 @@ func (h *Handler) register(c *gin.Context) {
|
||||
c.HTML(http.StatusOK, "register.html", nil)
|
||||
}
|
||||
|
||||
func logout(c *gin.Context) {
|
||||
clearLogin(c)
|
||||
}
|
||||
|
||||
func clearLogin(c *gin.Context) {
|
||||
c.SetCookie(authCookie, "", -1, "", "", false, true)
|
||||
}
|
||||
|
||||
type loginInformation struct {
|
||||
Password string `json:"password"`
|
||||
User string `json:"user"`
|
||||
@ -103,8 +93,6 @@ func (h *Handler) loginPost(c *gin.Context) {
|
||||
|
||||
go h.Service.UpdateLastLogin(context.Background(), user.ID)
|
||||
|
||||
maxAge := (int)((expiration * time.Hour).Seconds())
|
||||
c.SetCookie(authCookie, t, maxAge, "", "", false, true)
|
||||
c.JSON(http.StatusOK, map[string]string{
|
||||
"token": t,
|
||||
})
|
||||
|
Loading…
x
Reference in New Issue
Block a user