Added User with ability to login and register. By default, user is not an admin. DTO expects an integer and will convert to Boolean.

This commit is contained in:
Joseph Milazzo 2020-12-13 16:07:25 -06:00
parent 2b521924d0
commit 5da41ea6f3
12 changed files with 239 additions and 10 deletions

View file

@ -38,7 +38,8 @@ namespace API.Controllers
{
UserName = registerDto.Username.ToLower(),
PasswordHash = hmac.ComputeHash(Encoding.UTF8.GetBytes(registerDto.Password)),
PasswordSalt = hmac.Key
PasswordSalt = hmac.Key,
IsAdmin = registerDto.IsAdmin
};
_context.Users.Add(user);
@ -47,7 +48,8 @@ namespace API.Controllers
return new UserDto()
{
Username = user.UserName,
Token = _tokenService.CreateToken(user)
Token = _tokenService.CreateToken(user),
IsAdmin = user.IsAdmin
};
}