示例#1
0
    public async Task<ActionResult> Login(LoginViewModel model, string returnUrl)
    {
      if (ModelState.IsValid)
      {
        bool result = PTPrincipal.Login(model.UserName, model.Password);
        var user = new MvcUI.Models.PTApplicationUser((ProjectTracker.Library.Security.PTIdentity)Csla.ApplicationContext.User.Identity);
        if (result && user != null)
        {
          await SignInAsync(user, model.RememberMe);
          return RedirectToLocal(returnUrl);
        }
        else
        {
          ModelState.AddModelError("", "Invalid username or password.");
        }
      }

      // If we got this far, something failed, redisplay form
      return View(model);
    }
示例#2
0
        public async Task <ActionResult> Login(LoginViewModel model, string returnUrl)
        {
            if (ModelState.IsValid)
            {
                bool result = PTPrincipal.Login(model.UserName, model.Password);
                var  user   = new MvcUI.Models.PTApplicationUser((ProjectTracker.Library.Security.PTIdentity)Csla.ApplicationContext.User.Identity);
                if (result && user != null)
                {
                    await SignInAsync(user, model.RememberMe);

                    return(RedirectToLocal(returnUrl));
                }
                else
                {
                    ModelState.AddModelError("", "Invalid username or password.");
                }
            }

            // If we got this far, something failed, redisplay form
            return(View(model));
        }