summaryrefslogtreecommitdiffstats
path: root/pyload/web/app/scripts/models/UserSession.js
diff options
context:
space:
mode:
Diffstat (limited to 'pyload/web/app/scripts/models/UserSession.js')
-rw-r--r--pyload/web/app/scripts/models/UserSession.js28
1 files changed, 23 insertions, 5 deletions
diff --git a/pyload/web/app/scripts/models/UserSession.js b/pyload/web/app/scripts/models/UserSession.js
index a7e9aa848..7bf6abd8f 100644
--- a/pyload/web/app/scripts/models/UserSession.js
+++ b/pyload/web/app/scripts/models/UserSession.js
@@ -1,20 +1,38 @@
-define(['jquery', 'backbone', 'underscore', 'utils/apitypes', 'cookie'],
- function($, Backbone, _, Api) {
+define(['jquery', 'backbone', 'underscore', 'utils/apitypes', 'app'],
+ function($, Backbone, _, Api, App) {
'use strict';
+ // Used in app -> can not have a dependency on app
return Backbone.Model.extend({
- idAttribute: 'username',
+ idAttribute: 'name',
defaults: {
- username: null,
+ uid: -1,
+ name: 'User',
permissions: null,
session: null
},
// Model Constructor
initialize: function() {
- this.set('session', $.cookie('beaker.session.id'));
+ this.set(JSON.parse(localStorage.getItem('user')));
+ },
+
+ save: function() {
+ localStorage.setItem('user', JSON.stringify(this.toJSON()));
+ },
+
+ destroy: function() {
+ localStorage.removeItem('user');
+ },
+
+ // TODO
+ fetch: function(options) {
+ options = App.apiRequest('todo', null, options);
+
+ return Backbone.Model.prototype.fetch.call(this, options);
}
+
});
}); \ No newline at end of file