コード例 #1
0
 public ActionResult SecurityQuestion(UserData userdata, FormCollection fc1)
 {
     UserCredentials usercr = new UserCredentials();
     usercr = LetsShopImplementation.LoginAfterForgotPassword(userdata.UserId, userdata.SecurityAnswer);
     if (usercr.Password == "")
     {
         ViewBag.message = "Security answer does not match";
         return View(LetsShopImplementation.ForgotPassword(userdata.UserId));
     }
     else
     {
         Login(usercr, fc1);
         return RedirectToAction("Index", "Home");
     }
 }
コード例 #2
0
        //_____________________________________________________________________
        /// <summary>
        /// This method is used during login by a security answer, when a user forgets his/her password.
        /// </summary>
        /// <param name="UserIds"></param>
        /// <param name="SecurityAnswer"></param>
        /// <returns></returns>
        public static UserCredentials LoginAfterForgotPassword(string UserIds, string SecurityAnswer)
        {
            UserData userdata = new UserData();
            string SecurityQuestion = userdata.SecurityQuestion;
            Database _db = EnterpriseLibraryContainer.Current.GetInstance<Database>("LetsShopConnString");
            DbCommand cmdObj = _db.GetStoredProcCommand("LoginAfterForgotPassword");
            _db.AddInParameter(cmdObj, "@UserId", DbType.String, UserIds);
            _db.AddInParameter(cmdObj, "@SecurityQuestion", DbType.String, SecurityQuestion);
            _db.AddInParameter(cmdObj, "@SecurityAnswer", DbType.String, SecurityAnswer);
            _db.AddOutParameter(cmdObj, "@strMessage", DbType.String, 255);
            _db.ExecuteNonQuery(cmdObj);
            string result = _db.GetParameterValue(cmdObj, "@strMessage").ToString();
            UserCredentials use1 = new UserCredentials();
            use1.UserId = UserIds;
            use1.Password = result;

            return use1;
        }
コード例 #3
0
 public string Login(UserCredentials UserCredentials, FormCollection collection)
 {
     try
     {
         ViewBag.LoginMessage = LetsShopImplementation.ValidateUser(UserCredentials.UserId, UserCredentials.Password);
         if ((ViewBag.LoginMessage == "Admin logged in successfully") || (ViewBag.LoginMessage == "Guest logged in successfully"))
         {
             string type = ViewBag.LoginMessage;
             type = type.Split(' ')[0];
             Session["usertype"] = type;
             FormsAuthentication.SetAuthCookie(UserCredentials.UserId, false);
         }
         return ViewBag.LoginMessage;
     }
     catch
     {
         return "The network is down. Please try some time later.";
     }
 }