fix to login

This commit is contained in:
Rushabh Mehta 2013-03-19 14:35:20 +05:30
parent fd18fc7986
commit 1755b36ba3
2 changed files with 19 additions and 26 deletions

View File

@ -37,7 +37,7 @@ erpnext.send_message = function(opts) {
$(document).ready(function() { $(document).ready(function() {
// update login // update login
var full_name = getCookie("full_name"); var full_name = getCookie("full_name");
if(full_name.substr(0,1)=='"') { if(full_name && full_name.substr(0,1)=='"') {
full_name = full_name.substr(1, full_name.length-2); full_name = full_name.substr(1, full_name.length-2);
} }
if(full_name) { if(full_name) {

View File

@ -17,7 +17,6 @@ $(document).ready(function(wrapper) {
// Login // Login
login.do_login = function(){ login.do_login = function(){
var args = {}; var args = {};
if(window.is_sign_up) { if(window.is_sign_up) {
args.cmd = "core.doctype.profile.profile.sign_up"; args.cmd = "core.doctype.profile.profile.sign_up";
@ -28,6 +27,14 @@ login.do_login = function(){
login.set_message("Valid email and name required."); login.set_message("Valid email and name required.");
return false; return false;
} }
} else if(window.is_forgot) {
args.cmd = "reset_password";
args.user = $("#login_id").val();
if(!args.user) {
login.set_message("Valid Login Id required.");
return false;
}
} else { } else {
args.cmd = "login" args.cmd = "login"
@ -50,6 +57,7 @@ login.do_login = function(){
data: args, data: args,
dataType: "json", dataType: "json",
success: function(data) { success: function(data) {
$("input").val("");
$("#login-spinner").toggle(false); $("#login-spinner").toggle(false);
$('#login_btn').attr("disabled", false); $('#login_btn').attr("disabled", false);
if(data.message=="Logged In") { if(data.message=="Logged In") {
@ -68,35 +76,20 @@ login.do_login = function(){
login.sign_up = function() { login.sign_up = function() {
$("#login_wrapper h3").html("Sign Up"); $("#login_wrapper h3").html("Sign Up");
$("#login-label").html("Email Id"); $("#login-label").html("Email Id");
$("#password-label").html("Full Name"); $("#password-row, #sign-up-wrapper, #login_message").toggle(false);
$("#password-row, #forgot-wrapper, #sign-up-wrapper, #login_message").toggle(false);
$("#full-name-row").toggle(true); $("#full-name-row").toggle(true);
$("#login_btn").html("Register"); $("#login_btn").html("Register");
$("#forgot-wrapper").html("<a onclick='location.reload()' href='#'>Login</a>")
window.is_sign_up = true; window.is_sign_up = true;
} }
login.show_forgot_password = function(){ login.show_forgot_password = function() {
// create dialog $("#login_wrapper h3").html("Forgot");
var login_id = $("#login_id").val(); $("#login-label").html("Email Id");
if(!login_id || !valid_email(login_id)) { $("#password-row, #sign-up-wrapper, #login_message").toggle(false);
login.set_message("Please set your login id (which is your email where the password will be sent);"); $("#login_btn").html("Send Password");
return; $("#forgot-wrapper").html("<a onclick='location.reload()' href='#'>Login</a>")
} window.is_forgot = true;
login.set_message("Sending email with new password...");
$("#forgot-password").remove();
$.ajax({
method: "POST",
url: "server.py",
data: {
cmd: "reset_password",
user: login_id,
_type: "POST"
},
success: function(data) {
login.set_message("A new password has been sent to your email id.", "GREEN");
}
})
} }
login.set_message = function(message, color) { login.set_message = function(message, color) {