public async Task <ActionResult <UserLogin> > Get(int userId) { var userLoginLogic = new UserLoginLogic(); var model = await userLoginLogic.GetUserLogin(userId); return(Ok(model)); }
public async Task <IActionResult> Get(int userId) { var userLoginLogic = new UserLoginLogic(); var model = await userLoginLogic.GetUserLogin(userId); if (model == null) { return(NotFound()); } return(Ok(model)); }
public async Task <ActionResult <UserLogin> > Get(int userId) { var userLoginLogic = new UserLoginLogic(); var model = await userLoginLogic.GetUserLogin(userId); if (model == null) { return(Ok()); //200 with no content } return(Ok(model)); //200 }
public async Task <string> CreateEmptyCredentialsWithResetToken(int userId, string username) { var userLoginLogic = new UserLoginLogic(AuthContext); var userCredential = await userLoginLogic.CreateEmptyLogin(userId, username); userCredential.ResetToken = GenerateResetToken(); userCredential.ResetExpiration = DateTime.UtcNow.AddMinutes(RESET_TIME_IN_MINUTES); var userCredentialLogic = new UserCredentialLogic(AuthContext); await userCredentialLogic.Update(userCredential); return(userCredential.ResetToken); }
public async Task ResetPassword(int userId) { var userCredentialLogic = new UserCredentialLogic(AuthContext); var userLogic = new UserLogic(Cache, UserContext); var credential = await userCredentialLogic.GetUserCredential(userId); if (credential == null) { var user = await userLogic.GetUserWithoutRelated(userId); var userLoginLogic = new UserLoginLogic(AuthContext); credential = await userLoginLogic.CreateEmptyLogin(userId, user.Username); } await ResetPassword(userCredentialLogic, credential); }
public async Task <UserCredential> FindAndCreateCredentialFromResetText(string resetEntry) { var userLoginLogic = new UserLoginLogic(AuthContext); var searchLogic = new SearchLogic(Cache, UserContext); var userLogic = new UserLogic(Cache, UserContext); UserSearch usernameSearch = new UserSearch { SearchText = resetEntry, SearchUsername = true, Operator = SearchOperator.Equals, PageSize = 1 }; // Search by username Page <UserSearchResponse> result = await searchLogic.Search(usernameSearch); if (result != null && result.Records.Count > 0) { var userResult = result.Records.FirstOrDefault(); return(await userLoginLogic.CreateEmptyLogin(userResult.UserId, userResult.SearchFieldValue)); } UserSearch emailSearch = new UserSearch { SearchText = resetEntry, ProfilePropertyName = "email", Operator = SearchOperator.Equals, PageSize = 1 }; // Search by email Page <UserSearchResponse> emailResult = await searchLogic.Search(emailSearch); if (emailResult != null && emailResult.Records.Count > 0) { if (emailResult.TotalRecordCount > 1) { // Should this be friendly? What can we even do if this happens? // We could only check email if it marked unique throw new CallerException("Multiple users have this email"); } var emailUserResult = emailResult.Records.FirstOrDefault(); var user = await userLogic.GetUserWithoutRelated(emailUserResult.UserId); var userCredentialLogic = new UserCredentialLogic(AuthContext); var credential = await userCredentialLogic.GetUserCredential(user.Username); if (credential != null) { return(credential); } return(await userLoginLogic.CreateEmptyLogin(user.UserId, user.Username)); } return(null); }
public AuthResponseModel LoginUser([FromQuery] string username, string password) { UserLoginLogic login = new UserLoginLogic(); return(login.Login(username, password)); }
public async Task <UserCredential> Post([FromBody] UserCredential userLogin) { var userLoginLogic = new UserLoginLogic(Context); return(await userLoginLogic.CreateLogin(userLogin)); }
public async Task <UserCredential> Get(int userId) { var userLoginLogic = new UserLoginLogic(Context); return(await userLoginLogic.GetUserLogin(userId)); }