コード例 #1
0
ファイル: AccountService.cs プロジェクト: rock-walker/arna
        public async Task<JwtResponse> CompleteUserVerification(ApplicationUser user, string phoneNumber, string code)
        {
            var result = await userManager.ChangePhoneNumberAsync(user, phoneNumber, code);
            if (result.Succeeded)
            {
                //CHECK: looks like I don't need it anymore (most likely uses cookie)
                //await signInManager.SignInAsync(user, isPersistent: false);

                //TODO: rethink this approach
                await AddClaim(user, ApplicationClaims.Verified);
                var jwtIdentity = await CreateJwt(user);

                var refreshToken = identityProvider.GenerateRefreshToken(jwtIdentity);
                jwtIdentity.RefreshToken = refreshToken;

                var options = JwtTokenProducer.InitializeOptions(configuration);
                return JwtTokenProducer.Produce(jwtIdentity, options);
            }

            logger.LogError($"Failed to complete user {user.UserName} verification with ex: {result.Errors.First().Description}.");
            return null;
        }