From 34ceb935094e5c906a934a452a33fcd3a1304cc2 Mon Sep 17 00:00:00 2001 From: Paul de Vries Date: Sun, 3 Jan 2016 22:02:49 +0100 Subject: [PATCH] Initialize loginUser and loginPass with an empty string Clear loginUser and loginPass after a successful login (e.g. the user made a typo) --- .../static/js/app/viewmodels/loginstate.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/octoprint/static/js/app/viewmodels/loginstate.js b/src/octoprint/static/js/app/viewmodels/loginstate.js index 25e126c6..5d071740 100644 --- a/src/octoprint/static/js/app/viewmodels/loginstate.js +++ b/src/octoprint/static/js/app/viewmodels/loginstate.js @@ -2,8 +2,8 @@ $(function() { function LoginStateViewModel() { var self = this; - self.loginUser = ko.observable(); - self.loginPass = ko.observable(); + self.loginUser = ko.observable(""); + self.loginPass = ko.observable(""); self.loginRemember = ko.observable(false); self.loggedIn = ko.observable(false); @@ -79,10 +79,6 @@ $(function() { var password = self.loginPass(); var remember = self.loginRemember(); - self.loginUser(""); - self.loginPass(""); - self.loginRemember(false); - $.ajax({ url: API_BASEURL + "login", type: "POST", @@ -90,6 +86,10 @@ $(function() { success: function(response) { new PNotify({title: gettext("Login successful"), text: _.sprintf(gettext('You are now logged in as "%(username)s"'), {username: response.name}), type: "success"}); self.fromResponse(response); + + self.loginUser(""); + self.loginPass(""); + self.loginRemember(false); }, error: function(jqXHR, textStatus, errorThrown) { new PNotify({title: gettext("Login failed"), text: gettext("User unknown or wrong password"), type: "error"}); @@ -138,4 +138,4 @@ $(function() { [], [] ]); -}); \ No newline at end of file +});