Permalink
Browse files

Use / for canonical admin URL

  • Loading branch information...
dsamarin committed May 23, 2018
1 parent 4b3ab67 commit 81d389ceb232353326bc3cd676f09dadaf3d582a
Showing with 8 additions and 8 deletions.
  1. +5 −5 admin.go
  2. +1 −1 shot.go
  3. +1 −1 templates/entries.tmpl
  4. +1 −1 templates/new.tmpl
@@ -213,8 +213,7 @@ func NewAdminHandler(app *ZerodropApp) (*AdminHandler, error) {
handler.HandleFunc("/admin/login", handler.ServeLogin)
handler.HandleFunc("/admin/logout", handler.ServeLogout)
handler.HandleFunc("/admin/new", handler.ServeNew)
handler.HandleFunc("/admin/my", handler.ServeList)
handler.HandleFunc("/admin/", handler.ServeList)
handler.HandleFunc("/", handler.ServeList)
return handler, nil
}
@@ -299,6 +298,7 @@ func (a *AdminHandler) setClaims(w http.ResponseWriter, claims *AdminClaims) err
http.SetCookie(w, &http.Cookie{
Name: "jwt",
Value: tokenString,
Path: "/",
Expires: time.Now().Add(365 * 24 * time.Hour), // 1 year
})
@@ -319,7 +319,7 @@ func (a *AdminHandler) ServeLogin(w http.ResponseWriter, r *http.Request) {
// Successful authentication
log.Printf("Successful authentication by %s", ip)
http.Redirect(w, r, "/admin/", 302)
http.Redirect(w, r, "/", 302)
return
}
@@ -339,7 +339,7 @@ func (a *AdminHandler) ServeLogout(w http.ResponseWriter, r *http.Request) {
Value: "",
Expires: time.Unix(0, 0),
})
http.Redirect(w, r, "/admin/", 302)
http.Redirect(w, r, "/", 302)
}
// ServeNew renders the new entry page.
@@ -462,7 +462,7 @@ func (a *AdminHandler) ServeNew(w http.ResponseWriter, r *http.Request) {
redirectPage := a.App.Config.Base + "admin/my"
if claims.Admin {
redirectPage = a.App.Config.Base + "admin/"
redirectPage = a.App.Config.Base
}
http.Redirect(w, r, redirectPage, 302)
return
@@ -152,7 +152,7 @@ func (a *ShotHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
// Get entry
name := strings.Trim(r.URL.Path, "/")
if name == "" {
http.Redirect(w, r, "/admin/", 308)
a.App.AdminHandler.ServeHTTP(w, r)
return
}
@@ -2,7 +2,7 @@
{{template "header" $}}
<ul class="nav nav-pills mb-3">
<li class="nav-item">
<a class="nav-link{{if $.All}} active{{end}}" href="{{$.Config.Base}}admin/">All Entries</a>
<a class="nav-link{{if $.All}} active{{end}}" href="{{$.Config.Base}}">All Entries</a>
</li>
{{if not $.Claims.Admin}}
<li class="nav-item">
@@ -2,7 +2,7 @@
{{- template "header" $ -}}
<ul class="nav nav-pills mb-3">
<li class="nav-item">
<a class="nav-link" href="{{$.Config.Base}}admin/">All Entries</a>
<a class="nav-link" href="{{$.Config.Base}}">All Entries</a>
</li>
{{if not $.Claims.Admin}}
<li class="nav-item">

0 comments on commit 81d389c

Please sign in to comment.