NewExternalAuth instantiates and returns a new blank *ExternalAuth model. Example usage: ea := core.NewExternalAuth(app) ea.SetRecordRef(user.Id) ea.SetCollectionRef(user.Collection().Id) ea.SetProvider("google") ea.SetProviderId("...") app.Save(ea)
(app App)
| 34 | // ea.SetProviderId("...") |
| 35 | // app.Save(ea) |
| 36 | func NewExternalAuth(app App) *ExternalAuth { |
| 37 | m := &ExternalAuth{} |
| 38 | |
| 39 | c, err := app.FindCachedCollectionByNameOrId(CollectionNameExternalAuths) |
| 40 | if err != nil { |
| 41 | // this is just to make tests easier since it is a system collection and it is expected to be always accessible |
| 42 | // (note: the loaded record is further checked on ExternalAuth.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…