Example #1
0
        public IActionResult Login([FromBody] Login login)
        {
            IActionResult response = Unauthorized();
            var           userInfo = AuthenticateUser(login);

            if (userInfo.IsBand == 1)
            {
                return(Ok(new { token = "", response = "You have been band and cannot loggin" }));
            }

            if (userInfo.Password != null)
            {
                var tokenString = Jwt.GenerateJSONWebToken(userInfo, _config);
                response = Ok(new { token = "Bearer " + tokenString, response = "" });
                return(response);

                //response = Ok(new { payload = Jwt.decryptJSONWebToken(tokenString) });
            }

            return(Ok(new { token = "", response = "Email or password was typed incorrectly" })); //Email or password was typed incorrectly
        }