public SetPassword ( UserLogin user, string password ) : void | ||
user | UserLogin | The |
password | string | A |
Résultat | void |
/// <summary> /// Authenticates the specified user name and password /// </summary> /// <param name="user">The user.</param> /// <param name="password">The password.</param> /// <returns></returns> public override bool Authenticate( UserLogin user, string password ) { var passwordIsCorrect = CheckF1Password( user.UserName, password ); if ( passwordIsCorrect ) { using ( var rockContext = new RockContext() ) { var userLoginService = new UserLoginService( rockContext ); var userFromService = userLoginService.Get( user.Id ); var databaseGuid = Rock.SystemGuid.EntityType.AUTHENTICATION_DATABASE.AsGuid(); userFromService.EntityTypeId = EntityTypeCache.Read( databaseGuid ).Id; userLoginService.SetPassword( userFromService, password ); rockContext.SaveChanges(); } } return passwordIsCorrect; }
/// <summary> /// Shows the reset success. /// </summary> private void ShowResetSuccess() { RockContext rockContext = new RockContext(); UserLoginService userLoginService = new UserLoginService( rockContext ); UserLogin user = userLoginService.GetByConfirmationCode( this.ConfirmationCode ); if ( user != null ) { string caption = GetAttributeValue( "PasswordResetCaption" ); if ( caption.Contains( "{1}" ) ) { caption = string.Format( caption, user.Person.FirstName, user.UserName ); } else if ( caption.Contains( "{0}" ) ) { caption = string.Format( caption, user.Person.FirstName ); } lResetSuccess.Text = caption; userLoginService.SetPassword( user, tbPassword.Text ); user.IsConfirmed = true; rockContext.SaveChanges(); pnlResetSuccess.Visible = true; } else { ShowCode(); } }
/// <summary> /// Shows the reset success. /// </summary> private void ShowResetSuccess() { RockContext rockContext = new RockContext(); UserLoginService userLoginService = new UserLoginService( rockContext ); UserLogin user = userLoginService.GetByConfirmationCode( this.ConfirmationCode ); if ( user != null ) { if ( UserLoginService.IsPasswordValid( tbPassword.Text ) ) { string caption = GetAttributeValue( "PasswordResetCaption" ); if ( caption.Contains( "{1}" ) ) { caption = string.Format( caption, user.Person.FirstName, user.UserName ); } else if ( caption.Contains( "{0}" ) ) { caption = string.Format( caption, user.Person.FirstName ); } lResetSuccess.Text = caption; userLoginService.SetPassword( user, tbPassword.Text ); user.IsConfirmed = true; rockContext.SaveChanges(); pnlResetSuccess.Visible = true; } else { nbMessage.NotificationBoxType = Rock.Web.UI.Controls.NotificationBoxType.Danger; nbMessage.Text = UserLoginService.FriendlyPasswordRules(); nbMessage.Visible = true; ShowResetPassword(); } } else { ShowCode(); } }