Example #1
0
        public IActionResult LogIn([FromBody] UserLoginRequest vmodel)
        {
            UserLogInResponse response = new UserLogInResponse();

            if (!string.IsNullOrEmpty(vmodel.Username) && !string.IsNullOrEmpty(vmodel.Password) &&
                vmodel.Username.Equals("admin") && vmodel.Password.Equals("admin"))
            {
                var id       = Guid.NewGuid();
                var username = "******";

                response.Token = _jwtAuthentication.Authenticate(new JwtAuthenticationSettings
                {
                    Key = "r2development@123",
                    LoginExpireInHours = 8,
                    User = new JwtUser
                    {
                        Id       = id,
                        Username = "******"
                    }
                });
                response.Id       = id;
                response.Username = username;
            }


            return(Ok(response));
        }
        public IActionResult Authenticate([FromBody] UserCredentials userCredentials)
        {
            var token = _jwtAuthentication.Authenticate(userCredentials.UserName, userCredentials.Password);

            if (token == null)
            {
                return(Unauthorized());
            }

            return(Ok(token));
        }