Skip to content

Commit

Permalink
Fix(Authentication): Correção erro banco de dados
Browse files Browse the repository at this point in the history
  • Loading branch information
MMichels committed Nov 1, 2023
1 parent cb8ae65 commit d6ec173
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Browl.Api/Controllers/LoginController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public IActionResult Index()
return View();
}

[HttpPost("")]
[HttpPost]
public async Task<IActionResult> AuthenticateAsync(AutenticationCommand command)
{
var authenticated = await _authenticationService.Authenticate(command);
Expand Down
2 changes: 1 addition & 1 deletion Browl.Api/Views/Login/Index.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<div>
<h1>Login</h1>
<div>
<div>
<form method="post" action='@Url.Action("Authenticate", "Login")'>
<label for="email">
Email
Expand Down
2 changes: 1 addition & 1 deletion Browl.Domain/Models/User.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
public class User
{
public int Id { get; set; }
public string Name { get; set; }
public string Nome { get; set; }
public string Email { get; set; }

}
1 change: 1 addition & 0 deletions Browl.Service/Services/AuthenticationService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public AuthenticationService(IUserRepository userRepository, IMapper mapper)

public async Task<AuthenticationVM> Authenticate(AutenticationCommand command) {
Validate(command, new AuthenticationValidator());

var user = _mapper.Map<User>(command);

string passwordHash = command.Password; //Aqui precisa fazer o esquema pra gerar o hash da senha pra validar na base;
Expand Down
2 changes: 1 addition & 1 deletion Browl.Service/Validators/Login/AuthenticationValidator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ internal class AuthenticationValidator : AbstractValidator<AutenticationCommand>
{
public AuthenticationValidator() {
RuleFor(c => c.Email)
.NotEmpty()
.NotEmpty()
.WithMessage("Obrigatório informar o email");

RuleFor(c => c.Password)
Expand Down
4 changes: 2 additions & 2 deletions Infra/Queries/UserQueries.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ SELECT TOP 1
Nome,
Email
FROM
User
Browl.dbo.[User]
WHERE
Email = @email
Email = @Email
AND Passwordhash = @passwordhash
";

Expand Down

0 comments on commit d6ec173

Please sign in to comment.