private void LoadInitialData() { /* * Init Roles * */ IUserRepository userRepo = DependencyResolver.Current.GetService <IUserRepository>(); userRepo.CreateUser("admin", "admin", "*****@*****.**", Role.Administrator); userRepo.ActivateUser("admin"); userRepo.CreateUser("user", "user", "*****@*****.**", Role.AuthUser); userRepo.ActivateUser("user"); //if ( Roles.GetAllRoles().Length == 0) //{ // Roles.CreateRole( FollowMyTvRoles.ADMINISTRATOR ); // Roles.CreateRole( FollowMyTvRoles.AUTH_USER ); //} //if( Membership.FindUsersByName("administrator").Count == 0 ) //{ // MembershipCreateStatus status; // Membership.CreateUser( "administrator", "administrator", "admin@isel-leic-pi", "Question", "Answer", true, out status ); // Console.WriteLine( status ); // Roles.AddUserToRole("administrator", FollowMyTvRoles.ADMINISTRATOR ); //} }
public IActionResult PutUser(UpdateUserDto user) { var userDto = user.IsActive ? _userRepository.ActivateUser(user.UserId) : _userRepository.DeactivateUser(user.UserId); userDto = _userRepository.UpdateEmail(user.UserId, user.Email); return(Ok(userDto)); }
public ActionResult ActivateUser(int id) { if (_userRepository.ActivateUser(id)) { return(RedirectToAction("ListAll")); } return(View()); }
public async Task ActivateUser(Guid activationToken) { var user = await _userRepository.GetUserByActivationToken(activationToken); if (user.IsActive) { throw new BadRequestException("User has been already activated"); } await _userRepository.ActivateUser(user.Id); }
public async Task <IActionResult> ActivateUser(int id) { var userActivate = await _repo.GetUser(id); userActivate.IsActive = true; bool succes = await _repo.ActivateUser(userActivate); if (succes) { User currentUser = _userManager.FindByNameAsync(User.Identity.Name).Result; succes = await _eventLogRepo.AddEventLog(EventType.Activated, "bruger", userActivate.UserName, userActivate.Id, currentUser); } return(succes ? StatusCode(200) : BadRequest()); }
public ActionResult Activation(string id) { Guid guid = new Guid(id); Activation activation = Repo.GetById(guid); if (activation != null) { if (!activation.IsUsed) { bool result = userRepo.ActivateUser(activation.Username); if (result) { return(RedirectToAction("LogOn")); } } } return(View("Error")); }
public IActionResult ActivateUser([FromBody] UserContact userContact) { var user = _repository.GetDeactivatedUser(userContact.EmailAddress); if (user == null) { return(NotFound()); } try { _repository.ActivateUser(user); return(Ok("Activation successfull")); } catch (Exception e) { _logger.LogError($"Exception while trying to activate user: ${userContact.EmailAddress}"); } return(BadRequest("Unable to perform requested action")); }
public ActionResult <ResultModel <UserViewModel> > ActivateUser([FromBody] UserViewModel model) { var result = new ResultModel <UserViewModel> { Success = true }; try { var user = _userRepository.GetUserByActivationCode(model.EmailVerificationCode); if (user.IsEmailVerified == true) { result.Success = false; result.ErrorMessage = "Your account is already activated"; } else { result.Data = new UserViewModel { Email = user.Email }; _userRepository.ActivateUser(new UserModel { EmailVerificationCode = model.EmailVerificationCode, DisplayName = model.DisplayName, Password = model.Password }); } return(Ok(result)); } catch { result.Success = false; result.ErrorMessage = "Server error"; return(Ok(result)); } }
public async Task <ActionResult> Activate(Guid id) { await _userRepository.ActivateUser(id); return(RedirectToAction(nameof(Index))); }
public async Task ActivateUser(int id) { await _userRepository.ActivateUser(id); }
public void ActivateUser(int id) { userRepo.ActivateUser(id); }