authorizer/server/utils/cookie.go
Lakhan Samani 1d6191cbcb Add logout resolver
Resolves #8
2021-07-15 15:13:00 +05:30

29 lines
532 B
Go

package utils
import (
"github.com/gin-gonic/gin"
"github.com/yauthdev/yauth/server/constants"
)
func SetCookie(gc *gin.Context, token string) {
secure := true
httpOnly := true
if !constants.IS_PROD {
secure = false
}
gc.SetCookie(constants.COOKIE_NAME, token, 3600, "/", GetFrontendHost(), secure, httpOnly)
}
func DeleteCookie(gc *gin.Context) {
secure := true
httpOnly := true
if !constants.IS_PROD {
secure = false
}
gc.SetCookie(constants.COOKIE_NAME, "", -1, "/", GetFrontendHost(), secure, httpOnly)
}