コード例 #1
0
ファイル: Registration.cs プロジェクト: jkelin/OpenAAP
        public async Task Register(string password)
        {
            var regData = new PasswordRegisterRequest
            {
                Password = password
            };

            var regResp = await _client.PostJsonAsync <AuthenticationResponse>(
                $"/identity/{Seeder.IdentityNone.Id}/password/register",
                regData
                );

            var loginData = new PasswordLoginRequest
            {
                Password = password
            };

            var loginResp = await _client.PostJsonAsync <AuthenticationResponse>(
                $"/identity/{Seeder.IdentityNone.Id}/password/login",
                loginData
                );
        }
コード例 #2
0
        public async Task <IActionResult> Register(Guid identityId, [FromBody] PasswordRegisterRequest req)
        {
            var hash = await HashPassword(req.Password);

            var auth = new PasswordAuthentication
            {
                Id                    = Guid.NewGuid(),
                CreatedAt             = DateTime.UtcNow,
                EncodedStoredPassword = hash.Serialize(),
                IdentityId            = identityId,
            };

            await DisableRegistration(identityId);

            await ctx.PasswordAuthentications.AddAsync(auth);

            await ctx.SaveChangesAsync();

            return(Ok(new AuthenticationResponse {
                IdentityId = identityId
            }));
        }