Exemplo n.º 1
0
        public IActionResult OnPost()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            var userNoViewModel = UserMapper.MapFromViewModelUser(User);

            _userRepository.AddUser(userNoViewModel);
            _userLoginStatusService.SetLoggedInUser(userNoViewModel);

            TempData["Message"] = $"Welcome to Organizer {userNoViewModel.Name}! Create your first Event!";
            return(RedirectToPage("./Events"));
        }
Exemplo n.º 2
0
        public User LoginUser(string login, string password)
        {
            var user = GetUserFromDataBase(login);

            if (user == null)
            {
                return(null);
            }

            var accessToLogin = ValidateUserLogin(user, password);

            if (accessToLogin == false)
            {
                return(null);
            }

            _loginStatusService.SetLoggedInUser(user);
            return(user);
        }