NewAuthOrigin instantiates and returns a new blank *AuthOrigin model. Example usage: origin := core.NewOrigin(app) origin.SetRecordRef(user.Id) origin.SetCollectionRef(user.Collection().Id) origin.SetFingerprint("...") app.Save(origin)
(app App)
| 34 | // origin.SetFingerprint("...") |
| 35 | // app.Save(origin) |
| 36 | func NewAuthOrigin(app App) *AuthOrigin { |
| 37 | m := &AuthOrigin{} |
| 38 | |
| 39 | c, err := app.FindCachedCollectionByNameOrId(CollectionNameAuthOrigins) |
| 40 | if err != nil { |
| 41 | // this is just to make tests easier since authOrigins is a system collection and it is expected to be always accessible |
| 42 | // (note: the loaded record is further checked on AuthOrigin.PreValidate()) |
| 43 | c = NewBaseCollection("@___invalid___") |
| 44 | } |
| 45 | |
| 46 | m.Record = NewRecord(c) |
| 47 | |
| 48 | return m |
| 49 | } |
| 50 | |
| 51 | // PreValidate implements the [PreValidator] interface and checks |
| 52 | // whether the proxy is properly loaded. |
searching dependent graphs…