refactor: use setAuthCookie helper

This commit is contained in:
Derrick Hammer 2024-01-16 13:38:10 -05:00
parent 891ca20a72
commit 17441ff674
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
1 changed files with 14 additions and 10 deletions

View File

@ -346,16 +346,7 @@ func (h *HttpHandler) AccountRegister(jc jape.Context) {
return
}
authCookie := http.Cookie{
Name: "s5-auth-token",
Value: jwt,
Path: "/",
HttpOnly: true,
MaxAge: int(time.Hour.Seconds() * 24),
Secure: true,
}
http.SetCookie(jc.ResponseWriter, &authCookie)
setAuthCookie(jwt, jc)
}
func (h *HttpHandler) AccountLoginChallenge(jc jape.Context) {
@ -367,3 +358,16 @@ func (h *HttpHandler) AccountLogin(jc jape.Context) {
//TODO implement me
panic("implement me")
}
func setAuthCookie(jwt string, jc jape.Context) {
authCookie := http.Cookie{
Name: "s5-auth-token",
Value: jwt,
Path: "/",
HttpOnly: true,
MaxAge: int(time.Hour.Seconds() * 24),
Secure: true,
}
http.SetCookie(jc.ResponseWriter, &authCookie)
}