From 91ba3463543b5085347118d69723b232847602a2 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Fri, 13 Jul 2012 14:54:40 +0530 Subject: [PATCH] profile cleanup start and new auth table for better security --- erpnext/patches/patch_list.py | 4 ++++ erpnext/startup/event_handlers.py | 3 ++- erpnext/utilities/page/users/users.py | 8 +++++-- erpnext/website/templates/js/login.js | 1 + public/js/all-app.js | 33 ++++++++++++++------------- public/js/all-web.js | 2 +- public/js/fields.js | 7 +++--- 7 files changed, 35 insertions(+), 23 deletions(-) diff --git a/erpnext/patches/patch_list.py b/erpnext/patches/patch_list.py index 32e1a6ef6e..2392fd5a65 100644 --- a/erpnext/patches/patch_list.py +++ b/erpnext/patches/patch_list.py @@ -496,4 +496,8 @@ patch_list = [ 'patch_file': 'cms2', 'description': 'cms2 release patches' }, + { 'patch_module': 'patches.july_2012', + 'patch_file': 'auth_table', + 'description': 'create new __Auth table' + }, ] \ No newline at end of file diff --git a/erpnext/startup/event_handlers.py b/erpnext/startup/event_handlers.py index 0c5eae1892..d05b2ec8d3 100644 --- a/erpnext/startup/event_handlers.py +++ b/erpnext/startup/event_handlers.py @@ -40,8 +40,9 @@ def on_login_post_session(login_manager): if webnotes.session['user'] not in ('Guest', 'demo@webnotestech.com'): # create feed from webnotes.utils import nowtime + from webnotes.profile import get_user_fullname home.make_feed('Login', 'Profile', login_manager.user, login_manager.user, - '%s logged in at %s' % (login_manager.user_fullname, nowtime()), + '%s logged in at %s' % (get_user_fullname, nowtime()), login_manager.user=='Administrator' and '#8CA2B3' or '#1B750D') diff --git a/erpnext/utilities/page/users/users.py b/erpnext/utilities/page/users/users.py index 07504a8077..336282bace 100644 --- a/erpnext/utilities/page/users/users.py +++ b/erpnext/utilities/page/users/users.py @@ -30,9 +30,13 @@ def get(arg=None): @webnotes.whitelist() def get_roles(arg=None): - """return all roles""" + """return all roles except standard""" + return _get_roles(webnotes.form_dict['uid']) + +def _get_roles(user): + """return all roles except standard""" return [r[0] for r in webnotes.conn.sql("""select name from tabRole - where name not in ('Administrator', 'Guest', 'All') order by name""")] + where name not in ('Administrator', 'Guest', 'All') order by name""", user)] @webnotes.whitelist() def get_user_roles(arg=None): diff --git a/erpnext/website/templates/js/login.js b/erpnext/website/templates/js/login.js index 29e49226fc..4ca18c9452 100644 --- a/erpnext/website/templates/js/login.js +++ b/erpnext/website/templates/js/login.js @@ -59,6 +59,7 @@ erpnext.login.doLogin = function(){ args['remember_me'] = 1; $('#login_btn').set_working(); + $('#login_message').empty(); $c("login", args, erpnext.login.onLoginReply); diff --git a/public/js/all-app.js b/public/js/all-app.js index ef3b4e38e4..ee120300fd 100644 --- a/public/js/all-app.js +++ b/public/js/all-app.js @@ -678,7 +678,8 @@ this.set_input(_f.get_value(this.doctype,this.docname,this.df.fieldname));this.r Field.prototype.refresh_label_icon=function(){if(this.df.reqd){if(this.get_value&&is_null(this.get_value())){if(this.label_icon)$ds(this.label_icon);$(this.txt?this.txt:this.input).addClass('field-to-update')}else{if(this.label_icon)$dh(this.label_icon);$(this.txt?this.txt:this.input).removeClass('field-to-update')}}} Field.prototype.set=function(val){if(this.not_in_form) return;if((!this.docname)&&this.grid){this.docname=this.grid.add_newrow();} -var set_val=val;if(this.validate)set_val=this.validate(val);_f.set_value(this.doctype,this.docname,this.df.fieldname,set_val);this.value=val;} +if(this.validate) +val=this.validate(val);cur_frm.set_value_in_locals(this.doctype,this.docname,this.df.fieldname,val);this.value=val;} Field.prototype.set_input=function(val){this.value=val;if(this.input&&this.input.set_input){if(val==null)this.input.set_input('');else this.input.set_input(val);} var disp_val=val;if(val==null)disp_val='';this.set_disp(disp_val);} Field.prototype.run_trigger=function(){this.refresh_label_icon();if(this.df.reqd&&this.get_value&&!is_null(this.get_value())&&this.set_as_error) @@ -713,9 +714,9 @@ return v;}else{return v;}} DataField.prototype.onrefresh=function(){if(this.input&&this.df.colour){var col='#'+this.df.colour.split(':')[1];$bg(this.input,col);}} function ReadOnlyField(){} ReadOnlyField.prototype=new Field();function HTMLField(){} -HTMLField.prototype=new Field();HTMLField.prototype.with_label=0;HTMLField.prototype.set_disp=function(val){this.disp_area.innerHTML=val;} +HTMLField.prototype=new Field();HTMLField.prototype.with_label=0;HTMLField.prototype.set_disp=function(val){if(this.disp_area)this.disp_area.innerHTML=val;} HTMLField.prototype.set_input=function(val){if(val)this.set_disp(val);} -HTMLField.prototype.onrefresh=function(){this.set_disp(this.df.options?this.df.options:'');} +HTMLField.prototype.onrefresh=function(){if(this.df.options)this.set_disp(this.df.options);} var datepicker_active=0;function DateField(){}DateField.prototype=new Field();DateField.prototype.make_input=function(){var me=this;this.user_fmt=wn.control_panel.date_format;if(!this.user_fmt)this.user_fmt='dd-mm-yy';this.input=$a(this.input_area,'input');$(this.input).datepicker({dateFormat:me.user_fmt.replace('yyyy','yy'),altFormat:'yy-mm-dd',changeYear:true,beforeShow:function(input,inst){datepicker_active=1},onClose:function(dateText,inst){datepicker_active=0;if(_f.cur_grid_cell) _f.cur_grid_cell.grid.cell_deselect();}});var me=this;me.input.onchange=function(){if(this.value==null)this.value='';if(!this.not_in_form) me.set(dateutil.user_to_str(me.input.value));me.run_trigger();} @@ -1359,7 +1360,7 @@ var getchildren=LocalDB.getchildren;var get_field=Meta.get_field;var createLocal /* * lib/js/legacy/model/doclist.js */ -function compress_doclist(list){var kl={};var vl=[];var flx={};for(var i=0;i