Looking for general feedback on this module. remember
is property that a user sets via clicking "remember me" when logging in.
A token identifies the user - h_token. If localStorage.h_token
is set, it is assumed the user has clicked remember me, this is checked at load time.
When the remember state is changed manually by the user setRemember()
is called.
Not looking for advice on any security issues or naming conventions at the moment it is not a concern.
Just general things.
/*SClientStorage
**
**
**
*/
SStorage = NS.support({
Name: 'Storage',
hold: {},
clientStorage: localStorage.h_token ? localStorage : sessionStorage,
setRemember: function (remember) {
this.clientStorage = remember ? localStorage : sessionStorage
},
clear: function () {
this.clientStorage.clear();
},
setAll: function (o) {
var key;
for (key in o) {
if (o.hasOwnProperty(key)) {
this.clientStorage[key] = o[key];
}
}
},
getAll: function () {
var o = {},
key;
for (key in this.clientStorage) {
if (this.clientStorage.hasOwnProperty(key)) {
o[key] = this.clientStorage[key];
}
}
return o;
},
set: function (key, value) {
this.clientStorage[key] = value;
},
get: function (key) {
return this.clientStorage[key];
}
});