private void OnAuthCookieSet(object sender, Cookie e) { if (e != null) { AuthCookieHelper.SetAuthCookie(e); } }
public void LogOutBtn_Click(object sender, RoutedEventArgs e) { AuthCookieHelper.RemoveAuthCookie(); ((App)System.Windows.Application.Current).OpenLoginWindow(); DisposeOnClosed = false; Close(); }
private bool IsLoggedIn(IBarboraApiClient barboraApiClient) { var authCookie = AuthCookieHelper.GetAuthCookie(); if (authCookie != null && authCookie.Expires > DateTime.Now) { barboraApiClient.LogIn(authCookie); return(true); } return(false); }
public ActionResult Login(string email, string password) { IAccountRepository accountRepository = new AccountRepository(MvcApplication.RedisConn); AccountService service = new AccountService(accountRepository); UserEntity user = new UserEntity() { Email = email, Password = password }; UserTokenEntity token = service.Login(user); if (token != null) { AuthCookieHelper.CreateAuthCookie(email, token.GetTokenString(), false); return(RedirectToAction("Index", "Home")); } else { return(RedirectToAction("Register")); } }
public ActionResult Register(string email, string password, string passwordRepeat) { try { IAccountRepository accountRepository = new AccountRepository(MvcApplication.RedisConn); AccountService service = new AccountService(accountRepository); UserEntity user = new UserEntity() { Email = email, Password = password }; UserTokenEntity token = service.Register(user); AuthCookieHelper.CreateAuthCookie(email, token.GetTokenString(), false); return(RedirectToAction("Index", "Home")); } catch { throw; //return RedirectToAction("Error500", "Error"); } }