Example #1
0
        public User Login(LoginInputModel inputModel)
        {
            if (inputModel == null || inputModel.Username == null || inputModel.Password == null)
            {
                throw new UnauthorizedAccessException("Username or Password is non-existing");
            }

            User foundUser = GetAllUsers().FirstOrDefault(u => u.Username.Equals(inputModel.Username));

            if (foundUser == null)
            {
                throw new UnauthorizedAccessException("No user registered with such a name");
            }

            AuthenticationHelper.ValidateLogin(foundUser, inputModel);

            return(foundUser);
        }