refactor: use SetAuthCookie and set both DEFAULT_AUTH_COOKIE_NAME and s5 authCookieName

This commit is contained in:
Derrick Hammer 2024-03-17 08:17:56 -04:00
parent 51c7211c39
commit 6c58f6bd6c
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
1 changed files with 4 additions and 15 deletions

View File

@ -8,7 +8,6 @@ import (
"io/fs"
"net/http"
"strings"
"time"
"git.lumeweb.com/LumeWeb/portal/api/swagger"
@ -119,13 +118,8 @@ func (a AccountAPI) login(jc jape.Context) {
return
}
http.SetCookie(jc.ResponseWriter, &http.Cookie{
Name: "jwt",
Value: jwt,
Expires: time.Now().Add(24 * time.Hour),
HttpOnly: true,
Path: "/",
})
account.SetAuthCookie(jc.ResponseWriter, middleware.DEFAULT_AUTH_COOKIE_NAME, jwt)
account.SetAuthCookie(jc.ResponseWriter, authCookieName, jwt)
account.SendJWT(jc, jwt)
jc.Encode(&LoginResponse{
@ -220,13 +214,8 @@ func (a AccountAPI) otpValidate(jc jape.Context) {
return
}
http.SetCookie(jc.ResponseWriter, &http.Cookie{
Name: "jwt",
Value: jwt,
Expires: time.Now().Add(24 * time.Hour),
HttpOnly: true,
Path: "/",
})
account.SetAuthCookie(jc.ResponseWriter, middleware.DEFAULT_AUTH_COOKIE_NAME, jwt)
account.SetAuthCookie(jc.ResponseWriter, authCookieName, jwt)
account.SendJWT(jc, jwt)
jc.Encode(&LoginResponse{