예제 #1
0
 private void OnAuthCookieSet(object sender, Cookie e)
 {
     if (e != null)
     {
         AuthCookieHelper.SetAuthCookie(e);
     }
 }
예제 #2
0
 public void LogOutBtn_Click(object sender, RoutedEventArgs e)
 {
     AuthCookieHelper.RemoveAuthCookie();
     ((App)System.Windows.Application.Current).OpenLoginWindow();
     DisposeOnClosed = false;
     Close();
 }
예제 #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);
        }
예제 #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"));
            }
        }
예제 #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");
            }
        }