public static void Start(SchemaBuilder sb) { if (sb.NotDefined(MethodInfo.GetCurrentMethod())) { sb.Include <ResetPasswordRequestEntity>() .WithQuery(() => e => new { Entity = e, e.Id, e.RequestDate, e.Code, e.User, e.User.Email }); EmailLogic.AssertStarted(sb); EmailModelLogic.RegisterEmailModel <ResetPasswordRequestEmail>(() => new EmailTemplateEntity { Messages = CultureInfoLogic.ForEachCulture(culture => new EmailTemplateMessageEmbedded(culture) { Text = "<p>{0}</p>".FormatWith(AuthEmailMessage.YouRecentlyRequestedANewPassword.NiceToString()) + "<p>{0} @[User.UserName]</p>".FormatWith(AuthEmailMessage.YourUsernameIs.NiceToString()) + "<p>{0}</p>".FormatWith(AuthEmailMessage.YouCanResetYourPasswordByFollowingTheLinkBelow.NiceToString()) + "<p><a href=\"@[m:Url]\">@[m:Url]</a></p>", Subject = AuthEmailMessage.ResetPasswordRequestSubject.NiceToString() }).ToMList() }); } }
public static void Start(SchemaBuilder sb) { if (sb.NotDefined(MethodInfo.GetCurrentMethod())) { sb.Include <ResetPasswordRequestEntity>() .WithQuery(() => e => new { Entity = e, e.Id, e.RequestDate, e.Code, e.User, e.User.Email }); EmailLogic.AssertStarted(sb); EmailModelLogic.RegisterEmailModel <ResetPasswordRequestEmail>(() => new EmailTemplateEntity { DisableAuthorization = true, Messages = CultureInfoLogic.ForEachCulture(culture => new EmailTemplateMessageEmbedded(culture) { Text = "<p>{0}</p>".FormatWith(AuthEmailMessage.YouRecentlyRequestedANewPassword.NiceToString()) + "<p>{0} @[User.UserName]</p>".FormatWith(AuthEmailMessage.YourUsernameIs.NiceToString()) + "<p>{0}</p>".FormatWith(AuthEmailMessage.YouCanResetYourPasswordByFollowingTheLinkBelow.NiceToString()) + "<p><a href=\"@[m:Url]\">@[m:Url]</a></p>", Subject = AuthEmailMessage.ResetPasswordRequestSubject.NiceToString() }).ToMList() }); new Graph <ResetPasswordRequestEntity> .Execute(ResetPasswordRequestOperation.Execute) { CanBeNew = false, CanBeModified = false, CanExecute = (e) => e.Lapsed == false ? null : AuthEmailMessage.YourResetPasswordRequestHasExpired.NiceToString(), Execute = (e, args) => { string password = args.GetArg <string>(); e.Lapsed = true; var user = e.User; var error = UserEntity.OnValidatePassword(password); if (error != null) { throw new ApplicationException(error); } user.PasswordHash = Security.EncodePassword(password); using (AuthLogic.Disable()) user.Execute(UserOperation.Save); } } .Register(); } }