public ActionResult Login(string returnUrl)
        {
            ViewBag.ReturnUrl = returnUrl;

            if (User.Identity.IsAuthenticated)
            {
                if (User.IsInRole("Hirer"))
                {
                    return RedirectToAction("Index", "HirerWorkOrder");
                }
                else
                {
                    return RedirectToAction("Index", "Home");
                }
            }

            if (returnUrl != null && returnUrl != "")
            {
                // Redirect users back to external signin
                string[] controller = returnUrl.Split(new Char[] {'/'});
                if (controller.Length >= 2 && (controller[1] == "HirerWorkOrder" || controller[1] == "HirerAccount"))
                {
                    return RedirectToAction("Login", "HirerAccount");
                }
            }

            LoginViewModel model = new LoginViewModel();
            model.Action = "ExternalLogin";
            model.ReturnUrl = returnUrl;
            return View(model);
        }
        public async Task<ActionResult> Login(LoginViewModel model, string returnUrl)
        {
            if (ModelState.IsValid)
            {
                var user = await UserManager.FindAsync(model.UserName, model.Password);
                if (user != null)
                {
                    levent.Level = LogLevel.Info; levent.Message = "Logon successful";
                    levent.Properties["username"] = model.UserName; log.Log(levent);
                    await SignInAsync(user, model.RememberMe);
                    return RedirectToLocal(returnUrl);
                }
                else
                {
                    ModelState.AddModelError("", Machete.Web.Resources.ValidationStrings.invalidLogin);
                }
            }

            // If we got this far, something failed, redisplay form
            levent.Level = LogLevel.Info; levent.Message = "Logon failed for " + model.UserName;
            log.Log(levent);
            return View(model);
        }