Exemplo n.º 1
0
 private void OnAuthCookieSet(object sender, Cookie e)
 {
     if (e != null)
     {
         AuthCookieHelper.SetAuthCookie(e);
     }
 }
Exemplo n.º 2
0
 public void LogOutBtn_Click(object sender, RoutedEventArgs e)
 {
     AuthCookieHelper.RemoveAuthCookie();
     ((App)System.Windows.Application.Current).OpenLoginWindow();
     DisposeOnClosed = false;
     Close();
 }
Exemplo n.º 3
0
        private bool IsLoggedIn(IBarboraApiClient barboraApiClient)
        {
            var authCookie = AuthCookieHelper.GetAuthCookie();

            if (authCookie != null && authCookie.Expires > DateTime.Now)
            {
                barboraApiClient.LogIn(authCookie);
                return(true);
            }

            return(false);
        }
Exemplo n.º 4
0
        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"));
            }
        }
Exemplo n.º 5
0
        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");
            }
        }