Skip to content

Commit 48ddb69

Browse files
committed
Changed cookie name from coreander to session
1 parent 4e36efb commit 48ddb69

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed

internal/webserver/controller/auth/signin.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ func (a *Controller) SignIn(c *fiber.Ctx) error {
3838
}
3939

4040
c.Cookie(&fiber.Cookie{
41-
Name: "coreander",
41+
Name: "session",
4242
Value: signedToken,
4343
Path: "/",
4444
MaxAge: int(a.config.SessionTimeout.Seconds()),

internal/webserver/controller/auth/signout.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ import (
99
// Logs out user and removes their JWT.
1010
func (a *Controller) SignOut(c *fiber.Ctx) error {
1111
c.Cookie(&fiber.Cookie{
12-
Name: "coreander",
13-
Value: "void",
12+
Name: "session",
13+
Value: "",
1414
Path: "/",
1515
MaxAge: -1,
1616
Secure: false,

internal/webserver/controller/user/update.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ func (u *Controller) updateUserData(c *fiber.Ctx, user *model.User, session mode
7272
}
7373

7474
c.Cookie(&fiber.Cookie{
75-
Name: "coreander",
75+
Name: "session",
7676
Value: signedToken,
7777
Path: "/",
7878
MaxAge: int(session.Exp),

internal/webserver/middleware.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ func AllowIfNotLoggedIn(jwtSecret []byte) func(*fiber.Ctx) error {
5959
return jwtware.New(jwtware.Config{
6060
SigningKey: jwtSecret,
6161
SigningMethod: "HS256",
62-
TokenLookup: "cookie:coreander",
62+
TokenLookup: "cookie:session",
6363
SuccessHandler: func(c *fiber.Ctx) error {
6464
return fiber.ErrForbidden
6565
},
@@ -75,7 +75,7 @@ func AlwaysRequireAuthentication(jwtSecret []byte, sender Sender) func(*fiber.Ct
7575
return jwtware.New(jwtware.Config{
7676
SigningKey: jwtSecret,
7777
SigningMethod: "HS256",
78-
TokenLookup: "cookie:coreander",
78+
TokenLookup: "cookie:session",
7979
SuccessHandler: func(c *fiber.Ctx) error {
8080
c.Locals("Session", sessionData(c))
8181
return c.Next()
@@ -91,7 +91,7 @@ func ConfigurableAuthentication(jwtSecret []byte, sender Sender, requireAuth boo
9191
return jwtware.New(jwtware.Config{
9292
SigningKey: jwtSecret,
9393
SigningMethod: "HS256",
94-
TokenLookup: "cookie:coreander",
94+
TokenLookup: "cookie:session",
9595
SuccessHandler: func(c *fiber.Ctx) error {
9696
c.Locals("Session", sessionData(c))
9797
return c.Next()
@@ -111,7 +111,7 @@ func forbidden(c *fiber.Ctx, sender Sender, err error) error {
111111
emailSendingConfigured = false
112112
}
113113
message := ""
114-
if err.Error() != "missing or malformed JWT" && c.Cookies("coreander") != "void" {
114+
if err.Error() != "missing or malformed JWT" && c.Cookies("session") != "" {
115115
message = "Session expired, please log in again."
116116
}
117117
return c.Status(fiber.StatusForbidden).Render("auth/login", fiber.Map{

0 commit comments

Comments
 (0)