private async void OnGenerateTokenButtonClicked(object sender, RoutedEventArgs e) { if (string.IsNullOrEmpty(this.CPFTextBox.Text)) { await new MessageDialog("Você precisa digitar seu CPF!", "CPF inválido").ShowAsync(); return; } if (string.IsNullOrEmpty(this.PassTextBox.Password)) { await new MessageDialog("Você precisa digitar sua senha!", "Senha inválida").ShowAsync(); return; } string token; string cpf = this.CPFTextBox.Text; string rawPass = this.PassTextBox.Password; token = await Task.Run(() => { string pass = HashServices.HashPassword(rawPass, cpf); return(TokenGeneratorService.GenerateToken(pass)); }); this.TokenTextBlock.Text = token; this.TokenExpirationTextBlock.Text = "Válido por " + TokenExpirationTimeSeconds + " segundos"; this.cleanTimer.Start(); }
public void GenerateRefreshToken_ReturnRefreshToken() { //Arrange var services = new TokenGeneratorService(); //Act var result = services.RefreshGenerateToken(); //Assert var assertResult = Assert.IsType <string>(result); Assert.Equal(result, assertResult); }
private Account(AccountBuilder builder) : base(builder.Id) { Email = builder.Email; Confirmed = builder.Confirmed; PasswordHash = builder.PasswordHash; SecurityStamp = builder.SecurityStamp; Created = builder.Created; LastLogin = builder.LastLogin; _roles = builder.Roles; _tokens = builder.Tokens; _tokenGeneratorService = new TokenGeneratorService(); }
public void GenerateToken_ExcitingId_ReturnToken() { //Arrange User user = new User() { UserId = 12, HashPassword = "******", Email = "*****@*****.**", MobileNumber = "123123123", IdentificationNumber = "123123" }; var services = new TokenGeneratorService(); //Act var result = services.GenerateToken(user); //Assert var assertResult = Assert.IsType <string>(result); Assert.Equal(result, assertResult); }