aboutsummaryrefslogtreecommitdiff
path: root/API/Service
diff options
context:
space:
mode:
authorSyndamia <kamen.d.mladenov@protonmail.com>2020-12-11 21:25:45 +0200
committerSyndamia <kamen.d.mladenov@protonmail.com>2020-12-11 21:25:45 +0200
commit6ccb8618f2fe79e61702b0ba0ce48182d9293943 (patch)
tree1e9b1222ea7960f5e6c9c78e605ebb75c07858ad /API/Service
parent62c14b8cb87135d2c2bbb86b6bbb480be6a91bbd (diff)
downloadDevHive-6ccb8618f2fe79e61702b0ba0ce48182d9293943.tar
DevHive-6ccb8618f2fe79e61702b0ba0ce48182d9293943.tar.gz
DevHive-6ccb8618f2fe79e61702b0ba0ce48182d9293943.zip
Made login require only username and made null roles to user
Diffstat (limited to 'API/Service')
-rw-r--r--API/Service/UserService.cs9
1 files changed, 7 insertions, 2 deletions
diff --git a/API/Service/UserService.cs b/API/Service/UserService.cs
index 48f6c6e..453e5f4 100644
--- a/API/Service/UserService.cs
+++ b/API/Service/UserService.cs
@@ -26,10 +26,11 @@ namespace API.Service
public async Task<IActionResult> LoginUser(UserDTO userDTO)
{
- if (userDTO == null)
+ User user = this._userDbRepository.FindByUsername(userDTO.UserName);
+
+ if (user == null)
return new NotFoundObjectResult("User does not exist!");
- User user = this._userMapper.Map<User>(userDTO);
// Temporary, TODO: get key from appsettings
var key = Encoding.ASCII.GetBytes(")H@McQfTB?E(H+Mb8x/A?D(Gr4u7x!A%WnZr4t7weThWmZq4KbPeShVm*G-KaPdSz%C*F-Ja6w9z$C&F");
@@ -57,6 +58,10 @@ namespace API.Service
return new BadRequestObjectResult("Username already exists!");
User user = this._userMapper.Map<User>(userDTO);
+
+ if (user.Role == null)
+ user.Role = Roles.User;
+
await this._userDbRepository.AddAsync(user);
return new CreatedResult("CreateUser", user);