fixed bugs
This commit is contained in:
@@ -45,7 +45,7 @@ func (con *AuthApi) signToken(token Claims) (string, error) {
|
||||
token,
|
||||
}
|
||||
|
||||
return t.SignedString(con.config.Signing.Key)
|
||||
return t.SignedString([]byte(con.config.Signing.Key))
|
||||
}
|
||||
|
||||
func AuthorizedTo(requiredPermissions models.Permission) gin.HandlerFunc {
|
||||
@@ -84,7 +84,7 @@ func (con *AuthApi) LoggedIn(ctx *gin.Context) {
|
||||
}
|
||||
|
||||
// hmacSampleSecret is a []byte containing your secret, e.g. []byte("my_secret_key")
|
||||
return con.config.Signing.Key, nil
|
||||
return []byte(con.config.Signing.Key), nil
|
||||
})
|
||||
if err != nil {
|
||||
ctx.AbortWithError(403, err)
|
||||
@@ -156,6 +156,7 @@ func (con AuthApi) signIn(ctx *gin.Context) {
|
||||
}
|
||||
userItem, err := con.userAuthDbHandler.AuthenticateUser(ctx, request.Username, request.Password)
|
||||
if err != nil {
|
||||
println("handler")
|
||||
ctx.AbortWithError(403, err)
|
||||
return
|
||||
}
|
||||
@@ -171,7 +172,7 @@ func (con AuthApi) signIn(ctx *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
ctx.SetCookie("auth", signedToken, int(time.Hour)*24*30, "", "."+con.config.Domain, true, false)
|
||||
ctx.SetCookie("auth", signedToken, int(time.Hour)*24*30, "", "."+con.config.Domain, false, false)
|
||||
ctx.IndentedJSON(http.StatusOK, signedToken)
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user