MCPcopy
hub / github.com/pocketbase/pocketbase / registerAuthOriginHooks

Method registerAuthOriginHooks

core/auth_origin_model.go:111–140  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

109}
110
111func (app *BaseApp) registerAuthOriginHooks() {
112 recordRefHooks[*AuthOrigin](app, CollectionNameAuthOrigins, CollectionTypeAuth)
113
114 // delete existing auth origins on password change
115 app.OnRecordUpdate().Bind(&hook.Handler[*RecordEvent]{
116 Func: func(e *RecordEvent) error {
117 err := e.Next()
118 if err != nil || !e.Record.Collection().IsAuth() {
119 return err
120 }
121
122 old := e.Record.Original().GetString(FieldNamePassword + ":hash")
123 new := e.Record.GetString(FieldNamePassword + ":hash")
124 if old != new {
125 err = e.App.DeleteAllAuthOriginsByRecord(e.Record)
126 if err != nil {
127 e.App.Logger().Warn(
128 "Failed to delete all previous auth origin fingerprints",
129 "error", err,
130 "recordId", e.Record.Id,
131 "collectionId", e.Record.Collection().Id,
132 )
133 }
134 }
135
136 return nil
137 },
138 Priority: 99,
139 })
140}
141
142// -------------------------------------------------------------------
143

Callers 1

registerBaseHooksMethod · 0.95

Calls 9

OnRecordUpdateMethod · 0.95
IsAuthMethod · 0.80
CollectionMethod · 0.80
GetStringMethod · 0.80
OriginalMethod · 0.80
NextMethod · 0.65
LoggerMethod · 0.65
BindMethod · 0.45

Tested by

no test coverage detected