brockallen / BrockAllen.MembershipReboot

MembershipReboot is a user identity management and authentication library.
Other
742 stars 238 forks source link

Questions related to account verification via email #617

Closed rtassarone closed 8 years ago

rtassarone commented 8 years ago

My MembershipReboot configuration looks like this:

<membershipReboot requireAccountVerification="true" ... />

The verification email I get following registration has a link to:

http://localhost/UserAccount/ChangeEmail/Confirm/X6mZAcBdC0q5MdBXBPVQQ

First question is, where is the email content (text, formatting) specified? Second question is, why is the link going to the ChangeEmailController? Final question is, when I click the link I'm asked to reenter my password in order to verify the user. Where can I direct the user such that I successfully verify based on the hash alone?

brockallen commented 8 years ago

You should really use your own IEventHandler<T> rather than the built-in one. The built-in one is mainly for testing/dev sceanrios.

rtassarone commented 8 years ago

I'm reading https://github.com/brockallen/BrockAllen.MembershipReboot/wiki/Email-Configuration and I see the section about configuring an AspNetApplicationInformation object to inform the EmailMessageFormatter of the URLs. Per https://github.com/brockallen/BrockAllen.MembershipReboot/blob/01a256b3de9979b0bc5b32441d673f22c54d40d4/src/BrockAllen.MembershipReboot.WebHost/AspNetApplicationInformation.cs the only configurable URLs are:

I guess the account verification operation just uses the confirm change email url (without actually doing an email address change) and if I want to implement a new, dedicated account verification url it's up to me? Or is there a dedicated endpoint for that that I'm not seeing in any of the existing controllers?

Finally how do I exit the email content? I read in your docs that the strings are embedded.

rtassarone commented 8 years ago

Hi Brock, could I bug you here....? Thanks

brockallen commented 8 years ago

MR uses an event bus architecture for raising notification when stuff happens in MR. Stuff could be like "a user logged in", and other stuff could be "an account was created and we have a email confirmation code that can be sent". MR then provides a default implementation (handler) for these and uses a message formatter object and a message delivery object to format and send the messages. The default formatter is what then uses the "AppInfo" to know what URLs to embed into the emails. And within that, yes, the "Confirm change email url" is used for account creation and changing emails, because it's the same operation within MR (although perhaps different within your branding). You can always read the account and know if it's a new account or not -- there's an extension method for that.

To edit the email content you could either: 1) replace the built in message formatter, or 2) not use any of the default messaging architecture and just implement the IEventHandler<AccountCreatedEvent> yourself and do anything you need/want. You'll have much more control if you choose the latter.