mirror of https://github.com/jlelse/GoBlog
Login, Logout and show update and delete below posts
This commit is contained in:
parent
243d695bf4
commit
b81f890120
|
@ -157,3 +157,19 @@ func createTokenCookie(username string) (*http.Cookie, error) {
|
||||||
SameSite: http.SameSiteLaxMode,
|
SameSite: http.SameSiteLaxMode,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Need to set auth middleware!
|
||||||
|
func serveLogin(w http.ResponseWriter, r *http.Request) {
|
||||||
|
http.Redirect(w, r, "/", http.StatusFound)
|
||||||
|
}
|
||||||
|
|
||||||
|
func serveLogout(w http.ResponseWriter, r *http.Request) {
|
||||||
|
http.SetCookie(w, &http.Cookie{
|
||||||
|
Name: "token",
|
||||||
|
MaxAge: -1,
|
||||||
|
Secure: httpsConfigured(),
|
||||||
|
HttpOnly: true,
|
||||||
|
SameSite: http.SameSiteLaxMode,
|
||||||
|
})
|
||||||
|
http.Redirect(w, r, "/", http.StatusFound)
|
||||||
|
}
|
||||||
|
|
4
http.go
4
http.go
|
@ -100,6 +100,10 @@ func buildHandler() (http.Handler, error) {
|
||||||
r.Use(checkIsCaptcha)
|
r.Use(checkIsCaptcha)
|
||||||
r.Use(checkLoggedIn)
|
r.Use(checkLoggedIn)
|
||||||
|
|
||||||
|
// Logout
|
||||||
|
r.With(authMiddleware).Get("/login", serveLogin)
|
||||||
|
r.With(authMiddleware).Get("/logout", serveLogout)
|
||||||
|
|
||||||
// Micropub
|
// Micropub
|
||||||
r.Route(micropubPath, func(mpRouter chi.Router) {
|
r.Route(micropubPath, func(mpRouter chi.Router) {
|
||||||
mpRouter.Use(checkIndieAuth)
|
mpRouter.Use(checkIndieAuth)
|
||||||
|
|
|
@ -142,6 +142,10 @@ footer * {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.in {
|
||||||
|
display: inline;
|
||||||
|
}
|
||||||
|
|
||||||
.fw, .fw-form, .fw-form input:not([type]), .fw-form input[type=text], .fw-form input[type=email], .fw-form input[type=url], .fw-form input[type=password], .fw-form textarea {
|
.fw, .fw-form, .fw-form input:not([type]), .fw-form input[type=text], .fw-form input[type=email], .fw-form input[type=url], .fw-form input[type=password], .fw-form textarea {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
|
@ -169,6 +169,10 @@ footer {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.in {
|
||||||
|
display: inline;
|
||||||
|
}
|
||||||
|
|
||||||
.fw {
|
.fw {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
• <a href="/notifications">{{ string .Blog.Lang "notifications" }}</a>
|
• <a href="/notifications">{{ string .Blog.Lang "notifications" }}</a>
|
||||||
• <a href="/webmention">{{ string .Blog.Lang "webmentions" }}</a>
|
• <a href="/webmention">{{ string .Blog.Lang "webmentions" }}</a>
|
||||||
• <a href="{{ blogrelative .Blog "/comment" }}">{{ string .Blog.Lang "comments" }}</a>
|
• <a href="{{ blogrelative .Blog "/comment" }}">{{ string .Blog.Lang "comments" }}</a>
|
||||||
|
• <a href="/logout">{{ string .Blog.Lang "logout" }}</a>
|
||||||
</nav>
|
</nav>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
</header>
|
</header>
|
||||||
|
|
|
@ -27,6 +27,20 @@
|
||||||
</article>
|
</article>
|
||||||
{{ include "author" . }}
|
{{ include "author" . }}
|
||||||
</main>
|
</main>
|
||||||
|
{{ if .LoggedIn }}
|
||||||
|
<div class="p">
|
||||||
|
<form class="in" method="post" action="{{ blogrelative .Blog "/editor" }}">
|
||||||
|
<input type="hidden" name="editoraction" value="loadupdate">
|
||||||
|
<input type="hidden" name="url" value="{{ .Canonical }}">
|
||||||
|
<input type="submit" value="{{ string .Blog.Lang "update" }}">
|
||||||
|
</form>
|
||||||
|
<form class="in" method="post" action="{{ blogrelative .Blog "/editor" }}">
|
||||||
|
<input type="hidden" name="action" value="delete">
|
||||||
|
<input type="hidden" name="url" value="{{ .Canonical }}">
|
||||||
|
<input type="submit" value="{{ string .Blog.Lang "delete" }}">
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
{{ end }}
|
||||||
{{ if commentsenabled .Blog }}
|
{{ if commentsenabled .Blog }}
|
||||||
{{ include "interactions" . }}
|
{{ include "interactions" . }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
|
@ -17,6 +17,7 @@ interactions: "Interactions & Comments"
|
||||||
interactionslabel: "Have you published a response to this? Paste the URL here."
|
interactionslabel: "Have you published a response to this? Paste the URL here."
|
||||||
likeof: "Like of"
|
likeof: "Like of"
|
||||||
login: "Login"
|
login: "Login"
|
||||||
|
logout: "Logout"
|
||||||
nameopt: "Name (optional)"
|
nameopt: "Name (optional)"
|
||||||
next: "Next"
|
next: "Next"
|
||||||
notifications: "Notifications"
|
notifications: "Notifications"
|
||||||
|
|
Loading…
Reference in New Issue