Child pages
  • Registration

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

ApstrataSDK code is available as open source from google code, to obtain the latest:

...

languagebash

...

GitHub at https://github.com/apstrata/SDKs/tree/master/ApstrataSDK.

ApstrataSDK depends on the dojo 1.6 framework, you can download from here: http://download.dojotoolkit.org/release-1.6.1/dojo-release-1.6.1-src.zip

...

You need to set the apstrata connection parameters in the file ApstrataSDK/apstrata/sdk/ApConfig.js to use you account authentication key and secret. 

 

Code Block
languagejavascript
    "apstrata.sdk": {
        "Connection" : {
            credentials: {
                key: "<the authentication key of your apstrata account>",
                secret: "<the secret of your apstrata account>",
            },
            serviceURL: '<the apstrata base URL, i.e. https://sandbox.apstrata.com/apsdb/rest>',
            timeout: <the connection timeout in milliseconds>
        }
    }

 

Installing the server side scripts

...

After installing the server side scripts in your apstrata account, go to the script named "widgets.common" and configure the following parameters:

 

Code Block
languagejavascript
// The name of the project (or site) the user is subscribing to
var projectName = "";

// The name of the default group to which subscribing users will belong once registered
var defaultUsersGroup = "";

// The store where temporary registration documents will be created on the client application (user registration and/or account provisioning))
var defaultUnconfirmedRegistrationStore = "";    

// The url of the client application (user registration and/or account provisioning)
var apstrataHomeEnvironment = ";

// The auth key of the provisioning account on the client application
var apstrataHomeKey = "";

// The secret of the provisioning account on the client application
var apstrataHomeSecret = "";

// The type of registration that is required ("user" -> for user registration, or "account" -> for account creation)
var registrationType = "";

// Specify if an email should be sent to the user upon successful registration (true/false)
var sendEmailOnceRegistrationConfirmed = ;

// The URL that is sent in the verification e-mail for the subscriber to click on (you normally should not change this)
var verifyUrl = apstrataHomeEnvironment + "/apsdb/rest/" + apstrataHomeKey + "/RunScript?apsws.authMode=simple&apsdb.scriptName=widgets.Registration.verifyAccount&login=$login&d=$confirmation";

// The URL where to redirect the user after he submits his registration form
var registrationRedirectUrl = ""
 
var configuration = {
    projectName: projectName,
    defaultUsersGroup: defaultUsersGroup,
    defaultUnconfirmedRegistrationStore: defaultUnconfirmedRegistrationStore,    
    apstrataHomeEnvironment: apstrataHomeEnvironment,    
    apstrataHomeKey: apstrataHomeKey,
    registrationType: registrationType,
    registrationRedirectUrl: registrationRedirectUrl,
    sendEmailOnceRegistrationConfirmed: sendEmailOnceRegistrationConfirmed,    
    templates: {
        adminEmail: "dude@dude.com",
        subject: "$projectName Registration - Email Verification",
        body: "<div style='font-family:Calibri, font-size:11'>Hello $user,<br/><br/> Thank you for signing up to our $projectName <br/><br/> Please click on the link below to activate your account. If the link doesn't work, copy and paste the link directly into the address bar of your internet browser.<br/><a href='$url'>$url</a><br/><br/>Sincerely<br/><br/>The $projectName Team",        
        verifyUrl: verifyUrl 
    },

    templatesConfirmed: {
        adminEmail: "dude@dude.com",
        subject: "$projectName Registration confirmed",
        body: "<div style='font-family:Calibri, font-size:11'>Hello $user,<br/><br/> Welcome to our $projectName <br/><br/> Your account has been activated.<br/>Sincerely<br/><br/>The $projectName Team",
    }
}

 

NOTE: The above configuration assumes that the required stores have already been created in the apstrata account.

 

Embedding the widget in your web application

  1. Make sure to reference the dojo and apstrata core scripts and css files

    Code Block
    languagejavascript
    <script type="text/javascript" src="<relative path to dojo/dojo.js>" djConfig="parseOnLoad: true"></script>
    <script type="text/javascript" src="<relative path to ApstrataSDK/apstrata/sdk/apstrata.js>"></script>
    
    
    <style>
    	@import "<relative path to dojo/dijit/themes/claro/claro.css>";
    	@import "<relative path to ApstrataSDK/apstrata/ui/themes/apstrata/apstrata.css>";
    	@import "<relative path to ApstrataSDK/apstrata/ui/themes/apstrata/RegistrationWidget.css>";
    </style>
  2. Include the apstrata configuration file and the registration widget file

    Code Block
    languagejavascript
    dojo.require("apstrata.sdk.ApConfig")
    dojo.require("apstrata.ui.widgets.RegistrationWidget")
  3. Instantiate the registration widget and place it in your web application page

    Code Block
    languagejavascript
    var rw = new apstrata.ui.widgets.RegistrationWidget()
    dojo.place(rw.domNode, dojo.body())

Example

Please refer to the file "ApstrataSDK/apstrata\ui/widgets/tests/test-Registration.html" for a complete example on how to embed the widget