Skip to content

Commit

Permalink
userpage: make refresh token work w/ reverse proxy
Browse files Browse the repository at this point in the history
potentially for #290.
  • Loading branch information
hrfee committed Oct 3, 2023
1 parent f6fdd41 commit 543f23c
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions user-auth.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
package main

import "github.com/gin-gonic/gin"
import (
"strings"

"github.com/gin-gonic/gin"
)

func (app *appContext) userAuth() gin.HandlerFunc {
return app.userAuthenticate
Expand Down Expand Up @@ -60,7 +64,11 @@ func (app *appContext) getUserTokenLogin(gc *gin.Context) {
}

app.debug.Printf("Token generated for non-admin user \"%s\"", username)
gc.SetCookie("user-refresh", refresh, REFRESH_TOKEN_VALIDITY_SEC, "/my", gc.Request.URL.Hostname(), true, true)
uri := "/my"
if strings.HasPrefix(gc.Request.RequestURI, app.URLBase) {
uri = "/accounts/my"
}
gc.SetCookie("user-refresh", refresh, REFRESH_TOKEN_VALIDITY_SEC, uri, gc.Request.URL.Hostname(), true, true)
gc.JSON(200, getTokenDTO{token})
}

Expand Down

0 comments on commit 543f23c

Please sign in to comment.