mirror of
https://github.com/haiwen/seafile-server.git
synced 2025-08-05 09:00:36 +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,6 +1287,7 @@ func validateToken(r *http.Request, repoID string, skipCache bool) (string, *app
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !skipCache {
|
||||||
if value, ok := tokenCache.Load(token); ok {
|
if value, ok := tokenCache.Load(token); ok {
|
||||||
if info, ok := value.(*tokenInfo); ok {
|
if info, ok := value.(*tokenInfo); ok {
|
||||||
if info.repoID != repoID {
|
if info.repoID != repoID {
|
||||||
@ -1296,6 +1297,7 @@ func validateToken(r *http.Request, repoID string, skipCache bool) (string, *app
|
|||||||
return info.email, nil
|
return info.email, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
email, err := repomgr.GetEmailByToken(repoID, token)
|
email, err := repomgr.GetEmailByToken(repoID, token)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -1304,6 +1306,7 @@ func validateToken(r *http.Request, repoID string, skipCache bool) (string, *app
|
|||||||
return email, &appError{err, "", http.StatusInternalServerError}
|
return email, &appError{err, "", http.StatusInternalServerError}
|
||||||
}
|
}
|
||||||
if email == "" {
|
if email == "" {
|
||||||
|
tokenCache.Delete(token)
|
||||||
msg := fmt.Sprintf("Failed to get email by token %s", token)
|
msg := fmt.Sprintf("Failed to get email by token %s", token)
|
||||||
return email, &appError{nil, msg, http.StatusForbidden}
|
return email, &appError{nil, msg, http.StatusForbidden}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user