Beispiel #1
0
        public ActionResult <AuthenticateResponse> Login(UserLogin model)
        {
            Boolean status = AuthenticateUsers.AuthenticateUser(model);

            if (status != false)
            {
                var response = new MapUserProfile(_mapper).UserProfileMapped(model);
                if (response != null)
                {
                    var token = _jwtGenerator.generateJwtToken(response, model.Username);
                    return(new AuthenticateResponse(response, token));
                }
                return(Unauthorized(new { message = "This user doesn't register in the system yet" }));
            }
            return(Unauthorized(new { message = "Username or password is incorrect" }));
        }
Beispiel #2
0
        public ActionResult <string> Login(AuthenticateRequest model)
        {
            // Authenticate users FROM ingeni Database
            Boolean status = AuthenticateUsers.AuthenticateUser(model);

            //You're our employee
            if (status == true)
            {
                //Get your profile from base SQL
                var response = new MappingUserProfile(_mapper).UserProfileMapped(model);
                //Get JWT [Json Web Token]
                var responses = _userService.Authenticate(response, model.Username);

                return(Ok(responses));
            }
            //You're not our employee
            return(Unauthorized(new { message = "Username or password is incorrect" }));
            //"{ \"message\": \"Username or password is incorrect\" }"
        }