Changeset e837493
- Timestamp:
- 04/27/2009 01:01:20 PM (16 years ago)
- Branches:
- 2.0.x, develop, extjs4-port, master
- Children:
- 204f055
- Parents:
- c4cdd7
- Location:
- deluge/ui/web
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
deluge/ui/web/js/Deluge.Login.js
rc4cdd7 re837493 24 24 (function(){ 25 25 Ext.deluge.LoginWindow = Ext.extend(Ext.Window, { 26 27 firstShow: true, 28 26 29 constructor: function(config) { 27 30 config = Ext.apply({ … … 46 49 Deluge.Events.on('logout', this.onLogout, this); 47 50 this.on('show', this.onShow, this); 51 this.on('beforeshow', this.onBeforeShow, this); 48 52 49 53 this.addButton({ … … 83 87 Deluge.Client.web.login(passwordField.getValue(), { 84 88 success: function(result) { 85 if (result == true) {89 if (result) { 86 90 Deluge.Events.fire('login'); 87 91 this.hide(); 88 92 passwordField.setRawValue(''); 93 Deluge.UI.cookies.set("session", result); 89 94 } else { 90 95 Ext.MessageBox.show({ … … 106 111 107 112 onLogout: function() { 108 this.show(); 113 var session = Deluge.UI.cookies.get("session", false); 114 if (session) { 115 Deluge.Client.web.delete_session(session, { 116 success: function(result) { 117 Deluge.UI.cookies.set("session", false); 118 this.show(); 119 }, 120 scope: this 121 }); 122 } 123 }, 124 125 onBeforeShow: function() { 126 var session = Deluge.UI.cookies.get("session", false); 127 if (session) { 128 Deluge.Client.web.check_session(session, { 129 success: function(result) { 130 if (result) { 131 Deluge.Events.fire('login'); 132 this.loginForm.items.get('password').setRawValue(''); 133 this.hide(); 134 } else { 135 Deluge.UI.cookies.set("session", false); 136 this.show(); 137 } 138 }, 139 failure: function(result) { 140 Deluge.UI.cookies.set("session", false); 141 this.show(); 142 }, 143 scope: this 144 }); 145 return false; 146 } 109 147 }, 110 148 -
deluge/ui/web/js/Deluge.UI.js
rc4cdd7 re837493 50 50 }); 51 51 52 Deluge.Login.show();53 54 52 Deluge.Events.on("connect", this.onConnect, this); 55 53 Deluge.Events.on("disconnect", this.onDisconnect, this); 56 Deluge.Client = new Ext.ux.util.RpcClient({url: '/json'}); 54 Deluge.Client = new Ext.ux.util.RpcClient({ 55 url: '/json' 56 }); 57 Deluge.Client.on('connected', function(e) { 58 Deluge.Login.show(); 59 }); 57 60 this.update = this.update.bind(this); 58 61 }, -
deluge/ui/web/json_api.py
rc4cdd7 re837493 26 26 import time 27 27 import base64 28 import random 28 29 import urllib 29 30 import hashlib … … 428 429 return d 429 430 431 def _create_session(self, login='admin'): 432 m = hashlib.md5() 433 m.update(login) 434 m.update(str(time.time())) 435 m.update(str(random.getrandbits(999))) 436 m.update(m.hexdigest()) 437 session_id = m.hexdigest() 438 439 config = component.get("DelugeWeb").config 440 config["sessions"][session_id] = { 441 "login": login 442 } 443 return session_id 444 445 @export 446 def check_session(self, session_id): 447 d = Deferred() 448 config = component.get("DelugeWeb").config 449 d.callback(session_id in config["sessions"]) 450 return d 451 452 @export 453 def delete_session(self, session_id): 454 d = Deferred() 455 config = component.get("DelugeWeb").config 456 del config["sessions"][session_id] 457 d.callback(True) 458 return d 459 430 460 @export 431 461 def login(self, password): … … 437 467 m.update(password) 438 468 d = Deferred() 439 d.callback(m.hexdigest() == config['pwd_md5']) 469 if m.hexdigest() == config['pwd_md5']: 470 # Change this to return a session id 471 d.callback(self._create_session()) 472 else: 473 d.callback(False) 440 474 return d 441 475 -
deluge/ui/web/server.py
rc4cdd7 re837493 27 27 import locale 28 28 import shutil 29 import signal 29 30 import urllib 30 31 import gettext … … 72 73 "pwd_md5": "2c9baa929ca38fb5c9eb5b054474d1ce", 73 74 "base": "", 74 "sessions": [],75 "sessions": {}, 75 76 "sidebar_show_zero": False, 76 77 "sidebar_show_trackers": False,
Note:
See TracChangeset
for help on using the changeset viewer.