From a049a7e2dc37fb4e2a1b9b8ffeee44a9443c10d4 Mon Sep 17 00:00:00 2001 From: calzoneman Date: Tue, 24 Feb 2015 11:08:10 -0600 Subject: [PATCH] Fix login/logout redirects --- lib/web/jade.js | 3 ++- templates/nav.jade | 10 +++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/lib/web/jade.js b/lib/web/jade.js index f7a96b8a..a15a6425 100644 --- a/lib/web/jade.js +++ b/lib/web/jade.js @@ -15,7 +15,8 @@ function merge(locals, res) { siteAuthor: "Calvin 'calzoneman' 'cyzon' Montgomery", loginDomain: Config.get("https.enabled") ? Config.get("https.full-address") : Config.get("http.full-address"), - csrfToken: res.req.csrfToken() + csrfToken: res.req.csrfToken(), + baseUrl: res.req.protocol + "://" + res.req.header("host") }; if (typeof locals !== "object") { return _locals; diff --git a/templates/nav.jade b/templates/nav.jade index e8510ddc..5fbc2607 100644 --- a/templates/nav.jade +++ b/templates/nav.jade @@ -27,13 +27,13 @@ mixin navdefaultlinks(page) b.caret ul.dropdown-menu if loggedIn - li: a(href="/logout?dest=#{page}") Logout + li: a(href="/logout?dest=#{encodeURIComponent(baseUrl + page)}") Logout li.divider li: a(href="/account/channels") Channels li: a(href="/account/profile") Profile li: a(href="/account/edit") Change Password/Email else - li: a(href="/login?dest=#{page}") Login + li: a(href="/login?dest=#{encodeURIComponent(baseUrl + page)}") Login li: a(href="/register") Register mixin navloginlogout(redirect) @@ -48,7 +48,7 @@ mixin navloginform(redirect) .visible-lg form#loginform.navbar-form.navbar-right(action="#{loginDomain}/login", method="post") input(type="hidden", name="_csrf", value=csrfToken) - input(type="hidden", name="dest", value=redirect) + input(type="hidden", name="dest", value=baseUrl + redirect) .form-group input#username.form-control(type="text", name="name", placeholder="Username") .form-group @@ -61,7 +61,7 @@ mixin navloginform(redirect) button#login.btn.btn-default(type="submit") Login .visible-md p#loginform.navbar-text.pull-right - a#login.navbar-link(href="#{loginDomain}/login?dest=#{encodeURIComponent(redirect)}") Log in + a#login.navbar-link(href="#{loginDomain}/login?dest=#{encodeURIComponent(baseUrl + redirect)}") Log in span  ·  a#register.navbar-link(href="/register") Register @@ -70,4 +70,4 @@ mixin navlogoutform(redirect) p#logoutform.navbar-text.pull-right span#welcome Welcome, #{loginName} span  ·  - a#logout.navbar-link(href="/logout?dest=#{encodeURIComponent(redirect)}&_csrf=#{csrfToken}") Logout + a#logout.navbar-link(href="/logout?dest=#{encodeURIComponent(baseUrl + redirect)}&_csrf=#{csrfToken}") Logout