parent
c032987952
commit
bfee145b6c
|
@ -148,7 +148,7 @@ and
|
||||||
#+end_src
|
#+end_src
|
||||||
is what i need for it to pick up pb_data from work directory, cool
|
is what i need for it to pick up pb_data from work directory, cool
|
||||||
|
|
||||||
** TODO write nixos module
|
** DONE write nixos module
|
||||||
need to pass data and migration location as params
|
need to pass data and migration location as params
|
||||||
and address on which to serve, cool
|
and address on which to serve, cool
|
||||||
i suppose
|
i suppose
|
||||||
|
@ -174,10 +174,21 @@ cool
|
||||||
oh, but if i'm using nginx i'll need my own certificate, that makes sence
|
oh, but if i'm using nginx i'll need my own certificate, that makes sence
|
||||||
*** maybe things are ok?
|
*** maybe things are ok?
|
||||||
let's try to plaintext deploy?
|
let's try to plaintext deploy?
|
||||||
|
*** quoting of the '' in multiline string
|
||||||
|
https://nixos.org/manual/nix/stable/language/values.html
|
||||||
|
*** not accessible still
|
||||||
|
sudo journalctl -u nginx --since "1 day ago"
|
||||||
|
*** oh, i forgot to add subname in gandi ui
|
||||||
|
now works
|
||||||
|
*** now i need a way to pass in the hostname
|
||||||
|
because front-end is setting up js 'new PocketBase' with 127.0.0.1 connection
|
||||||
|
*** adding a custom flag:
|
||||||
|
https://github.com/pocketbase/pocketbase/discussions/1900
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
** TODO add docker image from nix
|
** TODO add docker image from nix
|
||||||
*** TODO add cli for port and host
|
*** CANCELLED add cli for port and host
|
||||||
** TODO add readme and comments
|
** TODO add readme and comments
|
||||||
** TODO configure tls / ssl / https on franzk deployment
|
** TODO configure tls / ssl / https on franzk deployment
|
||||||
can it be configured on render.com?
|
can it be configured on render.com?
|
||||||
|
@ -185,6 +196,7 @@ can it be configured on render.com?
|
||||||
** TODO get icons for the auth providers. surely they are accessible from the pocketbase itself?
|
** TODO get icons for the auth providers. surely they are accessible from the pocketbase itself?
|
||||||
http://localhost:8090/_/images/oauth2/apple.svg
|
http://localhost:8090/_/images/oauth2/apple.svg
|
||||||
yes.
|
yes.
|
||||||
|
** TODO read and add ok logging
|
||||||
** TODO figure out and enbale migrations
|
** TODO figure out and enbale migrations
|
||||||
https://pocketbase.io/docs/go-migrations/#enable-go-migrations
|
https://pocketbase.io/docs/go-migrations/#enable-go-migrations
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
package middleware
|
package middleware
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"log"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"github.com/labstack/echo/v5"
|
"github.com/labstack/echo/v5"
|
||||||
"github.com/pocketbase/pocketbase"
|
"github.com/pocketbase/pocketbase"
|
||||||
|
@ -23,10 +21,6 @@ func AddCookieSessionMiddleware(app *pocketbase.PocketBase) {
|
||||||
|
|
||||||
// fires for every auth collection
|
// fires for every auth collection
|
||||||
app.OnRecordAuthRequest().Add(func(e *core.RecordAuthEvent) error {
|
app.OnRecordAuthRequest().Add(func(e *core.RecordAuthEvent) error {
|
||||||
log.Println(e.HttpContext)
|
|
||||||
log.Println(e.Record)
|
|
||||||
log.Println(e.Token)
|
|
||||||
log.Println(e.Meta)
|
|
||||||
e.HttpContext.SetCookie(&http.Cookie{
|
e.HttpContext.SetCookie(&http.Cookie{
|
||||||
Name: AuthCookieName,
|
Name: AuthCookieName,
|
||||||
Value: e.Token,
|
Value: e.Token,
|
||||||
|
@ -39,9 +33,6 @@ func AddCookieSessionMiddleware(app *pocketbase.PocketBase) {
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
app.OnAdminAuthRequest().Add(func(e *core.AdminAuthEvent) error {
|
app.OnAdminAuthRequest().Add(func(e *core.AdminAuthEvent) error {
|
||||||
log.Println(e.HttpContext)
|
|
||||||
log.Println(e.Admin)
|
|
||||||
log.Println(e.Token)
|
|
||||||
e.HttpContext.SetCookie(&http.Cookie{
|
e.HttpContext.SetCookie(&http.Cookie{
|
||||||
Name: AuthCookieName,
|
Name: AuthCookieName,
|
||||||
Value: e.Token,
|
Value: e.Token,
|
||||||
|
@ -74,14 +65,6 @@ func loadAuthContextFromCookie(app core.App) echo.MiddlewareFunc {
|
||||||
if err == nil && admin != nil {
|
if err == nil && admin != nil {
|
||||||
// "authenticate" the admin
|
// "authenticate" the admin
|
||||||
c.Set(apis.ContextAdminKey, admin)
|
c.Set(apis.ContextAdminKey, admin)
|
||||||
someData := struct {
|
|
||||||
username string
|
|
||||||
email string
|
|
||||||
} {
|
|
||||||
admin.Email,
|
|
||||||
admin.Created.String(),
|
|
||||||
}
|
|
||||||
fmt.Printf("triggering the middlewar for cookie %v and err %v\n", someData, err)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
case tokens.TypeAuthRecord:
|
case tokens.TypeAuthRecord:
|
||||||
|
@ -92,15 +75,6 @@ func loadAuthContextFromCookie(app core.App) echo.MiddlewareFunc {
|
||||||
if err == nil && record != nil {
|
if err == nil && record != nil {
|
||||||
// "authenticate" the app user
|
// "authenticate" the app user
|
||||||
c.Set(apis.ContextAuthRecordKey, record)
|
c.Set(apis.ContextAuthRecordKey, record)
|
||||||
someData := struct {
|
|
||||||
username string
|
|
||||||
email string
|
|
||||||
} {
|
|
||||||
record.Username(),
|
|
||||||
record.Email(),
|
|
||||||
}
|
|
||||||
fmt.Printf("triggering the middlewar for cookie %v and err %v\n", someData, err)
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,6 @@ package pages
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"embed"
|
"embed"
|
||||||
"fmt"
|
|
||||||
"html/template"
|
"html/template"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
@ -47,8 +46,6 @@ func getIndexPageRoute(app *pocketbase.PocketBase) func(*core.ServeEvent) error
|
||||||
record := info.AuthRecord // nil if not authenticated as regular auth record
|
record := info.AuthRecord // nil if not authenticated as regular auth record
|
||||||
|
|
||||||
isGuest := admin == nil && record == nil
|
isGuest := admin == nil && record == nil
|
||||||
coolMessage := fmt.Sprintf("got admin %v and record %v. is guest: %t", admin, record, isGuest)
|
|
||||||
fmt.Print(coolMessage)
|
|
||||||
|
|
||||||
username := ""
|
username := ""
|
||||||
switch {
|
switch {
|
||||||
|
@ -65,7 +62,6 @@ func getIndexPageRoute(app *pocketbase.PocketBase) func(*core.ServeEvent) error
|
||||||
oauthProviderNames = append(oauthProviderNames, name)
|
oauthProviderNames = append(oauthProviderNames, name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fmt.Printf(">> enabled providers names %+v\n", oauthProviderNames)
|
|
||||||
|
|
||||||
indexPageData := struct {
|
indexPageData := struct {
|
||||||
IsGuest, IsAdmin bool
|
IsGuest, IsAdmin bool
|
||||||
|
|
Loading…
Reference in New Issue