コード例 #1
0
        public ActionResult Login(String email, String password)
        {
            AccountHandler handler      = new AccountHandler();
            bool           loginSuccess = handler.LoginDb(email, password);

            // If a user was found, we can log them in
            if (loginSuccess)
            {
                // Create a token which will be good for three days from time of login
                var ciphered = EncryptionHelper.aesCipher(DateTime.Now.AddDays(3).ToString(), email);
                // Return the token
                return(Json(ciphered));
            }

            // Return 401 (Unauthorized) if user data not found or incorrect
            return(new HttpStatusCodeResult(HttpStatusCode.Unauthorized));
        }