public AuthModel Create(LoginAuthentications loginAuthentications) { auth.Email = loginAuthentications.Email; auth.token = loginAuthentications.AuthToken; return(auth); }
public HttpResponseMessage login(LoginAuthentications auth) { string email = auth.Email.ToString(); LoginAuthentications Usercheck = ctx.Auths.SingleOrDefault(d => d.Email == email); if (Usercheck != null) { if (Usercheck.Password == auth.Password) { HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK, Usercheck); //response.Content(Usercheck.Auth.ToString()); string resp = Usercheck.AuthToken.ToString(); return(response); } else { HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK, "Incorrect User Name or password"); return(response); } } else { HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK, "Incorrect User Name or password"); return(response); } }
public IHttpActionResult makeUserInactive(string Email) { LoginAuthentications user = unitOfWork.LoginAuthenticationRepository.GetByID(Email); user.Status = "Inactive"; unitOfWork.LoginAuthenticationRepository.Update(user); unitOfWork.Save(); return(Ok(user)); }
//This Function will Assign required Data to the Authentication Table public string AssignAuth(AuthModel authModel, string password) { LoginAuthentications auth = new LoginAuthentications(); auth.AuthToken = authModel.token; auth.Status = "Pending"; auth.Email = authModel.Email.ToString(); auth.Password = password; createAuthentication(auth, "create"); return("Success"); }
public IHttpActionResult changePassword(UpdatePasswordModel updatePasswordModel) { LoginAuthentications check = unitOfWork.LoginAuthenticationRepository.GetByID(updatePasswordModel.Email); if (check != null) { userCredentials.changePassword(check, updatePasswordModel); return(Ok("Password Updated Successfully")); } else { return(Ok("Error Occured")); } }
public IHttpActionResult forgetPassward(LoginAuthentications loginAuthentications) { LoginAuthentications check = unitOfWork.LoginAuthenticationRepository.GetByID(loginAuthentications.Email); if (check != null) { userCredentials.forget(check); return(Ok("Please Check Email for further Instructions")); } else { return(Ok("No Matching Account")); } }
public void createAuthentication(LoginAuthentications loginAuthentications, string method) { if (method == "create") { LoginAuthentications log = unitOfWork.LoginAuthenticationRepository.GetLastRow(); loginAuthentications.Id = log.Id + 1; unitOfWork.LoginAuthenticationRepository.Insert(loginAuthentications); } else if (method == "update") { loginAuthentications.LastUpdate = DateTime.Now.ToString(); unitOfWork.LoginAuthenticationRepository.Update(loginAuthentications); } unitOfWork.Save(); }
public string changePassword(LoginAuthentications loginAuthentications, UpdatePasswordModel updatePasswordModel) { string type = "Your Request for changing password was successful. </br> If you believe that this is a mistake, Contact us"; loginAuthentications.Password = updatePasswordModel.NewPassword; createAuthentication(loginAuthentications, "update"); AuthModel authModel = modelCreation.Create(loginAuthentications); string mailStatus = SendMail(authModel, updatePasswordModel.NewPassword, type); if (mailStatus == "Success") { return("success"); } else { return("Error Occurred Inserting Value"); } }
public string forget(LoginAuthentications loginAuthentications) { string type = "We are sorry to hear that you've lost your password."; string Password = Generate().ToString(); loginAuthentications.Password = Password; createAuthentication(loginAuthentications, "update"); AuthModel authModel = modelCreation.Create(loginAuthentications); string mailStatus = SendMail(authModel, Password, type); if (mailStatus == "Success") { return("success"); } else { return("Error Occurred Inserting Value"); } }