3
Vote

Revise Users taking advantage of Workflows

description

Now that we have Workflows, we could get rid of the RegisytrationSettings.NotificationsRecipients settings, allowing the user to completely configure what should happen upon user registration using a workflow (of course we could run a recipe creating a default workflow from the Users settings page).

Essentially redactoring the following code (from Orchard.Users.MembershipService):
if ( registrationSettings != null  && registrationSettings.UsersAreModerated && registrationSettings.NotifyModeration && !createUserParams.IsApproved ) {
                var usernames = String.IsNullOrWhiteSpace(registrationSettings.NotificationsRecipients)
                                    ? new string[0]
                                    : registrationSettings.NotificationsRecipients.Split(new[] {',', ' '}, StringSplitOptions.RemoveEmptyEntries);

                foreach ( var userName in usernames ) {
                    if (String.IsNullOrWhiteSpace(userName)) {
                        continue;
                    }
                    var recipient = GetUser(userName);
                    if (recipient != null)
                        _messageManager.Send(recipient.ContentItem.Record, MessageTypes.Moderation, "email" , new Dictionary<string, string> { { "UserName", createUserParams.Username}, { "Email" , createUserParams.Email } });
                }
            }
With just a Workflow invocation, triggering an event (or even doing so from a IUserEventHandler implementation).

The beauty of having Workflows is that we can now replacing all hardcoded flows (where it makes sense) with configurable ones.

comments

Piedone wrote Nov 22, 2013 at 11:22 AM

Second that! We could just have a UserRegistered event or something (or even possibly have a Workflows event for every IUserEventHandler event).

justrhysism wrote Feb 2 at 11:28 PM

I agree, so long there is a default as part of the initial Orchard recipe.

sebastienros wrote Oct 9 at 7:37 PM

Right now the solution is to create your own workflow, as all the pieces are available.