Fix login/logout redirects

This commit is contained in:
calzoneman 2015-02-24 11:08:10 -06:00
parent a0b7bff70c
commit a049a7e2dc
2 changed files with 7 additions and 6 deletions

View File

@ -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;

View File

@ -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