diff --git a/public/js/website_utils.js b/public/js/website_utils.js
index 7897cd548b..48124df29e 100644
--- a/public/js/website_utils.js
+++ b/public/js/website_utils.js
@@ -37,7 +37,7 @@ erpnext.send_message = function(opts) {
$(document).ready(function() {
// update login
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);
}
if(full_name) {
diff --git a/website/templates/js/login.js b/website/templates/js/login.js
index 09e8e9e611..06ea4c5242 100644
--- a/website/templates/js/login.js
+++ b/website/templates/js/login.js
@@ -17,7 +17,6 @@ $(document).ready(function(wrapper) {
// Login
login.do_login = function(){
-
var args = {};
if(window.is_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.");
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 {
args.cmd = "login"
@@ -50,6 +57,7 @@ login.do_login = function(){
data: args,
dataType: "json",
success: function(data) {
+ $("input").val("");
$("#login-spinner").toggle(false);
$('#login_btn').attr("disabled", false);
if(data.message=="Logged In") {
@@ -68,35 +76,20 @@ login.do_login = function(){
login.sign_up = function() {
$("#login_wrapper h3").html("Sign Up");
$("#login-label").html("Email Id");
- $("#password-label").html("Full Name");
- $("#password-row, #forgot-wrapper, #sign-up-wrapper, #login_message").toggle(false);
+ $("#password-row, #sign-up-wrapper, #login_message").toggle(false);
$("#full-name-row").toggle(true);
$("#login_btn").html("Register");
+ $("#forgot-wrapper").html("Login")
window.is_sign_up = true;
}
-login.show_forgot_password = function(){
- // create dialog
- var login_id = $("#login_id").val();
- if(!login_id || !valid_email(login_id)) {
- login.set_message("Please set your login id (which is your email where the password will be sent);");
- return;
- }
- 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.show_forgot_password = function() {
+ $("#login_wrapper h3").html("Forgot");
+ $("#login-label").html("Email Id");
+ $("#password-row, #sign-up-wrapper, #login_message").toggle(false);
+ $("#login_btn").html("Send Password");
+ $("#forgot-wrapper").html("Login")
+ window.is_forgot = true;
}
login.set_message = function(message, color) {