Example #1
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"));
            }
        }
Example #2
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");
            }
        }