// GET: Home public ActionResult Login(string Account, string Password) { switch (Account.ToLower()) { case "admin": if (Password.ToLower() != "admin") { return(wrongPassword()); } break; case "aaa": if (Password.ToLower() != "aaa") { return(wrongPassword()); } break; case "bbb": if (Password.ToLower() != "bbb") { return(wrongPassword()); } break; case "ccc": if (Password.ToLower() != "ccc") { return(wrongPassword()); } break; default: return(wrongPassword()); break; } code.HQuser user = new code.HQuser() { account = Account, password = Password, id = 1 }; this.Session["user"] = user; HQAuthenticationManager.HQLogin(Account); return(RedirectToAction("Main")); // return View(); }
public void Configuration(IAppBuilder app) { HQAuthenticationManager manager = new HQAuthenticationManager(); manager.Configuration(app); // 使应用程序可以使用 Cookie 来存储已登录用户的信息 // 并使用 Cookie 来临时存储有关使用第三方登录提供程序登录的用户的信息 // 配置登录 Cookie //app.UseCookieAuthentication(new CookieAuthenticationOptions //{ // AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie, // LoginPath = new PathString("/Account/Login"), // CookieDomain = "zhao.cc" // , // CookieName = "CookieAuthentication.hq2" // , // TicketDataFormat = new HQSecureDataFormat() // //, // ,Provider = new CookieAuthenticationProvider // { // // 当用户登录时使应用程序可以验证安全戳。 // // 这是一项安全功能,当你更改密码或者向帐户添加外部登录名时,将使用此功能。 // //OnValidateIdentity = SecurityStampValidator.OnValidateIdentity<ApplicationUserManager, ApplicationUser>( // // validateInterval: TimeSpan.FromMinutes(30), // // regenerateIdentity: (manager, user) => user.GenerateUserIdentityAsync(manager)) // } //}); ; ; ; ////AuthStartup.ConfigureAuth(app); ////配置Middleware 組件 //app.UseCookieAuthentication(new CookieAuthenticationOptions //{ // AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie, // LoginPath = new PathString("/Account2/Login"), // CookieSecure = CookieSecureOption.Never, // CookieDomain = "hqbuy.com", // // TicketDataFormat = null //}) //.UseExternalSignInCookie(); ;; }
public async Task <ActionResult> Login(UserIdentity model) { HQAuthenticationManager.HQLogin("admin"); return(Content("admin")); //var v = zhuche(model).Result; // var user = await UserManager.FindAsync(model.UserName, model.Password); var user = await UserManager.FindByNameAsync(model.UserName); //UserIdentity Uidentity = new UserIdentity(); //Uidentity. if (user != null) { await SignInAsync(user, model.RememberMe); // return Content("ok"); return(RedirectToAction("Main")); } return(Content("")); }
public ActionResult Logout() { this.Session["user"] = null; HQAuthenticationManager.HQLogout(); return(RedirectToAction("Main")); }