/// <summary> /// This handler will lock the account using ???? /// </summary> /// <param name="message">The command object that was sent</param> /// <param name="context">Contains information relevent to the current command being handled.</param> /// <returns>A task to publish an AccountLocked event</returns> public Task Handle(LockAccount message, IMessageHandlerContext context) { log.Info("Recieved a command to lock an account.", new NotImplementedException()); //TODO MOSHI low importance: Implement logic to lock an account. var accountLocked = new AccountLocked { //TODO MOSHI low importance: Populate this with relevant info, once AccountLocked has been implemented. }; return(context.Publish(accountLocked)); }
public bool LockAccount(Address address) { if (!_passwords.ContainsKey(address)) { if (_logger.IsError) { _logger.Error("Account does not exist."); } return(false); } AccountLocked?.Invoke(this, new AccountLockedEventArgs(address)); _isUnlocked[address] = false; return(true); }
public async Task <AuthenticateResult> Authenticate(string email, string password) { email.CheckIfNull(nameof(email)); password.CheckIfNull(nameof(password)); var identity = await _identityRepository.GetByEmail(email); if (identity == null || !identity.IsEnabled) { return(AuthenticateResult.Failed); } if (identity.LockoutEnd > DateTime.UtcNow) { return(AuthenticateResult.Lockout); } if (!_cryptoManager.CheckPassword(password, identity.Password)) { var status = AuthenticateResult.Failed; identity.AccessFailedCount++; identity.LastAccessFailureAt = DateTime.UtcNow; if (identity.AccessFailedCount > 5) { identity.LockoutEnd = DateTime.UtcNow.AddMinutes(5); status = AuthenticateResult.Lockout; await _mediator.Publish(AccountLocked.From(identity)); } await _identityRepository.Update(identity); return(status); } if (identity.AccessFailedCount > 0) { identity.AccessFailedCount = 0; identity.LockoutEnd = null; } identity.LastAccessAt = DateTime.UtcNow; await _identityRepository.Update(identity); return(AuthenticateResult.Ok); }
public bool LockAccount(Address address) { AccountLocked?.Invoke(this, new AccountLockedEventArgs(address)); return(true); }
public bool LockAccount(Address address) { AccountLocked?.Invoke(this, new AccountLockedEventArgs(address)); return(_unlockedAccounts.Remove(address)); }
protected override void afterPopulateProps() { UsernameProperty.SetOnPropChange(OnUserNamePropChange); AvailableWorkUnits.SetOnPropChange(OnAvailableWorkUnitsChange); CurrentWorkUnitProperty.SetOnPropChange(OnCurrentWorkUnitPropertyChange); AccountLocked.SetOnPropChange(onAccountLockedPropChange); AvailableWorkUnits.InitOptions = InitAvailableWorkUnitsOptions; _updateAvailableWorkUnits(); // BZ 6941, 8288 // Set the Default View to use the selected User, rather than the logged in User //DefaultView.User = this; FavoriteViews.User = this; // BZ 8288 // Favorite Actions options should derive from Role's Action Permissions if (_RoleNode != null) { CswCommaDelimitedString NewYValues = new CswCommaDelimitedString(); foreach (CswNbtAction Action in _CswNbtResources.Actions) { if (_CswNbtResources.Permit.can(Action, this) && Action.ShowInList) { NewYValues.Add(Action.DisplayName.ToString()); } } this.FavoriteActions.YValues = NewYValues; } //BZ 9933 if (_CswNbtResources.CurrentNbtUser == null || !_CswNbtResources.CurrentNbtUser.IsAdministrator()) { this.FailedLoginCount.setHidden(value: true, SaveToDb: false); this.AccountLocked.setHidden(value: true, SaveToDb: false); } //case 27793: these are the properties that a user cannot edit -- not even his own if ((null == _CswNbtResources.CurrentNbtUser) || (false == _CswNbtResources.CurrentNbtUser.IsAdministrator())) { this.Role.setReadOnly(true, false); } //case 27793: Prevent non-adminsitrators from editing paswords, except their own if (IsPasswordReadOnly) { this.PasswordProperty.setReadOnly(true, false); } else { this.PasswordProperty.setReadOnly(false, false); } Role.SetOnPropChange(onRolePropChange); DateFormatProperty.SetOnPropChange(onDateFormatPropChange); TimeFormatProperty.SetOnPropChange(onTimeFormatPropChange); //Case 31084: only an administrator can edit other users' profiles if ((null == _CswNbtResources.CurrentNbtUser) || (false == _CswNbtResources.CurrentNbtUser.IsAdministrator() && UserId != _CswNbtResources.CurrentNbtUser.UserId)) { this.Node.setReadOnly(true, false); } }
public bool LockAccount(Address address) { AccountLocked?.Invoke(this, new AccountLockedEventArgs(address)); throw new NotSupportedException(); }
public bool LockAccount(Address address) { AccountLocked?.Invoke(this, new AccountLockedEventArgs(address)); _unlockedAccounts.Delete(address.ToString()); return(true); }
public async Task HandleAsync(AccountLocked @event) => await CompleteAsync(@event, @event.UserId);