perf: delete user cache after cancel 2FA

This commit is contained in:
Andy Hsu
2023-08-06 20:47:58 +08:00
parent 1d06a0019f
commit 30415cefbe
6 changed files with 80 additions and 0 deletions

View File

@ -113,3 +113,18 @@ func Cancel2FAById(id uint) error {
}
return Cancel2FAByUser(user)
}
func DelUserCache(username string) error {
user, err := GetUserByName(username)
if err != nil {
return err
}
if user.IsAdmin() {
adminUser = nil
}
if user.IsGuest() {
guestUser = nil
}
userCache.Del(username)
return nil
}