Пример #1
0
        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);
            }
        }
Пример #3
0
        public IHttpActionResult makeUserInactive(string Email)
        {
            LoginAuthentications user = unitOfWork.LoginAuthenticationRepository.GetByID(Email);

            user.Status = "Inactive";
            unitOfWork.LoginAuthenticationRepository.Update(user);
            unitOfWork.Save();

            return(Ok(user));
        }
Пример #4
0
        //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"));
            }
        }
Пример #7
0
        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();
        }
Пример #8
0
        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");
            }
        }
Пример #9
0
        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");
            }
        }