fix: update docker file

This commit is contained in:
Lakhan Samani
2021-07-27 17:46:02 +05:30
parent 30f83aaf82
commit 0fd4f18dc1
5 changed files with 20 additions and 10 deletions

View File

@@ -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
}

View File

@@ -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