Skip to content
Snippets Groups Projects
Commit c681903e authored by Cross, Liam (UG - Comp Sci & Elec Eng)'s avatar Cross, Liam (UG - Comp Sci & Elec Eng)
Browse files

Merge branch 'LC/login-backend' into 'main'

Make login use email instead of username

See merge request ma03081/COM3014!15
parents 0f3921b6 6b0e4d80
No related branches found
No related tags found
No related merge requests found
......@@ -2,7 +2,7 @@
{
public class UserLogin
{
public required string Username { get; set; }
public required string Email { get; set; }
public required string Password { get; set; }
}
......
......@@ -71,7 +71,7 @@ namespace UserMicroservice.Controllers
[HttpPost("login")]
public IActionResult Login([FromBody] LoginModel model)
{
User? user = _userService.GetUser(model.Username, model.Password);
User? user = _userService.GetUser(model.Email, model.Password);
if(user == null)
return Unauthorized();
......
......@@ -2,7 +2,7 @@
{
public class LoginModel
{
public required string Username { get; set; }
public required string Email { get; set; }
public required string Password { get; set; }
}
}
......@@ -7,7 +7,7 @@ namespace UserMicroservice.Services
{
User? GetUser(string username);
User? GetUser(int userId);
User? GetUser(string username, string password);
User? GetUser(string email, string password);
List<User> GetUsers();
User CreateUser(string email, string userName, string password, UserType UserType);
void UpdateUser(int id, string? username, string? email, string? password);
......
......@@ -45,9 +45,9 @@ namespace UserMicroservice.Services
return user;
}
public User? GetUser(string username, string password)
public User? GetUser(string email, string password)
{
User? user = GetUser(username);
User? user = GetUserByEmail(email);
if (user != null)
{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment