Beispiel #1
0
        public virtual async Task ChangePhoneNumberAsync(ChangePhoneNumberDto input)
        {
            // 是否已有用户使用手机号绑定
            if (await UserRepository.IsPhoneNumberConfirmedAsync(input.NewPhoneNumber))
            {
                throw new BusinessException(IdentityErrorCodes.DuplicatePhoneNumber);
            }
            //TODO: 可以查询缓存用 securityTokenCacheItem.SecurityToken 与 user.SecurityStamp 作对比
            var user = await UserManager.GetByIdAsync(CurrentUser.GetId());

            // 更换手机号
            (await UserManager.ChangePhoneNumberAsync(user, input.NewPhoneNumber, input.Code)).CheckErrors();

            await CurrentUnitOfWork.SaveChangesAsync();

            var securityTokenCacheKey = SmsSecurityTokenCacheItem.CalculateCacheKey(input.NewPhoneNumber, "SmsChangePhoneNumber");
            await SecurityTokenCache.RemoveAsync(securityTokenCacheKey);
        }
Beispiel #2
0
 public virtual async Task ChangePhoneNumberAsync(ChangePhoneNumberDto input)
 {
     await MyProfileAppService.ChangePhoneNumberAsync(input);
 }