Commit f089c138 authored by Tristan Cavelier's avatar Tristan Cavelier Committed by Sebastien Robin

Fix bug: user was never added to the user array list (Jio localStorage).

parent fe765144
......@@ -59,6 +59,22 @@ var jio_storage_loader = function ( LocalOrCookieStorage, Base64, Jio, $) {
userarray);
};
/**
* checks if a user exists in the user array.
* @method userExists
* @param {string} username The user name
* @return {boolean} true if exist, else false
*/
priv.userExists = function (username) {
var userarray = priv.getUserArray(), i, l;
for (i = 0, l = userarray.length; i < l; i += 1) {
if (userarray[i] === username) {
return true;
}
}
return false;
};
/**
* Returns the file names of all existing files owned by the user.
* @method getFileNameArray
......@@ -104,14 +120,7 @@ var jio_storage_loader = function ( LocalOrCookieStorage, Base64, Jio, $) {
*/
that.checkNameAvailability = function () {
setTimeout(function () {
var i, l, array = priv.getUserArray();
for (i = 0, l = array.length; i < l; i+= 1) {
if (array[i] === that.getUserName()) {
that.done(false);
return;
}
}
that.done(true);
that.done(!priv.userExists(that.getUserName()));
}, 100);
}; // end checkNameAvailability
......@@ -138,6 +147,9 @@ var jio_storage_loader = function ( LocalOrCookieStorage, Base64, Jio, $) {
'creationDate': Date.now(),
'lastModified': Date.now()
};
if (!priv.userExists()){
priv.addUser (that.getStorageUserName());
}
priv.addFileName(that.getFileName());
} else {
// overwriting
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment