Ignore:
Timestamp:
08/09/22 16:09:32 (2 years ago)
Author:
Danilo <danilo.najkov@…>
Branches:
master
Children:
a569b7c
Parents:
899b19d
Message:

full auth flow

File:
1 edited

Legend:

Unmodified
Added
Removed
  • resTools_backend/backend/Controllers/UsersController.cs

    r899b19d ra26f6a1  
    4141        }catch (Exception ex){ return null; }
    4242        User user = await _userService.GetById(userId);
    43         return new AuthenticateResponse() { Email=user.Email, Id = user.Id};
     43        return new AuthenticateResponse() { Email=user.Email, Id = user.Id, IsAdmin = user.IsAdmin, IsConfirmed = user.IsConfirmed};
     44    }
     45
     46    [HttpPost("confirm")]
     47    public async Task ConfirmEmail()
     48    {
     49        int userId = 0;
     50        try
     51        {
     52            userId = (int)this.HttpContext.Items["User"];
     53        }
     54        catch (Exception ex) { return; }
     55        User user = await _userService.GetById(userId);
     56        await _userService.SendEmailConfirmation(user.Email);
     57    }
     58
     59    [HttpPost("reset")]
     60    public async Task ResetPassword(string email)
     61    {
     62        await _userService.SendPasswordReset(email);
     63    }
     64
     65    [HttpPost("confirmed")]
     66    public async Task ConfirmedEmail(string validityString)
     67    {
     68        int userId = 0;
     69        try
     70        {
     71            userId = (int)this.HttpContext.Items["User"];
     72        }
     73        catch (Exception ex) { return; }
     74        User user = await _userService.GetById(userId);
     75        await _userService.ConfirmEmail(user, validityString);
     76    }
     77
     78    [HttpPost("reseted")]
     79    public async Task ResetedPassword(string validityString, string newPassword)
     80    {
     81        await _userService.ResetPassword(validityString, newPassword);
    4482    }
    4583
Note: See TracChangeset for help on using the changeset viewer.