orchardcms - Orchard CMS ask for an invite token to link to backend data during registration using workflows only -


i using orchard cms v1.9 , want display custom registration page accept usual username/password/email , additional token (invite token). token used match user custom data on server.

i have walked through blog customizing user registation dynamic forms , workflows. in addition achieved in blog want force registering user enter token. token used lookup data on server , create link userpart.

adding token form not issue - querying , linking entered token backend data , storing in userpart im finding awkward.

  • is possible using workflows - or need custom module? did not see custom action allowed me match token , link.

  • is there custom module available something
    similar?

disclaimer: approach based on orchard 1.10 developed on 1.9.x branch. not rely on dynamic forms , workflows, think achieve similar modules.

okay ended building example module our approach extended users / activation system. stripped out lot of code, let juicy parts, aren't directly related answer, in it.

first should check out userscontroller has activate actions searching for. may need extend orchard logon-view , include & post actions accordingly.

[allowanonymous] [httpget] public actionresult activate(string activationcode) {     // validation stuff....      var viewmodel = new customuseractivate     {         // activationcode you're looking         activationcode = userfromactivationcode.activationcode,         username = userfromactivationcode.user.username,         welcometext = userfromactivationcode.welcometext,         email = userfromactivationcode.user.email     };      return this.view(viewmodel); }  [allowanonymous] [httppost] [validateantiforgerytoken] public actionresult activate(customuseractivate input) {     if ( input == null )     {         this.modelstate.addmodelerror("_form", this.t("the argument cannot null").text);     }      customuserpart customuserpart = null;     if ( this.modelstate.isvalid )     {         customuserpart = this.myservice.getcustomuserbyactivationcode(input.activationcode);          if ( customuserpart == null || customuserpart.user == null || customuserpart.user.username != input.username )         {             this.notifier.add(notifytype.error, this.t("the activation failed"));         }          if ( string.isnullorempty(input.email) )         {             this.modelstate.addmodelerror("email", this.t("you must specify email address.").text);         }         else if ( input.email.length >= 255 )         {             this.modelstate.addmodelerror("email", this.t("the email address provided long.").text);         }         else if ( !regex.ismatch(input.email, userpart.emailpattern, regexoptions.ignorecase) )         {             // http://haacked.com/archive/2007/08/21/i-knew-how-to-validate-an-email-address-until-i.aspx                 this.modelstate.addmodelerror("email", this.t("you must specify valid email address.").text);         }         else if ( !this.myservice.verifyemailunicity(customuserpart.user.id, input.email) )         {             this.modelstate.addmodelerror("email", this.t("this email address in use.").text);         }     }      if ( !this.modelstate.isvalid )     {         return this.view(input);     }      debug.assert(customuserpart != null, "customuserpart != null");     var user = customuserpart.user;     var userparams = new createuserparams(user.username, input.password, input.email, passwordquestion: null, passwordanswer: null, isapproved: true);     this.myservice.activatecustomuser(customuserpart.id, userparams);      this.notifier.add(notifytype.information, this.t("your account activated. can log in."));     return this.redirecttoaction("logon", "account", new { area = "orchard.users" }); } 

the interesting stuff happens in myservice.cs. designed activation system can still leverage features of orchard.user module email-verifcation. we've implemented customsettings, can decide if user get's activated when activationcode used or if trigger normal orchard mechanism.

i guess it's best checkout module , step through code in visual studio.

here 2 screenshots of our activation views.

step 1 - enter activation code enter image description here

step 2 - fill in remaining fields enter image description here

profit!

all additional source make use of customuser / activationcode in workflows, events, tokens, etc. leave discover.

if want more detailed descriptions of source on github let me know. hope helps!


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -