()
| 109 | } |
| 110 | |
| 111 | func (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 |
no test coverage detected