RESTLoginView.js revision 5969fecc672d0114b3463008cec7a75cba073821
/**
* The contents of this file are subject to the terms of the Common Development and
* Distribution License (the License). You may not use this file except in compliance with the
* License.
*
* You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
* specific language governing permission and limitations under the License.
*
* When distributing Covered Software, include this CDDL Header Notice in each file and include
* the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
* Header, with the fields enclosed by brackets [] replaced by your own identifying
* information: "Portions copyright [year] [name of copyright owner]".
*
* Portions copyright 2011-2015 ForgeRock AS.
*/
"jquery",
"underscore",
"form2js",
"handlebars",
], function ($, _, AbstractView, AuthNDelegate, BootstrapDialog, Configuration, Constants, CookieHelper, EventManager,
Form2js, Handlebars, i18nManager, Messages, RESTLoginHelper, RealmHelper, Router, SessionManager, UIUtils,
URIUtils) {
function populateTemplate () {
var self = this,
// self-service links should be shown only on the first stage of the UsernamePassword Stages
this.data.showForgotPassword = firstUsernamePassStage && Configuration.globalData.forgotPassword === "true";
this.data.showRegister = firstUsernamePassStage && Configuration.globalData.selfRegistration === "true";
if (Configuration.backgroundLogin) {
this.prefillLoginData();
title: $.t("common.form.sessionExpired"),
cssClass: "login-dialog",
closable: false,
message: $("<div></div>"),
onshow: function () {
var dialog = this;
// change the target element of the view
self.noBaseTemplate = true;
},
onshown: function () {
// return back to the default state
delete self.noBaseTemplate;
}
});
}
}
data: {},
events: {
"click input[type=submit]": "formSubmit",
"click #passwordReset": "selfServiceClick",
"click #register": "selfServiceClick"
},
selfServiceClick: function (e) {
e.preventDefault();
if (overrideRealmParameter) {
} else {
}
},
autoLogin: function () {
var index,
submitContent = {},
}
});
},
isZeroPageLoginAllowed: function () {
return false;
}
if (!referer) {
}
},
formSubmit: function (e) {
var submitContent, expire;
e.preventDefault();
// START CUSTOM STAGE-SPECIFIC LOGIC HERE
expire = new Date();
// An assumption that the login name is the first text input box
}
// END CUSTOM STAGE-SPECIFIC LOGIC HERE
},
var urlParams = {}, // Deserialized querystring params
if (args[1]) {
urlParams = this.handleUrlParams();
}
// If there are IDTokens try to login with the provided credentials
this.autoLogin();
}
}
// Clear out existing session if instructed
}
// If simply by asking for the requirements, we end up with a token,
// then we must have auto-logged-in somehow
// Set a variable for the realm passed into the browser so there can be a
// check to make sure it is the same as the current user's realm
// If we have a token, let's see who we are logged in as....
delete auth.passedInRealm;
$("body").empty();
return false;
}
anonymousMode: false
});
// Copied from EVENT_LOGIN_REQUEST handler
if (Configuration.gotoURL &&
delete Configuration.gotoURL;
} else {
}
});
} else {
}
}, function () {
// There is a tokenId but it is invalid so kill it
});
} else { // We aren't logged in yet, so render a form...
}
// If we can't render a login form, then the user must not be able to login
this.template = this.unavailableTemplate;
this.parentRender(function () {
if (error) {
});
}
});
}, this));
}
});
},
implicitConfirmation = true,
self = this;
var redirectForm,
}));
});
} else {
}
}
implicitConfirmation = false;
}
input: {
},
});
});
if (implicitConfirmation) {
"input": {
name: "loginButton",
value: 0
},
output: [{
name: "options",
value: [$.t("common.user.login")]
}],
type: "ConfirmationCallback",
isSubmit: true
});
}
// Is there an attempt at autologin happening?
// if yes then don't render the form until it fails one time
} else {
// Attempt to load a stage-specific template to render this form. If not found, use the generic one.
.always(function (compiledTemplate) {
// A rendered template will be a string; an error will be an object
self.parentRender(function () {
// Resolve a promise when all templates will be loaded
});
});
}
return promise;
},
prefillLoginData: function () {
} else {
":not([type='submit']):not([type='button']):first").focus();
}
},
handleUrlParams: function () {
// Rest does not accept the params listed in the array below as is
// they must be transformed into the "authIndexType" and "authIndexValue" params
//*** Note special case for authLevel
}
});
// Special case for SSORedirect
}
return urlParams;
}
});
}
});
renderContext = {
};
}
switch (this.type) {
case "TextOutputCallback":
options = {
};
// Magic number 4 is for a <script>, taken from ScriptTextOutputCallback.java
});
} else {
});
}
break;
case "ConfirmationCallback":
// if there is only one option then mark it as default.
});
});
}
break;
case "ChoiceCallback":
return {
};
})
});
}
break;
}
});
return new LoginView();
});