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