Exemplo n.º 1
0
        // [HttpGet]
        public IActionResult Login(User user)
        {
            _log4net.Info("Authentication Started");

            IActionResult response = Unauthorized();
            var           tempuser = _auth.AuthenticateUser(user);

            if (tempuser != null)
            {
                var tokenString = _auth.GenerateJSONWebToken();
                response = Ok(new { token = tokenString });
            }
            return(response);
        }
Exemplo n.º 2
0
        public string GenerateJSONWebTokenFromRepo()
        {
            string tokenFromRepo = "";

            try
            {
                tokenFromRepo = objRepository.GenerateJSONWebToken(config);
                return(tokenFromRepo);
            }
            catch (Exception e)
            {
                return(null);
            }
        }
Exemplo n.º 3
0
        public IActionResult Login(Authenticate user)
        {
            _log4net.Info("post method invoked");
            IActionResult response = Unauthorized();

            if (user != null)
            {
                var tokenString = _authrepo.GenerateJSONWebToken();
                response = Ok(new { token = tokenString });
            }

            return(response);
            // return NotFound();
        }
        // [HttpGet]
        public IActionResult Login(UserDetail userdetail)
        {
            /*user.Id = 1;
             * user.UserName = "******";
             * user.Password = "******";*/
            _log4net.Info("Authentication initiated");
            IActionResult response = Unauthorized();
            var           user     = _auth.AuthenticateUser(userdetail);

            if (user != null)
            {
                var tokenString = _auth.GenerateJSONWebToken();
                response = Ok(new { token = tokenString });
            }

            // return response;

            /* var tokenString = GenerateJSONWebToken();
             * response = Ok(new { token = tokenString });
             * // return Ok(GenerateJSONWebToken());*/
            return(response);
        }