diff --git a/Guide.md b/Guide.md index a518ffd..38601d0 100644 --- a/Guide.md +++ b/Guide.md @@ -223,6 +223,7 @@ AccountsTemplates.configure({ onLogoutHook: myLogoutFunc, onSubmitHook: mySubmitFunc, preSignUpHook: myPreSubmitFunc, + postSignUpHook: myPostSubmitFunc, // Texts texts: { @@ -281,6 +282,7 @@ Details for each of them follow. | onLogoutHook | Function | | Called on `AccountsTemplates.logout` invocation: allows for custom redirects or whatever custom action to be taken on user logout. | | onSubmitHook | Function | | `func(error, state)` Called when the `pwdForm` is being submitted: allows for custom actions to be taken on form submission. `error` contains possible errors occurred during the submission process, `state` specifies the `atForm` internal state from which the submission was triggered. A nice use case might be closing the modal or side-menu showing `atForm` | | preSignUpHook | Function | | `func(password, info)` Called just before submitting the `pwdForm` for sign-up: allows for custom actions on the data being submitted. A nice use could be extending the user profile object accessing `info.profile`. to be taken on form submission. The plain text `password` is also provided for any reasonable use. | +| postSignUpHook | Function | | `func(userId, info)` Called, **server side only**, just after a successfull user account creation, post submitting the `pwdForm` for sign-up: allows for custom actions on the data being submitted ___after___ we are sure a new user was ___successfully___ created. A common use might be applying roles to the user, as this is only possible after fully completing user creation in alanning:roles. The `userId` is available as the first parameter, so that user user object may be retrieved. The `password` is not available as it's already encrypted, though the encrypted password may be found in `info` if of use. | ##### onSubmitHook diff --git a/lib/core.js b/lib/core.js index d5be960..4dfb626 100644 --- a/lib/core.js +++ b/lib/core.js @@ -130,6 +130,7 @@ CONFIG_PAT = { onLogoutHook: Match.Optional(Function), onSubmitHook: Match.Optional(Function), preSignUpHook: Match.Optional(Function), + postSignUpHook: Match.Optional(Function), texts: Match.Optional(TEXTS_PAT), diff --git a/lib/server_methods.js b/lib/server_methods.js index 4b546c5..500440d 100644 --- a/lib/server_methods.js +++ b/lib/server_methods.js @@ -107,6 +107,12 @@ Meteor.methods({ throw new Error("createUser failed to insert new user"); } + // Call postSignUpHook, if any... + var postSignUpHook = AccountsTemplates.options.postSignUpHook; + if (postSignUpHook) { + postSignUpHook(userId, options); + } + // Send a email address verification email in case the context permits it // and the specific configuration flag was set to true if (options.email && AccountsTemplates.options.sendVerificationEmail) {