mirror of
https://github.com/Floriansylvain/RenewCMS.git
synced 2026-08-19 19:53:21 +02:00
clean: moved http.SetCookie into its own func
This commit is contained in:
+5
-2
@@ -126,7 +126,7 @@ func register(w http.ResponseWriter, r *http.Request) {
|
|||||||
_, _ = w.Write(message)
|
_, _ = w.Write(message)
|
||||||
}
|
}
|
||||||
|
|
||||||
func logout(w http.ResponseWriter, _ *http.Request) {
|
func removeJwtCookie(w http.ResponseWriter) {
|
||||||
http.SetCookie(w, &http.Cookie{
|
http.SetCookie(w, &http.Cookie{
|
||||||
Name: "jwt",
|
Name: "jwt",
|
||||||
Value: "",
|
Value: "",
|
||||||
@@ -134,9 +134,12 @@ func logout(w http.ResponseWriter, _ *http.Request) {
|
|||||||
MaxAge: -1,
|
MaxAge: -1,
|
||||||
Secure: false, // TODO false in dev, true in prod
|
Secure: false, // TODO false in dev, true in prod
|
||||||
HttpOnly: true,
|
HttpOnly: true,
|
||||||
Path: "/v1/",
|
Path: "/",
|
||||||
})
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
func logout(w http.ResponseWriter, _ *http.Request) {
|
||||||
|
removeJwtCookie(w)
|
||||||
message, _ := json.Marshal(map[string]interface{}{"message": "User logged out! HTTPonly jwt cookie deleted"})
|
message, _ := json.Marshal(map[string]interface{}{"message": "User logged out! HTTPonly jwt cookie deleted"})
|
||||||
_, _ = w.Write(message)
|
_, _ = w.Write(message)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user