public BaseResponse verifyPin(VerifyPinReqObj verPin)
        {
            BaseResponse res = new BaseResponse();

            try
            {
                var db = _db;

                var obj = db.User.SingleOrDefault(b => b.Email == verPin.email);

                if (obj != null)
                {
                    if (obj.TokenForgetpw.Equals(verPin.token))
                    {
                        obj.Password = Utils.CreateMD5(verPin.password);
                        res.status   = db.SaveChanges();

                        string subject = Constant.VERIFY_PIN_EMAIL_SUBJECT;
                        string body    = Constant.VERIFY_PIN_EMAIL_BODY;
                        string address = obj.Email;

                        if (Utils.sendEmail(subject, body, address))
                        {
                            res.status           = 1;
                            res.developerMessage = "Password changed successfully.";
                        }
                        else
                        {
                            res.status           = -2;
                            res.developerMessage = "Failed to send email. SMTP Server Down.";
                        }
                    }
                    else
                    {
                        res.status           = 0;
                        res.developerMessage = "Wrong token provided.";
                    }
                }
                else
                {
                    res.developerMessage = "Token is not set in DB OR Email is incorrect.";
                    res.status           = 2;
                }
            }
            catch (Exception e)
            {
                res.developerMessage = "Something went wrong: " + e.Message;
                res.status           = -1;
            }
            return(res);
        }
Пример #2
0
 public BaseResponse VerifyPin([FromBody] VerifyPinReqObj verifyPin)
 {
     return(new UserService(_db).verifyPin(verifyPin));
 }
Пример #3
0
 public BaseResponse VerifyPin([FromBody] VerifyPinReqObj verifyPin)
 {
     return(new BLL.BLL_Users(_db).verifyPin(verifyPin));
 }