🐛 Fix didn't handle invalid auth sessions

This commit is contained in:
LittleSheep 2024-03-17 23:13:44 +08:00
parent ea460c3623
commit 437c2e5b4b
2 changed files with 3 additions and 1 deletions

View File

@ -46,6 +46,6 @@ func authFunc(c *fiber.Ctx, overrides ...string) error {
c.Locals("principal", user)
return nil
} else {
return err
return fiber.NewError(fiber.StatusUnauthorized, err.Error())
}
}

View File

@ -56,6 +56,8 @@ func Authenticate(atk, rtk string) (models.Account, string, string, error) {
})
if err != nil {
return user, reply.GetAccessToken(), reply.GetRefreshToken(), err
} else if !reply.IsValid {
return user, reply.GetAccessToken(), reply.GetRefreshToken(), fmt.Errorf("invalid authorization context")
}
user, err = LinkAccount(reply.Userinfo)