public IActionResult Login([FromBody] LoginRequest loginRequest) { var creditials = Credentials.FromRawData(loginRequest.Email.ToLower(), loginRequest.Password); var client = _userFacade.FindByCredentials(creditials); if (client != null) { string roleClaim; if (client.Type.Equals(UserType.Admin)) { roleClaim = Claims.Roles.Admin; } else if (client.Type.Equals(UserType.Moderator)) { roleClaim = Claims.Roles.Moderator; } else if (client.Type.Equals(UserType.User)) { roleClaim = Claims.Roles.User; } else { roleClaim = Claims.Roles.UnConfirmed; } var response = new LoginResponse(client.UserProfile.Name, client.Credentials.Email, client.UserProfile.AvatarLink, _jwtIssuer.IssueJwt(roleClaim, client.Id), client.UserProfile.IsTeacher); return(Ok(response)); } return(Unauthorized()); }