Ignore:
Timestamp:
07/10/22 10:27:45 (2 years ago)
Author:
Danilo <danilo.najkov@…>
Branches:
master
Children:
a26f6a1
Parents:
cc4db18
Message:

reviews full feature

File:
1 edited

Legend:

Unmodified
Added
Removed
  • resTools_backend/backend/Services/UserService.cs

    rcc4db18 r899b19d  
    1515{
    1616    Task<AuthenticateResponse> Authenticate(AuthenticateRequest model);
    17     Task<AuthenticateResponse> Register(CreateUserRequest req);
     17    Task<AuthenticateResponse> Register(CreateUserRequest req, bool isFirst);
    1818    Task<User> GetById(int id);
    1919}
     
    4040        var token = generateJwtToken(user);
    4141
    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};
    4343    }
    4444
     
    4848    }
    4949
    50     public async Task<AuthenticateResponse> Register(CreateUserRequest req)
     50    public async Task<AuthenticateResponse> Register(CreateUserRequest req, bool isFirst)
    5151    {
    52         User user = new User() { Email = req.Email, Password = req.Password };
     52        User user = new User() { Email = req.Email, Password = req.Password, IsAdmin = isFirst };
    5353        await _context.Users.AddAsync(user);
    5454        await _context.SaveChangesAsync();
    5555        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 };
    5757    }
    5858
Note: See TracChangeset for help on using the changeset viewer.