add a basic login system
This commit is contained in:
parent
7842ad5d3d
commit
0b3a04dc6c
|
@ -15,6 +15,7 @@
|
||||||
<script type="text/javascript" src="/js/rpc.js"></script>
|
<script type="text/javascript" src="/js/rpc.js"></script>
|
||||||
<script type="text/javascript" src="/gettext.js"></script>
|
<script type="text/javascript" src="/gettext.js"></script>
|
||||||
<script type="text/javascript" src="/js/deluge.js"></script>
|
<script type="text/javascript" src="/js/deluge.js"></script>
|
||||||
|
<script type="text/javascript" src="/js/deluge-login.js"></script>
|
||||||
<script type="text/javascript" src="/js/deluge-menus.js"></script>
|
<script type="text/javascript" src="/js/deluge-menus.js"></script>
|
||||||
<script type="text/javascript" src="/js/deluge-bars.js"></script>
|
<script type="text/javascript" src="/js/deluge-bars.js"></script>
|
||||||
<script type="text/javascript" src="/js/deluge-torrents.js"></script>
|
<script type="text/javascript" src="/js/deluge-torrents.js"></script>
|
||||||
|
|
|
@ -118,7 +118,7 @@ Deluge.SideBar = {
|
||||||
|
|
||||||
Deluge.StatusBar = new Ext.StatusBar({
|
Deluge.StatusBar = new Ext.StatusBar({
|
||||||
statusAlign: 'left',
|
statusAlign: 'left',
|
||||||
items: [{
|
/*items: [{
|
||||||
id: 'statusbar-connections',
|
id: 'statusbar-connections',
|
||||||
text: '200 (200)',
|
text: '200 (200)',
|
||||||
cls: 'x-btn-text-icon',
|
cls: 'x-btn-text-icon',
|
||||||
|
@ -146,5 +146,5 @@ Deluge.StatusBar = new Ext.StatusBar({
|
||||||
text: '161',
|
text: '161',
|
||||||
cls: 'x-btn-text-icon',
|
cls: 'x-btn-text-icon',
|
||||||
icon: '/icons/16/dht.png'
|
icon: '/icons/16/dht.png'
|
||||||
}]
|
}]*/
|
||||||
});
|
});
|
|
@ -0,0 +1,44 @@
|
||||||
|
Deluge.Login = {
|
||||||
|
Form: new Ext.form.FormPanel({
|
||||||
|
defaultType: 'textfield',
|
||||||
|
id: 'loginForm',
|
||||||
|
baseCls: 'x-plain',
|
||||||
|
labelWidth: 55,
|
||||||
|
items: [{
|
||||||
|
fieldLabel: 'Password',
|
||||||
|
id: 'password',
|
||||||
|
name: 'password',
|
||||||
|
inputType: 'password',
|
||||||
|
anchor: '100%'
|
||||||
|
}]
|
||||||
|
}),
|
||||||
|
|
||||||
|
onLogin: function() {
|
||||||
|
var passwordField = Deluge.Login.Form.items.get('password');
|
||||||
|
Deluge.Client.web.login(passwordField.getValue(), {
|
||||||
|
onSuccess: function(result) {
|
||||||
|
if (result == true) {
|
||||||
|
Deluge.Login.Window.hide();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Deluge.Login.Window = new Ext.Window({
|
||||||
|
layout: 'fit',
|
||||||
|
width: 300,
|
||||||
|
height: 150,
|
||||||
|
bodyStyle: 'padding: 10px 5px;',
|
||||||
|
buttonAlign: 'center',
|
||||||
|
closeAction: 'hide',
|
||||||
|
closable: false,
|
||||||
|
modal: true,
|
||||||
|
plain: true,
|
||||||
|
title: 'Login',
|
||||||
|
items: Deluge.Login.Form,
|
||||||
|
buttons: [{
|
||||||
|
text: 'Login',
|
||||||
|
handler: Deluge.Login.onLogin
|
||||||
|
}]
|
||||||
|
});
|
|
@ -1,9 +1,7 @@
|
||||||
Deluge.Ui = {
|
Deluge.Ui = {
|
||||||
initialize: function() {
|
initialize: function() {
|
||||||
Deluge.Client = new JSON.RPC('/json');
|
|
||||||
this.errorCount = 0;
|
this.errorCount = 0;
|
||||||
Ext.state.Manager.setProvider(new Ext.state.CookieProvider());
|
Ext.state.Manager.setProvider(new Ext.state.CookieProvider());
|
||||||
|
|
||||||
this.MainPanel = new Ext.Panel({
|
this.MainPanel = new Ext.Panel({
|
||||||
id: 'mainPanel',
|
id: 'mainPanel',
|
||||||
title: 'Deluge',
|
title: 'Deluge',
|
||||||
|
@ -13,19 +11,22 @@ Deluge.Ui = {
|
||||||
bbar: Deluge.StatusBar
|
bbar: Deluge.StatusBar
|
||||||
});
|
});
|
||||||
|
|
||||||
Deluge.SideBar = this.MainPanel.items.get('sidebar');
|
|
||||||
Deluge.SideBar.on('collapse', function(bar) {
|
|
||||||
|
|
||||||
//alert(JSON.encode($('sidebar').getSize()));
|
|
||||||
});
|
|
||||||
|
|
||||||
this.Viewport = new Ext.Viewport({
|
this.Viewport = new Ext.Viewport({
|
||||||
layout: 'fit',
|
layout: 'fit',
|
||||||
items: [this.MainPanel]
|
items: [this.MainPanel]
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Deluge.Login.Window.show();
|
||||||
|
Deluge.Client = new JSON.RPC('/json');
|
||||||
|
|
||||||
Deluge.Details.Status.items.get("status-details").load({
|
Deluge.Details.Status.items.get("status-details").load({
|
||||||
url: "/render/tab_statistics.html"
|
url: "/render/tab_statistics.html"
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Deluge.SideBar = this.MainPanel.items.get('sidebar');
|
||||||
|
Deluge.SideBar.on('collapse', function(bar) {
|
||||||
|
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
update: function() {
|
update: function() {
|
||||||
|
@ -178,5 +179,4 @@ Deluge.Ui = {
|
||||||
|
|
||||||
document.addEvent('domready', function(e) {
|
document.addEvent('domready', function(e) {
|
||||||
Deluge.Ui.initialize();
|
Deluge.Ui.initialize();
|
||||||
Deluge.Ui.run();
|
|
||||||
});
|
});
|
|
@ -124,7 +124,8 @@ class JSON(resource.Resource):
|
||||||
"web.update_ui": self.update_ui,
|
"web.update_ui": self.update_ui,
|
||||||
"web.download_torrent_from_url": self.download_torrent_from_url,
|
"web.download_torrent_from_url": self.download_torrent_from_url,
|
||||||
"web.get_torrent_info": self.get_torrent_info,
|
"web.get_torrent_info": self.get_torrent_info,
|
||||||
"web.add_torrents": self.add_torrents
|
"web.add_torrents": self.add_torrents,
|
||||||
|
"web.login": self.login
|
||||||
}
|
}
|
||||||
for entry in open(common.get_default_config_dir("auth")):
|
for entry in open(common.get_default_config_dir("auth")):
|
||||||
parts = entry.split(":")
|
parts = entry.split(":")
|
||||||
|
@ -355,7 +356,9 @@ class JSON(resource.Resource):
|
||||||
m = hashlib.md5()
|
m = hashlib.md5()
|
||||||
m.update(config['pwd_salt'])
|
m.update(config['pwd_salt'])
|
||||||
m.update(password)
|
m.update(password)
|
||||||
return (m.digest() == config['pwd_md5'])
|
d = Deferred()
|
||||||
|
d.callback(m.digest() == config['pwd_md5'])
|
||||||
|
return d
|
||||||
|
|
||||||
|
|
||||||
class GetText(resource.Resource):
|
class GetText(resource.Resource):
|
||||||
|
|
Loading…
Reference in New Issue