onCreate-user-set-default-fields.js revision a8c6d744ff331d62689592d572c7cca1135d5feb
0N/A/*! @license
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
0N/A *
0N/A * Copyright © 2011-2012 ForgeRock AS. All rights reserved.
2362N/A *
0N/A * The contents of this file are subject to the terms
0N/A * of the Common Development and Distribution License
0N/A * (the License). You may not use this file except in
0N/A * compliance with the License.
2362N/A *
0N/A * You can obtain a copy of the License at
2362N/A * http://forgerock.org/license/CDDLv1.0.html
0N/A * See the License for the specific language governing
0N/A * permission and limitations under the License.
0N/A *
0N/A * When distributing Covered Code, include this CDDL
0N/A * Header Notice in each file and include the License file
0N/A * at http://forgerock.org/license/CDDLv1.0.html
0N/A * If applicable, add the following below the CDDL Header,
0N/A * with the fields enclosed by brackets [] replaced by
0N/A * your own identifying information:
0N/A * "Portions Copyrighted [year] [name of copyright owner]"
0N/A */
0N/A
0N/A/**
0N/A * @author jdabrowski
0N/A *
0N/A * This script sets default fields.
0N/A * It forces that user role is openidm-authorized and account status
0N/A * is active.
0N/A *
0N/A * It is run every time new user is created.
0N/A */
0N/A
0N/AuiConfig = openidm.read("config/ui/configuration");
0N/A
0N/Aobject.accountStatus = 'active';
0N/A
0N/Aif(!object.roles) {
0N/A object.roles = 'openidm-authorized';
0N/A}
0N/A
0N/Aif (!object.lastPasswordSet) {
0N/A object.lastPasswordSet = "";
0N/A}
0N/A
0N/Aif (!object.postalCode) {
0N/A object.postalCode = "";
0N/A}
0N/A
0N/Aif (!object.stateProvince) {
0N/A object.stateProvince = "";
0N/A}
0N/A
0N/Aif (!object.passwordAttempts) {
0N/A object.passwordAttempts = "0";
0N/A}
0N/A
0N/Aif (!object.lastPasswordAttempt) {
0N/A object.lastPasswordAttempt = (new Date()).toString();
0N/A}
0N/A
0N/Aif (!object.address1) {
0N/A object.address1 = "";
0N/A}
0N/A
0N/Aif (!object.address2) {
0N/A object.address2 = "";
0N/A}
0N/A
0N/Aif (!object.country) {
0N/A object.country = "";
0N/A}
0N/A
0N/Aif (!object.city) {
0N/A object.city = "";
0N/A}
0N/Aif (!object.givenName) {
object.givenName = "";
}
if (!object.familyName) {
object.familyName = "";
}
if (!object.phoneNumber) {
object.phoneNumber = "";
}
//password and security answer are generated if missing just to keep those attributes filled
if (!object.password) {
object.password = java.util.UUID.randomUUID().toString();
}
if (uiConfig.configuration.siteIdentification) {
if (!object.siteImage) {
object.siteImage = "user.png";
}
if (!object.passPhrase) {
object.passPhrase = "Welcome new user";
}
}
if (uiConfig.configuration.securityQuestions) {
if (!object.securityAnswer) {
object.securityAnswer = java.util.UUID.randomUUID().toString();
}
if (!object.securityQuestion) {
object.securityQuestion = "1";
}
if (!object.securityAnswerAttempts) {
object.securityAnswerAttempts = "0";
}
if (!object.lastSecurityAnswerAttempt) {
object.lastSecurityAnswerAttempt = (new Date()).toString();
}
}