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,
|
||||
}, 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(checkLoggedIn)
|
||||
|
||||
// Logout
|
||||
r.With(authMiddleware).Get("/login", serveLogin)
|
||||
r.With(authMiddleware).Get("/logout", serveLogout)
|
||||
|
||||
// Micropub
|
||||
r.Route(micropubPath, func(mpRouter chi.Router) {
|
||||
mpRouter.Use(checkIndieAuth)
|
||||
|
|
|
@ -142,6 +142,10 @@ footer * {
|
|||
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 {
|
||||
width: 100%;
|
||||
}
|
||||
|
|
|
@ -169,6 +169,10 @@ footer {
|
|||
display: none;
|
||||
}
|
||||
|
||||
.in {
|
||||
display: inline;
|
||||
}
|
||||
|
||||
.fw {
|
||||
width: 100%;
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
• <a href="/notifications">{{ string .Blog.Lang "notifications" }}</a>
|
||||
• <a href="/webmention">{{ string .Blog.Lang "webmentions" }}</a>
|
||||
• <a href="{{ blogrelative .Blog "/comment" }}">{{ string .Blog.Lang "comments" }}</a>
|
||||
• <a href="/logout">{{ string .Blog.Lang "logout" }}</a>
|
||||
</nav>
|
||||
{{ end }}
|
||||
</header>
|
||||
|
|
|
@ -27,6 +27,20 @@
|
|||
</article>
|
||||
{{ include "author" . }}
|
||||
</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 }}
|
||||
{{ include "interactions" . }}
|
||||
{{ end }}
|
||||
|
|
|
@ -17,6 +17,7 @@ interactions: "Interactions & Comments"
|
|||
interactionslabel: "Have you published a response to this? Paste the URL here."
|
||||
likeof: "Like of"
|
||||
login: "Login"
|
||||
logout: "Logout"
|
||||
nameopt: "Name (optional)"
|
||||
next: "Next"
|
||||
notifications: "Notifications"
|
||||
|
|
Loading…
Reference in New Issue