diff --git a/api/s5/http.go b/api/s5/http.go index d0c93ec..472b535 100644 --- a/api/s5/http.go +++ b/api/s5/http.go @@ -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) +}