public async Task <ActionResult> Register(GetRegisterRequest request, CancellationToken ct) { var client = await _ioAuthClientsService.GetByClientIdAsync(request.client_id, ct); if (!client.IsValid()) { return(BadRequest("Client not found")); } if (!client.IsMatchRedirectUri(request)) { return(BadRequest("Invalid redirect uri")); } if (!client.IsScopesInclude(request.scope)) { return(BadRequest("Invalid scopes")); } var model = new RegisterViewModel( request.client_id, request.response_type, request.scope, request.redirect_uri, request.state, request.Surname, request.Name, request.Login, request.Email, request.Phone, request.IsPasswordsNotEqual, request.IsLoginExists, request.IsEmailExists, request.IsPhoneExists); return(View("~/OAuth/Views/Register.cshtml", model)); }
public static bool IsMatchRedirectUri(this OAuthClient oAuthClient, GetRegisterRequest request) { return(IsMatchRedirectUri(oAuthClient, request.redirect_uri)); }
public async Task <ActionResult> Register([FromForm] PostRegisterRequest request, CancellationToken ct) { var client = await _ioAuthClientsService.GetByClientIdAsync(request.client_id, ct); if (!client.IsValid()) { return(BadRequest("Client not found")); } if (!client.IsMatchRedirectUri(request)) { return(BadRequest("Invalid redirect uri")); } if (!client.IsScopesInclude(request.scope)) { return(BadRequest("Invalid scopes")); } if (request.Password != request.PasswordConfirmation) { var newRegisterRequest = new GetRegisterRequest { client_id = request.client_id, response_type = request.response_type, scope = request.scope, state = request.state, redirect_uri = request.redirect_uri, Surname = request.Surname, Name = request.Name, Login = request.Login, Email = request.Email, Phone = request.Phone, IsPasswordsNotEqual = true }; return(RedirectToAction("Register", newRegisterRequest)); } var isLoginExists = await _identityStatusService.IsLoginExistsAsync(request.Login, ct); var isEmailExists = await _identityStatusService.IsEmailExistsAsync(request.Email, ct); var isPhoneExists = await _identityStatusService.IsPhoneExistsAsync(request.Phone, ct); if (isLoginExists || isEmailExists || isPhoneExists) { var newRegisterRequest = new GetRegisterRequest { client_id = request.client_id, response_type = request.response_type, scope = request.scope, state = request.state, redirect_uri = request.redirect_uri, Surname = request.Surname, Name = request.Name, Login = request.Login, Email = request.Email, Phone = request.Phone, IsLoginExists = isLoginExists, IsEmailExists = isEmailExists, IsPhoneExists = isPhoneExists }; return(RedirectToAction("Register", newRegisterRequest)); } var phoneIdentityTokenId = await _registrationService.RegisterAsync( request.Country, request.Surname, request.Name, request.Login, request.Email, request.Phone, request.Password, IpAddress, UserAgent, ct); var authorizeResponse = await _oauthService.AuthorizeAsync( request.Country, request.Login, request.Password, request.response_type, request.redirect_uri, request.state, IpAddress, UserAgent, request.scope.ToScopeList(), client.Audience, ct); if (authorizeResponse.IsInvalidCredentials) { var newAuthorizeRequest = new GetAuthorizeRequest { client_id = request.client_id, response_type = request.response_type, scope = request.scope, state = request.state, redirect_uri = request.redirect_uri, IsInvalidCredentials = true }; return(RedirectToAction("Authorize", newAuthorizeRequest)); } var getVerifyPhoneRequest = new GetVerifyPhoneRequest { TokenId = phoneIdentityTokenId, CallbackUri = authorizeResponse.CallbackUri, IsInvalidCode = false }; if (_webHostEnvironment.IsDevelopment()) { var phoneIdentityToken = await _identityTokensService.GetAsync(phoneIdentityTokenId, ct); getVerifyPhoneRequest.Code = phoneIdentityToken?.Value; } return(RedirectToAction("VerifyPhone", getVerifyPhoneRequest)); }