diff --git a/api/router_static.go b/api/router_static.go index 62958b3..80c160b 100644 --- a/api/router_static.go +++ b/api/router_static.go @@ -63,6 +63,8 @@ func initStaticRouter(router *mux.Router) error { pages := []string{ "login", + "forgot", + "reset-password", "signup", "dashboard", "logout", diff --git a/frontend/Makefile b/frontend/Makefile index f3b0da0..909491d 100644 --- a/frontend/Makefile +++ b/frontend/Makefile @@ -1,13 +1,15 @@ SHELL = bash # list of JS files to be built -JS_BUILD = jquery.js vue.js highlight.js chartist.js login.js signup.js dashboard.js logout.js commento.js +JS_BUILD = jquery.js vue.js highlight.js chartist.js login.js forgot.js reset.js signup.js dashboard.js logout.js commento.js jquery.js = jquery.js vue.js = vue.js highlight.js = highlight.js chartist.js = chartist.js login.js = utils.js http.js auth-common.js login.js +forgot.js = utils.js http.js forgot.js +reset.js = utils.js http.js reset.js signup.js = utils.js http.js auth-common.js signup.js dashboard.js = utils.js http.js errors.js self.js dashboard.js dashboard-setting.js dashboard-domain.js dashboard-installation.js dashboard-general.js dashboard-moderation.js dashboard-statistics.js dashboard-import.js dashboard-danger.js logout.js = utils.js logout.js diff --git a/frontend/forgot.html b/frontend/forgot.html new file mode 100644 index 0000000..4c2d168 --- /dev/null +++ b/frontend/forgot.html @@ -0,0 +1,54 @@ + + + + + + + + Commento: Reset your Password + + + + +
+
+
+ Reset your Password +
+
+
Email Address
+ +
+
+
+ +
+
+ + + diff --git a/frontend/js/forgot.js b/frontend/js/forgot.js new file mode 100644 index 0000000..d1d872c --- /dev/null +++ b/frontend/js/forgot.js @@ -0,0 +1,33 @@ +(function (global, document) { + + // Talks to the API and sends an reset email. + global.sendResetHex = function() { + var all_ok = global.unfilledMark(["#email"], function(el) { + el.css("border-bottom", "1px solid red"); + }); + + if (!all_ok) { + global.textSet("#err", "Please make sure all fields are filled."); + return; + } + + var json = { + "email": $("#email").val(), + }; + + global.buttonDisable("#reset-button"); + global.post(global.commento_origin + "/api/owner/send-reset-hex", json, function(resp) { + global.buttonEnable("#reset-button"); + + global.textSet("#err", ""); + if (!resp.success) { + global.textSet("#err", resp.message); + return + } + + $("#msg").html("If that email is a registered account, you will receive an email with instructions on how to reset your password."); + $("#reset-button").hide(); + }); + } + +} (window, document)); diff --git a/frontend/js/reset.js b/frontend/js/reset.js new file mode 100644 index 0000000..241ce41 --- /dev/null +++ b/frontend/js/reset.js @@ -0,0 +1,37 @@ +(function (global, document) { + + global.resetPassword = function() { + var all_ok = global.unfilledMark(["#password", "#password2"], function(el) { + el.css("border-bottom", "1px solid red"); + }); + + if (!all_ok) { + global.textSet("#err", "Please make sure all fields are filled."); + return; + } + + if ($("#password").val() != $("#password2").val()) { + global.textSet("#err", "The two passwords do not match."); + return; + } + + var json = { + "resetHex": paramGet("hex"), + "password": $("#password").val(), + }; + + global.buttonDisable("#reset-button"); + global.post(global.commento_origin + "/api/owner/reset-password", json, function(resp) { + global.buttonEnable("#reset-button"); + + global.textSet("#err", ""); + if (!resp.success) { + global.textSet("#err", resp.message); + return + } + + document.location = "/login?changed=true"; + }); + } + +} (window, document)); diff --git a/frontend/login.html b/frontend/login.html index 795702d..67fc012 100644 --- a/frontend/login.html +++ b/frontend/login.html @@ -42,7 +42,7 @@ - Trouble logging in? Reset your password. + Trouble logging in? Reset your password. Don't have an account yet? Sign up. diff --git a/frontend/reset-password.html b/frontend/reset-password.html new file mode 100644 index 0000000..58a4b47 --- /dev/null +++ b/frontend/reset-password.html @@ -0,0 +1,62 @@ + + + + + + + + Commento: Reset your Password + + + + +
+
+
+ Reset your Password +
+ +
+
New Password
+ +
+ +
+
Confirm Password
+ +
+ +
+
+ + Suddenly remembered your password? Login. +
+
+ + +