fix: no database check when using accessToken (#461)

Signed-off-by: 0x2a <stevesough@gmail.com>
This commit is contained in:
Steve0x2a
2022-01-28 15:07:42 +08:00
committed by GitHub
parent c1f553440e
commit d129202b95
3 changed files with 31 additions and 26 deletions

View File

@ -156,6 +156,16 @@ func DeleteToken(token *Token) bool {
return affected != 0
}
func GetTokenByAccessToken(accessToken string) *Token {
//Check if the accessToken is in the database
token := Token{}
existed, err := adapter.Engine.Where("access_token=?", accessToken).Get(&token)
if err != nil || !existed {
return nil
}
return &token
}
func CheckOAuthLogin(clientId string, responseType string, redirectUri string, scope string, state string) (string, *Application) {
if responseType != "code" {
return "response_type should be \"code\"", nil