* initial commit * add lists * update permissions * fix waypoint create * needs_full_sync for activitypub trails * fixes build issues * fix list get * further CSRF protection * update API docs * adds rate limiter * fix tiptap mentions * a bit more cleanup of main.go * Fix migration order * fixes reviewed notes * require context for activitpub server calls * improve hashing for identifier * fix copy paste error * fix sync trail/list issues * fix summit log/comment duplicates * adaptions after trail merge * fix dockerignore --------- Co-authored-by: Christian Beutel <> Co-authored-by: slothful-vassal <89943360+slothful-vassal@users.noreply.github.com>
23 lines
524 B
Go
23 lines
524 B
Go
package hooks
|
|
|
|
import (
|
|
"github.com/pocketbase/pocketbase/core"
|
|
"github.com/pocketbase/pocketbase/tools/security"
|
|
)
|
|
|
|
func CreateAPITokenHandler() func(e *core.RecordEvent) error {
|
|
return func(e *core.RecordEvent) error {
|
|
rawToken := "wanderer_key_" + security.RandomString(32)
|
|
|
|
hashedKey := security.SHA256(rawToken)
|
|
|
|
e.Record.Set("token", hashedKey)
|
|
|
|
// Temporarily store rawToken so we can display it once to the user
|
|
e.Record.WithCustomData(true)
|
|
e.Record.Set("rawToken", rawToken)
|
|
|
|
return e.Next()
|
|
}
|
|
}
|