(ctx context.Context, accessToken string)
| 61 | } |
| 62 | |
| 63 | func (as *AuthService) GetUserCacheInfo(ctx context.Context, accessToken string) (userInfo *entity.UserCacheInfo, err error) { |
| 64 | userCacheInfo, err := as.authRepo.GetUserCacheInfo(ctx, accessToken) |
| 65 | if err != nil { |
| 66 | return nil, err |
| 67 | } |
| 68 | if userCacheInfo == nil { |
| 69 | return nil, nil |
| 70 | } |
| 71 | cacheInfo, _ := as.authRepo.GetUserStatus(ctx, userCacheInfo.UserID) |
| 72 | if cacheInfo != nil { |
| 73 | userCacheInfo.UserStatus = cacheInfo.UserStatus |
| 74 | userCacheInfo.EmailStatus = cacheInfo.EmailStatus |
| 75 | userCacheInfo.RoleID = cacheInfo.RoleID |
| 76 | // update current user cache info |
| 77 | err := as.authRepo.SetUserCacheInfo(ctx, accessToken, userCacheInfo.VisitToken, userCacheInfo) |
| 78 | if err != nil { |
| 79 | return nil, err |
| 80 | } |
| 81 | } |
| 82 | |
| 83 | // try to get user status from user center |
| 84 | uc, ok := plugin.GetUserCenter() |
| 85 | if ok && len(userCacheInfo.ExternalID) > 0 { |
| 86 | if userStatus := uc.UserStatus(userCacheInfo.ExternalID); userStatus != plugin.UserStatusAvailable { |
| 87 | userCacheInfo.UserStatus = int(userStatus) |
| 88 | } |
| 89 | } |
| 90 | return userCacheInfo, nil |
| 91 | } |
| 92 | |
| 93 | func (as *AuthService) SetUserCacheInfo(ctx context.Context, userInfo *entity.UserCacheInfo) ( |
| 94 | accessToken string, visitToken string, err error) { |
no test coverage detected