diff options
author | 2013-07-24 17:42:43 +0200 | |
---|---|---|
committer | 2013-07-24 17:42:56 +0200 | |
commit | f0bfb8a13b6b488c561084a4a33acc9b75984b03 (patch) | |
tree | 22ef409a315a5afdb2bb93157dd751f2d61d8a71 /pyload/web/app/scripts/models/UserSession.js | |
parent | DebridItaliaCom: two more hosters supported (diff) | |
download | pyload-f0bfb8a13b6b488c561084a4a33acc9b75984b03.tar.xz |
improved login mechanism
Diffstat (limited to 'pyload/web/app/scripts/models/UserSession.js')
-rw-r--r-- | pyload/web/app/scripts/models/UserSession.js | 28 |
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 |