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