MCPcopy
hub / github.com/pocketbase/pocketbase / NewExternalAuth

Function NewExternalAuth

core/external_auth_model.go:36–49  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

34// ea.SetProviderId("...")
35// app.Save(ea)
36func 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.

Callers 10

TestNewExternalAuthFunction · 0.92
TestExternalAuthProviderFunction · 0.92
TestExternalAuthCreatedFunction · 0.92
TestExternalAuthUpdatedFunction · 0.92
TestRecordAuthWithOAuth2Function · 0.92
oauth2SubmitFunction · 0.92

Calls 3

NewBaseCollectionFunction · 0.85
NewRecordFunction · 0.85

Tested by 9

TestNewExternalAuthFunction · 0.74
TestExternalAuthProviderFunction · 0.74
TestExternalAuthCreatedFunction · 0.74
TestExternalAuthUpdatedFunction · 0.74
TestRecordAuthWithOAuth2Function · 0.74

Used in the wild real call sites across dependent graphs

searching dependent graphs…