mirror of
https://github.com/haiwen/seafile-server.git
synced 2025-04-27 19:15:07 +00:00
Fix skip cache error (#732)
* Fix skip cache error * Delete token cache when failed to get email --------- Co-authored-by: 杨赫然 <heran.yang@seafile.com>
This commit is contained in:
parent
ee9ad5ef39
commit
e2d771852f
@ -1287,13 +1287,15 @@ func validateToken(r *http.Request, repoID string, skipCache bool) (string, *app
|
||||
}
|
||||
}
|
||||
|
||||
if value, ok := tokenCache.Load(token); ok {
|
||||
if info, ok := value.(*tokenInfo); ok {
|
||||
if info.repoID != repoID {
|
||||
msg := "Invalid token"
|
||||
return "", &appError{nil, msg, http.StatusForbidden}
|
||||
if !skipCache {
|
||||
if value, ok := tokenCache.Load(token); ok {
|
||||
if info, ok := value.(*tokenInfo); ok {
|
||||
if info.repoID != repoID {
|
||||
msg := "Invalid token"
|
||||
return "", &appError{nil, msg, http.StatusForbidden}
|
||||
}
|
||||
return info.email, nil
|
||||
}
|
||||
return info.email, nil
|
||||
}
|
||||
}
|
||||
|
||||
@ -1304,6 +1306,7 @@ func validateToken(r *http.Request, repoID string, skipCache bool) (string, *app
|
||||
return email, &appError{err, "", http.StatusInternalServerError}
|
||||
}
|
||||
if email == "" {
|
||||
tokenCache.Delete(token)
|
||||
msg := fmt.Sprintf("Failed to get email by token %s", token)
|
||||
return email, &appError{nil, msg, http.StatusForbidden}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user