Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $('#log-in').click(function () {
- if (ServerModel.UserId == 0) {//User not logged in, open login dialog
- $("<div></div>")
- .addClass("dialog")
- .addClass("form-dialog")
- .attr("id", "login-dialog")
- .appendTo("body")
- .dialog({
- title: 'LOGIN',
- close: function () { $(this).remove() },
- modal: true,
- width: 323,
- resizable: false
- })
- .load(ActionUrls.LogOn);
- }
- });
- @using (Ajax.BeginForm(new AjaxOptions { HttpMethod = "POST", UpdateTargetId = "login-dialog" }))
- {
- //Login form fileds in here with submit button at the end
- }
- [HttpGet]
- public ActionResult LogOn()
- {
- return PartialView("_Logon");
- }
- [HttpPost]
- public ActionResult LogOn(LogOnModel model)
- {
- if (ModelState.IsValid)
- {
- CustomSqlMembershipProvider provider = new CustomSqlMembershipProvider();
- if (provider.ValidateUser(model.UserName, Security.ComputeHash(model.Password)))
- {
- FormsAuthentication.SetAuthCookie(model.UserName, model.RememberMe);
- return RedirectToAction("Index", "Home");
- }
- else
- {
- ModelState.AddModelError("", "The user name or password provided is incorrect.");
- }
- }
- // something failed, redisplay partial view with the model
- return PartialView("_Logon", model);
- }
- ...
- .load(ActionUrls.LogOn, function(data) {
- if (data.redirect) {
- window.location.href = data.redirect;
- else {
- // other
- }
- });
- @using (Ajax.BeginForm(new AjaxOptions { HttpMethod = "POST", UpdateTargetId = "login-dialog" }))
- {
- //Login form fileds in here with submit button at the end
- }
Add Comment
Please, Sign In to add comment