var kUser = new User(user.username, user.password, user.confirmPassword,user.fullName,user.email,user.permanent,user.validated,
user.timestampAccountCreation,user.timestampLastLogin,user.timestampLastPasswordChange,user.locked,
- user.passwordChangeRequired,null,user.readOnly,user.userManagerId);
+ user.passwordChangeRequired,null,user.readOnly,user.userManagerId, user.validationToken);
kUser.rememberme(user.rememberme());
var userJson=ko.toJSON(kUser);
}
var kUser = new User(user.username, user.password, user.confirmPassword,user.fullName,user.email,user.permanent,user.validated,
user.timestampAccountCreation,user.timestampLastLogin,user.timestampLastPasswordChange,user.locked,
- user.passwordChangeRequired,null,user.readOnly,user.userManagerId);
+ user.passwordChangeRequired,null,user.readOnly,user.userManagerId, user.validationToken);
$.log("user.rememberme:"+user.rememberme);
return $.inArray(karmaName,window.redbackModel.operatioNames)>=0;
};
+ addValidationTokenHeader=function(user) {
+ if (user.validationToken) {
+ $.log("Adding validation token "+user.validationToken);
+ $.ajaxSetup({
+ beforeSend: function (xhr) {
+ xhr.setRequestHeader('X-XSRF-TOKEN', user.validationToken);
+ }
+ });
+ } else {
+ $.log("No validation token in user object "+user.username+", "+user.validationToken);
+ }
+ }
+
startArchivaApplication=function(){
$.log("startArchivaApplication");
window.redbackModel.password=user.password();
loginCall(user.username(),user.password(),user.rememberme()
,successLoginCallbackFn,errorLoginCallbackFn,completeLoginCallbackFn);
+ } else {
+ // Token for origin validation
+ addValidationTokenHeader(user);
}
};
}
if (logged == true) {
var user = mapUser(result);
+ addValidationTokenHeader(user);
if (user.passwordChangeRequired()==true){
changePasswordBox(true,false,user);
}
clearForm("#user-login-form");
decorateMenuWithKarma(user);
+
+ // Token for origin validation
$("#login-welcome" ).show();
$("#welcome-label" ).html( $.i18n.prop("user.login.welcome",user.username()));
return;
* @param ownerViewModel
* @param readOnly
* @param uuserManagerId
+ * @param validationToken
*/
User=function(username, password, confirmPassword,fullName,email,permanent,validated,timestampAccountCreation,
- timestampLastLogin,timestampLastPasswordChange,locked,passwordChangeRequired,ownerViewModel,readOnly,userManagerId) {
+ timestampLastLogin,timestampLastPasswordChange,locked,passwordChangeRequired,ownerViewModel,readOnly,
+ userManagerId,validationToken) {
var self=this;
// Potentially Editable Field.
this.username = ko.observable(username);
this.rememberme=ko.observable(false);
+ this.validationToken=validationToken;
+
this.logged=false;
this.remove = function() {
var created = result;
if (created == true) {
displaySuccessMessage( $.i18n.prop("user.admin.created"));
- var onSuccessCall=function(){
+ var onSuccessCall=function(result){
+ var logUser = mapUser(result);
+ currentAdminUser.validationToken=logUser.validationToken;
reccordLoginCookie(currentAdminUser);
+ addValidationTokenHeader(currentAdminUser);
window.archivaModel.adminExists=true;
screenChange();
checkCreateAdminLink();
checkSecurityLinks();
+ if(succesCallbackFn){
+ succesCallbackFn();
+ }
}
loginCall(currentAdminUser.username(), currentAdminUser.password(),false,onSuccessCall);
- if(succesCallbackFn){
- succesCallbackFn();
- }
return this;
} else {
displayErrorMessage("admin user not created");
mapUser=function(data) {
return new User(data.username, data.password, null,data.fullName,data.email,data.permanent,data.validated,
data.timestampAccountCreation,data.timestampLastLogin,data.timestampLastPasswordChange,
- data.locked,data.passwordChangeRequired,self,data.readOnly,data.userManagerId);
+ data.locked,data.passwordChangeRequired,self,data.readOnly,data.userManagerId,
+ data.validationToken);
}