Changeset 899b19d for resTools_backend/backend/Services/UserService.cs
- Timestamp:
- 07/10/22 10:27:45 (2 years ago)
- Branches:
- master
- Children:
- a26f6a1
- Parents:
- cc4db18
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
resTools_backend/backend/Services/UserService.cs
rcc4db18 r899b19d 15 15 { 16 16 Task<AuthenticateResponse> Authenticate(AuthenticateRequest model); 17 Task<AuthenticateResponse> Register(CreateUserRequest req );17 Task<AuthenticateResponse> Register(CreateUserRequest req, bool isFirst); 18 18 Task<User> GetById(int id); 19 19 } … … 40 40 var token = generateJwtToken(user); 41 41 42 return new AuthenticateResponse { Email = user.Email, Id = user.Id, Token = token };42 return new AuthenticateResponse { Email = user.Email, Id = user.Id, Token = token, IsAdmin = user.IsAdmin}; 43 43 } 44 44 … … 48 48 } 49 49 50 public async Task<AuthenticateResponse> Register(CreateUserRequest req )50 public async Task<AuthenticateResponse> Register(CreateUserRequest req, bool isFirst) 51 51 { 52 User user = new User() { Email = req.Email, Password = req.Password };52 User user = new User() { Email = req.Email, Password = req.Password, IsAdmin = isFirst }; 53 53 await _context.Users.AddAsync(user); 54 54 await _context.SaveChangesAsync(); 55 55 var token = generateJwtToken(user); 56 return new AuthenticateResponse { Email = user.Email, Id = user.Id, Token = token };56 return new AuthenticateResponse { Email = user.Email, Id = user.Id, Token = token, IsAdmin = user.IsAdmin }; 57 57 } 58 58
Note:
See TracChangeset
for help on using the changeset viewer.