Merge branch 'master' of gitssh.handmade.network:hmn/hmn
This commit is contained in:
commit
77273cdb33
|
@ -63,7 +63,7 @@ func TestLoginPage(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestLogoutAction(t *testing.T) {
|
func TestLogoutAction(t *testing.T) {
|
||||||
AssertRegexMatch(t, BuildLogoutAction(), RegexLogoutAction, nil)
|
AssertRegexMatch(t, BuildLogoutAction(""), RegexLogoutAction, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestRegister(t *testing.T) {
|
func TestRegister(t *testing.T) {
|
||||||
|
|
|
@ -66,9 +66,12 @@ func BuildLoginPage(redirectTo string) string {
|
||||||
|
|
||||||
var RegexLogoutAction = regexp.MustCompile("^/logout$")
|
var RegexLogoutAction = regexp.MustCompile("^/logout$")
|
||||||
|
|
||||||
func BuildLogoutAction() string {
|
func BuildLogoutAction(redir string) string {
|
||||||
defer CatchPanic()
|
defer CatchPanic()
|
||||||
return Url("/logout", nil)
|
if redir == "" {
|
||||||
|
redir = "/"
|
||||||
|
}
|
||||||
|
return Url("/logout", []Q{{"redirect", redir}})
|
||||||
}
|
}
|
||||||
|
|
||||||
var RegexRegister = regexp.MustCompile("^/_register$")
|
var RegexRegister = regexp.MustCompile("^/_register$")
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
<a class="admin-panel" href="{{ .Header.AdminUrl }}"><span class="icon-settings"> Admin</span></a>
|
<a class="admin-panel" href="{{ .Header.AdminUrl }}"><span class="icon-settings"> Admin</span></a>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
<a class="username settings" href="{{ .Header.UserSettingsUrl }}"><span class="icon-settings"></span> {{ .User.Username }}</a>
|
<a class="username settings" href="{{ .Header.UserSettingsUrl }}"><span class="icon-settings"></span> {{ .User.Username }}</a>
|
||||||
<a class="logout" href="{{ .Header.LogoutActionUrl }}"><span class="icon-logout"></span> Logout</a>
|
<a class="logout" href="{{ .Header.LogoutActionUrl }}"><span class="icon-logout"></span> Log Out</a>
|
||||||
{{ else }}
|
{{ else }}
|
||||||
<a class="register" id="register-link" href="{{ .Header.RegisterUrl }}">Register</a>
|
<a class="register" id="register-link" href="{{ .Header.RegisterUrl }}">Register</a>
|
||||||
<a class="login" id="login-link" href="{{ .LoginPageUrl }}">Log in</a>
|
<a class="login" id="login-link" href="{{ .LoginPageUrl }}">Log in</a>
|
||||||
|
@ -23,6 +23,7 @@
|
||||||
</tr>
|
</tr>
|
||||||
{{/* TODO: Forgot password flow? Or just on standalone page? */}}
|
{{/* TODO: Forgot password flow? Or just on standalone page? */}}
|
||||||
</table>
|
</table>
|
||||||
|
<input type="hidden" name="redirect" value="{{ $.CurrentUrl }}">
|
||||||
<div class="actionbar pt2">
|
<div class="actionbar pt2">
|
||||||
<input type="submit" value="Log In" />
|
<input type="submit" value="Log In" />
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -14,6 +14,7 @@ type BaseData struct {
|
||||||
BodyClasses []string
|
BodyClasses []string
|
||||||
Breadcrumbs []Breadcrumb
|
Breadcrumbs []Breadcrumb
|
||||||
|
|
||||||
|
CurrentUrl string
|
||||||
LoginPageUrl string
|
LoginPageUrl string
|
||||||
ProjectCSSUrl string
|
ProjectCSSUrl string
|
||||||
|
|
||||||
|
|
|
@ -91,7 +91,12 @@ func Logout(c *RequestContext) ResponseData {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
res := c.Redirect("/", http.StatusSeeOther) // TODO: Redirect to the page the user was currently on, or if not authorized to view that page, immediately to the home page.
|
redir := c.Req.URL.Query().Get("redirect")
|
||||||
|
if redir == "" {
|
||||||
|
redir = "/"
|
||||||
|
}
|
||||||
|
|
||||||
|
res := c.Redirect(redir, http.StatusSeeOther)
|
||||||
res.SetCookie(auth.DeleteSessionCookie)
|
res.SetCookie(auth.DeleteSessionCookie)
|
||||||
|
|
||||||
return res
|
return res
|
||||||
|
|
|
@ -135,17 +135,21 @@ func getBaseData(c *RequestContext) templates.BaseData {
|
||||||
}
|
}
|
||||||
|
|
||||||
return templates.BaseData{
|
return templates.BaseData{
|
||||||
Project: templates.ProjectToTemplate(c.CurrentProject, c.Theme),
|
Theme: c.Theme,
|
||||||
|
|
||||||
|
CurrentUrl: c.FullUrl(),
|
||||||
LoginPageUrl: hmnurl.BuildLoginPage(c.FullUrl()),
|
LoginPageUrl: hmnurl.BuildLoginPage(c.FullUrl()),
|
||||||
User: templateUser,
|
|
||||||
Theme: c.Theme,
|
|
||||||
ProjectCSSUrl: hmnurl.BuildProjectCSS(c.CurrentProject.Color1),
|
ProjectCSSUrl: hmnurl.BuildProjectCSS(c.CurrentProject.Color1),
|
||||||
|
|
||||||
|
Project: templates.ProjectToTemplate(c.CurrentProject, c.Theme),
|
||||||
|
User: templateUser,
|
||||||
|
|
||||||
IsProjectPage: !c.CurrentProject.IsHMN(),
|
IsProjectPage: !c.CurrentProject.IsHMN(),
|
||||||
Header: templates.Header{
|
Header: templates.Header{
|
||||||
AdminUrl: hmnurl.BuildHomepage(), // TODO(asaf)
|
AdminUrl: hmnurl.BuildHomepage(), // TODO(asaf)
|
||||||
UserSettingsUrl: hmnurl.BuildHomepage(), // TODO(asaf)
|
UserSettingsUrl: hmnurl.BuildHomepage(), // TODO(asaf)
|
||||||
LoginActionUrl: hmnurl.BuildLoginAction(c.FullUrl()),
|
LoginActionUrl: hmnurl.BuildLoginAction(c.FullUrl()),
|
||||||
LogoutActionUrl: hmnurl.BuildLogoutAction(),
|
LogoutActionUrl: hmnurl.BuildLogoutAction(c.FullUrl()),
|
||||||
RegisterUrl: hmnurl.BuildHomepage(), // TODO(asaf)
|
RegisterUrl: hmnurl.BuildHomepage(), // TODO(asaf)
|
||||||
HMNHomepageUrl: hmnurl.BuildHomepage(),
|
HMNHomepageUrl: hmnurl.BuildHomepage(),
|
||||||
ProjectHomepageUrl: hmnurl.BuildProjectHomepage(c.CurrentProject.Slug),
|
ProjectHomepageUrl: hmnurl.BuildProjectHomepage(c.CurrentProject.Slug),
|
||||||
|
|
Loading…
Reference in New Issue