示例#1
0
        public async Task <IActionResult> Post([FromForm] LoginModel model)
        {
            // User profile
            Profile = new UserProfile();

            // Security
            Security = new AdvancedSecurity();

            // As an example, AuthService.CreateToken can return Jose.JWT.Encode(claims, YourTokenSecretKey, Jose.JwsAlgorithm.HS256);
            if (await Security.ValidateUser(model, false))
            {
                return(Ok(new { JWT = Security.JwtToken }));
            }
            return(BadRequest("Invalid username or password!"));
        }
示例#2
0
        public async Task <IActionResult> Post([FromForm] LoginModel model)
        {
            // User profile
            Profile = new UserProfile();

            // Security
            Security = new AdvancedSecurity();
            bool validPwd = await Security.ValidateUser(model, false);

            // As an example, AuthService.CreateToken can return Jose.JWT.Encode(claims, YourTokenSecretKey, Jose.JwsAlgorithm.HS256);
            if (validPwd)
            {
                return(Ok(new { JWT = BuildToken(model.Username, Security.CurrentUserID, Security.CurrentParentUserID, Security.CurrentUserLevelID) }));
            }
            else
            {
                return(BadRequest("Invalid username or password!"));
            }
        }