SBM ModScript Reference → SBM ModScript Samples → Sample Four: Self-Registration Validation
This sample is an example of a script that can be run from the self-registration context.
/* ModScript Example: SelfRegValidationExample.tsc
Purpose: Perform additional password validation for self-registration form.
Context: Registration Form Settings for the "Self-Registration by External
Users" feature.
Implementation: Verify that the password is at least 5 characters. */
/* Validate that the Shell contains the properties that are
expected to be there in the context of the self-registration form.*/
if ( !( Ext.ShellHasProp( "RegistrationMethod" ) && Ext.ShellHasProp( "Password" ) ) ) {
Shell.RedoMessage() = "Missing shell properties, is this a Self-Registration context?";
}
else {
/* Only verify the password if the registration mode is "automatic".
In 'manual' registration mode the form doesn't ask for a login id
and password. In automatic mode, Shell.registrationMethod is 1
and in manual mode, Shell.registrationMethod is 0. */
if ( Shell.RegistrationMethod() == "automatic" ) {
if ( Shell.Password().to_string().size() < 5 ) {
// could also use Len( Shell.Password() ), but using this to demo that
→Variants can be converted to the ChaiScript string class
Shell.RedoMessage() = "Password must be at least 5 characters";
}
}
}
Copyright © 2007–2017 Serena Software, Inc. All rights reserved.