From 3a483b32e8df1a0f0351c0b9e028b31762b97a32 Mon Sep 17 00:00:00 2001 From: Nijil Y Date: Thu, 13 Oct 2011 15:11:23 +0530 Subject: [PATCH 1/2] Remove extra popup message in login validation --- py/core/page/login_page/login_page.js | 7 ++++--- py/webnotes/auth.py | 10 +++++++--- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/py/core/page/login_page/login_page.js b/py/core/page/login_page/login_page.js index ac8dfd573b..cfd8b72092 100644 --- a/py/core/page/login_page/login_page.js +++ b/py/core/page/login_page/login_page.js @@ -17,8 +17,9 @@ pscript.onLoginReply = function(r, rtext) { pscript.login_btn.done_working(); if(r.message=="Logged In"){ window.location.href='index.html' + (get_url_arg('page') ? ('?page='+get_url_arg('page')) : ''); - } else { - $i('login_message').innerHTML = ''+eval(r.message)+''; + } else{ + + $i('login_message').innerHTML = ''+r.message+''; //if(r.exc)alert(r.exc); } } @@ -53,4 +54,4 @@ pscript.show_forgot_password = function(){ } d.show(); pscript.forgot_dialog = d; -} \ No newline at end of file +} diff --git a/py/webnotes/auth.py b/py/webnotes/auth.py index 6858151560..a853c177b4 100644 --- a/py/webnotes/auth.py +++ b/py/webnotes/auth.py @@ -139,8 +139,10 @@ class LoginManager: user, pwd = webnotes.form_dict.get('usr'), webnotes.form_dict.get('pwd') if not (user and pwd): - webnotes.msgprint('Incomplete Login Details', raise_exception=1) - + webnotes.response['message'] = 'Incomplete Login Details' + raise ValidationError + #webnotes.msgprint('Incomplete Login Details', raise_exception=1) + # custom authentication (for single-sign on) self.load_control_panel() if hasattr(self.cp, 'authenticate'): @@ -153,7 +155,9 @@ class LoginManager: p = webnotes.conn.sql("select name from tabProfile where name=%s and (`password`=%s OR `password`=PASSWORD(%s)) and IFNULL(enabled,0)=1", (user, pwd, pwd)) if not p: - webnotes.msgprint('Authentication Failed', raise_exception=1) + webnotes.response['message'] = 'Authentication Failed' + raise ValidationError + #webnotes.msgprint('Authentication Failed',raise_exception=1) self.user = p[0][0] From 160155f6c48c6d00f75675d47ca583b63e1c6008 Mon Sep 17 00:00:00 2001 From: Nijil Y Date: Thu, 15 Dec 2011 14:44:47 +0530 Subject: [PATCH 2/2] login popup changed tologin messages --- py/core/page/login_page/login_page.js | 4 ++-- py/webnotes/auth.py | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/py/core/page/login_page/login_page.js b/py/core/page/login_page/login_page.js index ac8dfd573b..7ca5aab426 100644 --- a/py/core/page/login_page/login_page.js +++ b/py/core/page/login_page/login_page.js @@ -18,7 +18,7 @@ pscript.onLoginReply = function(r, rtext) { if(r.message=="Logged In"){ window.location.href='index.html' + (get_url_arg('page') ? ('?page='+get_url_arg('page')) : ''); } else { - $i('login_message').innerHTML = ''+eval(r.message)+''; + $i('login_message').innerHTML = ''+(r.message)+''; //if(r.exc)alert(r.exc); } } @@ -53,4 +53,4 @@ pscript.show_forgot_password = function(){ } d.show(); pscript.forgot_dialog = d; -} \ No newline at end of file +} diff --git a/py/webnotes/auth.py b/py/webnotes/auth.py index 6858151560..2cb03df438 100644 --- a/py/webnotes/auth.py +++ b/py/webnotes/auth.py @@ -137,10 +137,9 @@ class LoginManager: def authenticate(self, user=None, pwd=None): if not (user and pwd): user, pwd = webnotes.form_dict.get('usr'), webnotes.form_dict.get('pwd') - if not (user and pwd): - webnotes.msgprint('Incomplete Login Details', raise_exception=1) - + webnotes.response['message'] = 'Incomplete Login Details' + raise Exception # custom authentication (for single-sign on) self.load_control_panel() if hasattr(self.cp, 'authenticate'): @@ -151,9 +150,10 @@ class LoginManager: p = webnotes.conn.sql("select name from tabProfile where name=%s and (`password`=%s OR `password`=PASSWORD(%s))", (user, pwd, pwd)) else: p = webnotes.conn.sql("select name from tabProfile where name=%s and (`password`=%s OR `password`=PASSWORD(%s)) and IFNULL(enabled,0)=1", (user, pwd, pwd)) - if not p: - webnotes.msgprint('Authentication Failed', raise_exception=1) + webnotes.response['message'] = 'Authentication Failed' + raise Exception + #webnotes.msgprint('Authentication Failed',raise_exception=1) self.user = p[0][0]