public async Task user_change_password_happy_path() { string email = $"{Helpers.GenerateRandonIdentifier()}@test.com.br"; string password = $"{Helpers.GenerateRandonIdentifier().Substring(0, 20)}"; string newPassword = $"{Helpers.GenerateRandonIdentifier().Substring(0, 20)}"; await _authCommonActions.RegisterNewUserAndConfirmEmailAsync(new RegisterRequest() { Email = email, FirstName = "Test", LastName = "User", Password = password, Phone = "+5599999999999" }).ConfigureAwait(false); SigninResponse signinResponse = await _authCommonActions.AuthValidUserAsync(new SigninRequest() { Email = email, Password = password }).ConfigureAwait(false); await _authCommonActions.ChangeUserPasswordAsync(new ChangePasswordRequest() { CurrentPassword = password, Email = email, NewPassword = newPassword }, signinResponse.Token).ConfigureAwait(false); await _authCommonActions.AuthValidUserAsync(new SigninRequest() { Email = email, Password = newPassword }).ConfigureAwait(false); }
public async Task <SigninResponse> SignInAsync(SigninRequest request) { if (request == null) { throw new ArgumentNullException(nameof(request)); } var response = null as SigninResponse; var manager = await this.managerRepository.GetManagerAsync(request.Email) .ConfigureAwait(false); if (manager != null) { if ((manager.VerificationStatus == VerificationStatus.Verified) && (PasswordHelper.IsValid(request.Password, manager.Password))) { var token = TokenHelper.CreateToken( this.TokenSigningKey, manager.Id.ToString(), manager.Name); response = new SigninResponse() { Token = TokenHelper.EncodeToken(token) }; } } return(response); }
public IResponse createSuccessResponse(PersonEN pPersonAuthenticated) { SigninResponse response = new SigninResponse(); try { response.token = pPersonAuthenticated.CurrentToken; response.AvailableAmount = Decimal.Round(pPersonAuthenticated.SingleBagValue, 2).ToString(); response.SesionID = pPersonAuthenticated.SessionID; response.VendorM = pPersonAuthenticated.VendorM; response.CountryID = pPersonAuthenticated.CountryID.ToString(); response.ISO3Code = pPersonAuthenticated.ISO3Code; response.PhoneCode = pPersonAuthenticated.PhoneCode; response.VendorCode = pPersonAuthenticated.VendorCode; response.ProfileCompleted = pPersonAuthenticated.ProfileCompleted; response.OperatorsBalance = new List <OperatorBalance>(); foreach (var item in pPersonAuthenticated.OperatorsBalance) { OperatorBalance balance = new OperatorBalance(); balance.mobileOperator = item.MobileOperatorName; balance.operatorId = item.MobileOperatorID; balance.balance = item.UserBalance; response.OperatorsBalance.Add(balance); } } catch (Exception ex) { Console.WriteLine(ex.InnerException); } return(response); }
private void SetSessionValues(SigninResponse signinResponse) { LogMessage($"Setting session values.{Environment.NewLine}{signinResponse.ToString()}"); TsUserId = signinResponse.TableauUserId; TsUserName = signinResponse.Username; TsUserToken = signinResponse.TableauToken; TsTrustedToken = signinResponse.TrustedToken; TsCurrentSiteId = signinResponse.TableauSiteId; TsCurrentSiteName = signinResponse.TableauSiteName; }
/// <summary> /// シークレットキー取得API /// 自動的にアプリケーション連携を行い、認証キーの作成に使うシークレットキーを取得することができます。 /// </summary> /// <param name="u_address">利用者のMonacoinアドレス。</param> /// <param name="pass">利用者のパスワード。</param> /// <returns></returns> public SigninResponse Signin(string u_address, string pass) { var slr = SigninLow(u_address, pass); var ret = new SigninResponse(); ret.status = slr.status; ret.error = slr.error; ret.user = AskMonaUser.Create(slr.u_id, slr.secretkey); return(ret); }
public static void SigninUser(string email, string password) { string payLoad = "{\"email\":\"" + email + "\",\"password\":\"" + password + "\",\"returnSecureToken\":true}"; RestClient.Post(AuthSigninURL, payLoad).Then(response => { fsData data = fsJsonParser.Parse(response.Text); SigninResponse signinResponse = new SigninResponse(); serializer.TryDeserialize(data, ref signinResponse).AssertSuccessWithoutWarnings(); userId = signinResponse.localId; idToken = signinResponse.idToken; GameObject.FindGameObjectWithTag("EditorHandler").GetComponent <EditorHandler>().SigninSucceded(); }).Catch(error => { GameObject.FindGameObjectWithTag("EditorHandler").GetComponent <EditorHandler>().SigninFailed(); }); }
/// <summary> /// Autenticar um usuário válido /// </summary> /// <param name="signinRequest">Dados para autenticação</param> /// <returns></returns> public async Task<SigninResponse> AuthValidUserAsync( SigninRequest signinRequest) { _httpClient.DefaultRequestHeaders.Authorization = null; HttpResponseMessage response = await _httpClient.PostAsync( Endpoints.Auth.Signin_v1_0, signinRequest.ToStringContent()).ConfigureAwait(false); response.StatusCode.Should().Be(HttpStatusCode.OK); string bodyResponse = await response.Content.ReadAsStringAsync().ConfigureAwait(false); SigninResponse signinResponse = JsonConvert.DeserializeObject<SigninResponse>( bodyResponse); signinResponse.Should().NotBeNull(); signinResponse.Token.Should().NotBeNull(); signinResponse.RefreshToken.Should().NotBeNull(); return signinResponse; }
public async Task create_new_user_happy_path() { string email = $"{Helpers.GenerateRandonIdentifier()}@test.com.br"; string password = $"{Helpers.GenerateRandonIdentifier().Substring(0, 20)}"; SigninResponse signinResponse = await _authCommonActions.RegisterNewUserConfirmEmailAndAddRoleAsync(new RegisterRequest() { Email = email, FirstName = "Test", LastName = "User", Password = password, Phone = "+5599999999999" }, 0).ConfigureAwait(false); email = $"{Helpers.GenerateRandonIdentifier()}@test.com.br"; password = $"{Helpers.GenerateRandonIdentifier().Substring(0, 20)}"; ManagerUserResponse managerUserResponse = await _authCommonActions.ManagerUsersCreate(new ManagerUserCreateRequest() { Email = email, FirstName = "Test", LastName = "User", Password = password, Phone = "+5599999999999" }, signinResponse.Token).ConfigureAwait(false); string confirmationCode = await AuthCommonActions.GetRegisterConfirmationCodeAsync(email, managerUserResponse.FirstName).ConfigureAwait(false); await _authCommonActions.ConfirmUserEmailAsync(new ConfirmRegisterRequest() { ConfirmRegisterToken = confirmationCode, Email = email }).ConfigureAwait(false); await _authCommonActions.AuthValidUserAsync(new SigninRequest() { Email = email, Password = password }); }
public static async Task <EditPhoneNoResponse> EditPhoneNumberAsync(EditPhoneNoRequest editPhoneNoRequest) { try { var loginRequest = new LoginRequest(editPhoneNoRequest.Username, editPhoneNoRequest.Password); SigninResponse signinResponse = await SigninAsync(loginRequest); if (signinResponse.isLoggedIn == true) { using (var conn = Connection) { DynamicParameters parameters = new DynamicParameters(); parameters.Add("Username", editPhoneNoRequest.Username); parameters.Add("PhoneNumber", editPhoneNoRequest.PhoneNumber); await conn.ExecuteAsync("EditPhoneNoProcedure", parameters, commandType : System.Data.CommandType.StoredProcedure); return(new EditPhoneNoResponse(editPhoneNoRequest.PhoneNumber, true, new List <ServiceResponse> { new ServiceResponse("200", "Successful", null) })); } } else { return(new EditPhoneNoResponse(editPhoneNoRequest.PhoneNumber, false, new List <ServiceResponse> { new ServiceResponse("200", "Authentication Error", null) })); } } catch (Exception ex) { return(new EditPhoneNoResponse(editPhoneNoRequest.PhoneNumber, false, new List <ServiceResponse> { new ServiceResponse("400", "Error Updating your PhoneNumber", new List <Error>() { new Error(ex.GetHashCode().ToString(), ex.Message) }) })); } }
public static async Task <LockAccountResponse> LockAccountAsync(LockAccountRequest lockAccountRequest) { try { var loginRequest = new LoginRequest(lockAccountRequest.Username, lockAccountRequest.Password); SigninResponse signinResponse = await SigninAsync(loginRequest); if (signinResponse.isLoggedIn == true) { using (var conn = Connection) { DynamicParameters parameters = new DynamicParameters(); parameters.Add("Username", lockAccountRequest.Username); await conn.ExecuteAsync("LockAccountProcedure", parameters, commandType : System.Data.CommandType.StoredProcedure); return(new LockAccountResponse(lockAccountRequest.Username, true, new List <ServiceResponse> { new ServiceResponse("200", "Successful", null) })); } } else { return(new LockAccountResponse(lockAccountRequest.Username, false, new List <ServiceResponse> { new ServiceResponse("200", "Authentication Error", null) })); } } catch (Exception ex) { return(new LockAccountResponse(lockAccountRequest.Username, false, new List <ServiceResponse> { new ServiceResponse("400", "Something went wrong", new List <Error> { new Error(ex.GetHashCode().ToString(), ex.Message) }) })); } }
/// <summary> /// シークレットキー取得API /// 自動的にアプリケーション連携を行い、認証キーの作成に使うシークレットキーを取得することができます。 /// </summary> /// <param name="u_address">利用者のMonacoinアドレス。</param> /// <param name="pass">利用者のパスワード。</param> /// <returns></returns> public SigninResponse Signin(string u_address, string pass) { var slr = SigninLow(u_address, pass); var ret = new SigninResponse(); ret.status = slr.status; ret.error = slr.error; ret.user = AskMonaUser.Create(slr.u_id, slr.secretkey); return ret; }