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, $) { ...@@ -59,6 +59,22 @@ var jio_storage_loader = function ( LocalOrCookieStorage, Base64, Jio, $) {
userarray); 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. * Returns the file names of all existing files owned by the user.
* @method getFileNameArray * @method getFileNameArray
...@@ -104,14 +120,7 @@ var jio_storage_loader = function ( LocalOrCookieStorage, Base64, Jio, $) { ...@@ -104,14 +120,7 @@ var jio_storage_loader = function ( LocalOrCookieStorage, Base64, Jio, $) {
*/ */
that.checkNameAvailability = function () { that.checkNameAvailability = function () {
setTimeout(function () { setTimeout(function () {
var i, l, array = priv.getUserArray(); that.done(!priv.userExists(that.getUserName()));
for (i = 0, l = array.length; i < l; i+= 1) {
if (array[i] === that.getUserName()) {
that.done(false);
return;
}
}
that.done(true);
}, 100); }, 100);
}; // end checkNameAvailability }; // end checkNameAvailability
...@@ -138,6 +147,9 @@ var jio_storage_loader = function ( LocalOrCookieStorage, Base64, Jio, $) { ...@@ -138,6 +147,9 @@ var jio_storage_loader = function ( LocalOrCookieStorage, Base64, Jio, $) {
'creationDate': Date.now(), 'creationDate': Date.now(),
'lastModified': Date.now() 'lastModified': Date.now()
}; };
if (!priv.userExists()){
priv.addUser (that.getStorageUserName());
}
priv.addFileName(that.getFileName()); priv.addFileName(that.getFileName());
} else { } else {
// overwriting // 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