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