public ActionResult Connexion(string login, string password) { DCLogin dc = new DCLogin(); if (dc.find(login, password)) { Session["admin"] = true; FormsAuthentication.SetAuthCookie("1", false); return(Redirect("~/Home/Connect")); } else { return(Redirect("~/Login?error=Login ou mot de passe incorrect")); } }
protected override async void OnStart() { if (!Properties.ContainsKey("url")) { Application.Current.Properties["url"] = "https://danceconvention.net"; } if (!Properties.ContainsKey("logLevel")) { Application.Current.Properties["logLevel"] = "information"; } if (Application.Current.Properties["logLevel"].ToString() == "information") { LevelSwitch.MinimumLevel = LogEventLevel.Information; } else { LevelSwitch.MinimumLevel = LogEventLevel.Verbose; } _logger.Verbose("Restoring login information"); if (Properties.ContainsKey("userName") && Properties.ContainsKey("password")) { _logger.Verbose("Login present"); var login = new DCLogin() { Username = Properties["userName"].ToString(), Password = Properties["password"].ToString() }; var service = new DCServiceWrapper(); var loginResult = await service.Login(login); if (loginResult == null) { _logger.Verbose("LoginResult empty, navigate to LoginPage"); NavigateToLoginPage(); return; } _logger.Verbose("LoginResult {Status}, Error message '{Message}'", loginResult.Successful, loginResult.ErrorMessage); if (loginResult.Successful) { await InitializeService(loginResult, service); _logger.Information("Navigating to events page {Url} for user {User}", Properties["url"], Properties["userName"]); NavigateToMainPage(); return; } } else { _logger.Verbose("No login found"); } _logger.Information("Navigating to login page {Url}", Properties["url"]); NavigateToLoginPage(); }