fix: user verified email will update email status. so user status cache should be updated.

This commit is contained in:
LinkinStar 2022-11-17 12:10:20 +08:00
parent 70efa79547
commit e8ab1c4202
2 changed files with 8 additions and 0 deletions

View File

@ -58,6 +58,10 @@ func (as *AuthService) SetUserCacheInfo(ctx context.Context, userInfo *entity.Us
return accessToken, err
}
func (as *AuthService) SetUserStatus(ctx context.Context, userInfo *entity.UserCacheInfo) (err error) {
return as.authRepo.SetUserStatus(ctx, userInfo.UserID, userInfo)
}
func (as *AuthService) UpdateUserCacheInfo(ctx context.Context, token string, userInfo *entity.UserCacheInfo) (err error) {
err = as.authRepo.SetUserCacheInfo(ctx, token, userInfo)
if err != nil {

View File

@ -413,6 +413,10 @@ func (us *UserService) UserVerifyEmail(ctx context.Context, req *schema.UserVeri
if err != nil {
return nil, err
}
// User verified email will update user email status. So user status cache should be updated.
if err = us.authService.SetUserStatus(ctx, userCacheInfo); err != nil {
return nil, err
}
resp.IsAdmin = userInfo.IsAdmin
if resp.IsAdmin {
err = us.authService.SetCmsUserCacheInfo(ctx, resp.AccessToken, &entity.UserCacheInfo{UserID: userInfo.ID})