daily pastebin goal
77%
SHARE
TWEET

Untitled

a guest Jul 21st, 2018 60 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $('#log-in').click(function () {
  2.         if (ServerModel.UserId == 0) {//User not logged in, open login dialog
  3.             $("<div></div>")
  4.             .addClass("dialog")
  5.             .addClass("form-dialog")
  6.             .attr("id", "login-dialog")
  7.             .appendTo("body")
  8.             .dialog({
  9.                 title: 'LOGIN',
  10.                 close: function () { $(this).remove() },
  11.                 modal: true,
  12.                 width: 323,
  13.                 resizable: false
  14.             })
  15.             .load(ActionUrls.LogOn);
  16.         }
  17.     });
  18.    
  19. @using (Ajax.BeginForm(new AjaxOptions { HttpMethod = "POST", UpdateTargetId = "login-dialog" }))
  20. {    
  21.     //Login form fileds in here with submit button at the end
  22. }
  23.    
  24. [HttpGet]
  25.     public ActionResult LogOn()
  26.     {
  27.        return PartialView("_Logon");
  28.     }
  29.  
  30.     [HttpPost]
  31.     public ActionResult LogOn(LogOnModel model)
  32.     {
  33.         if (ModelState.IsValid)
  34.         {
  35.             CustomSqlMembershipProvider provider = new CustomSqlMembershipProvider();
  36.  
  37.             if (provider.ValidateUser(model.UserName, Security.ComputeHash(model.Password)))
  38.             {
  39.                 FormsAuthentication.SetAuthCookie(model.UserName, model.RememberMe);
  40.                 return RedirectToAction("Index", "Home");                    
  41.             }
  42.             else
  43.             {
  44.                 ModelState.AddModelError("", "The user name or password provided is incorrect.");
  45.             }
  46.         }
  47.  
  48.         // something failed, redisplay partial view with the model
  49.         return PartialView("_Logon", model);
  50.     }
  51.    
  52. ...
  53. .load(ActionUrls.LogOn, function(data) {
  54.     if (data.redirect) {
  55.         window.location.href = data.redirect;
  56.     else {
  57.         // other
  58.     }
  59. });
  60.    
  61. @using (Ajax.BeginForm(new AjaxOptions { HttpMethod = "POST", UpdateTargetId = "login-dialog" }))
  62. {    
  63.     //Login form fileds in here with submit button at the end
  64. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top