docs: readme and comments

This commit is contained in:
efim
2023-10-09 14:56:57 +00:00
parent 8842235372
commit 36c8def8c1
5 changed files with 300 additions and 1 deletions

View File

@@ -14,6 +14,8 @@ import (
const AuthCookieName = "Auth"
// registeres on pocketbase middleware that
// Sets and Reads session data into a secure cookie
func AddCookieSessionMiddleware(app *pocketbase.PocketBase) {
app.OnBeforeServe().Add(func(e *core.ServeEvent) error {
e.Router.Use(loadAuthContextFromCookie(app))
@@ -35,6 +37,7 @@ func AddCookieSessionMiddleware(app *pocketbase.PocketBase) {
})
return nil
})
// fires for admin authentication
app.OnAdminAuthRequest().Add(func(e *core.AdminAuthEvent) error {
e.HttpContext.SetCookie(&http.Cookie{
Name: AuthCookieName,