[#3700] allow a single OAuth2 user to be used for authentication in multiple auth collection
This commit is contained in:
@@ -85,7 +85,7 @@ func init() {
|
||||
);
|
||||
|
||||
CREATE UNIQUE INDEX _externalAuths_record_provider_idx on {{_externalAuths}} ([[collectionId]], [[recordId]], [[provider]]);
|
||||
CREATE UNIQUE INDEX _externalAuths_provider_providerId_idx on {{_externalAuths}} ([[provider]], [[providerId]]);
|
||||
CREATE UNIQUE INDEX _externalAuths_collection_provider_idx on {{_externalAuths}} ([[collectionId]], [[provider]], [[providerId]]);
|
||||
`).Execute()
|
||||
if tablesErr != nil {
|
||||
return tablesErr
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
package migrations
|
||||
|
||||
import (
|
||||
"github.com/pocketbase/dbx"
|
||||
)
|
||||
|
||||
// Fixes the unique _externalAuths constraint for old installations
|
||||
// to allow a single OAuth2 provider to be registered for different auth collections.
|
||||
func init() {
|
||||
AppMigrations.Register(func(db dbx.Builder) error {
|
||||
_, createErr := db.NewQuery("CREATE UNIQUE INDEX IF NOT EXISTS _externalAuths_collection_provider_idx on {{_externalAuths}} ([[collectionId]], [[provider]], [[providerId]])").Execute()
|
||||
if createErr != nil {
|
||||
return createErr
|
||||
}
|
||||
|
||||
_, dropErr := db.NewQuery("DROP INDEX IF EXISTS _externalAuths_provider_providerId_idx").Execute()
|
||||
if dropErr != nil {
|
||||
return dropErr
|
||||
}
|
||||
|
||||
return nil
|
||||
}, nil)
|
||||
}
|
||||
Reference in New Issue
Block a user