fix: update docker file
This commit is contained in:
@@ -49,9 +49,8 @@ func CreateAuthToken(user UserAuthInfo, tokenType enum.TokenType) (string, int64
|
||||
}
|
||||
|
||||
func GetAuthToken(gc *gin.Context) (string, error) {
|
||||
token := ""
|
||||
cookie, err := gc.Request.Cookie(constants.COOKIE_NAME)
|
||||
if err != nil {
|
||||
token, err := GetCookie(gc)
|
||||
if err != nil || token == "" {
|
||||
// try to check in auth header for cookie
|
||||
log.Println("cookie not found checking headers")
|
||||
auth := gc.Request.Header.Get("Authorization")
|
||||
@@ -60,10 +59,7 @@ func GetAuthToken(gc *gin.Context) (string, error) {
|
||||
}
|
||||
|
||||
token = strings.TrimPrefix(auth, "Bearer ")
|
||||
} else {
|
||||
token = cookie.Value
|
||||
}
|
||||
|
||||
return token, nil
|
||||
}
|
||||
|
||||
|
@@ -24,6 +24,15 @@ func SetCookie(gc *gin.Context, token string) {
|
||||
gc.SetCookie(constants.COOKIE_NAME, token, 3600, "/", u.Hostname(), secure, httpOnly)
|
||||
}
|
||||
|
||||
func GetCookie(gc *gin.Context) (string, error) {
|
||||
cookie, err := gc.Request.Cookie(constants.COOKIE_NAME)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return cookie.Value, nil
|
||||
}
|
||||
|
||||
func DeleteCookie(gc *gin.Context) {
|
||||
secure := true
|
||||
httpOnly := true
|
||||
|
Reference in New Issue
Block a user