20 lines
658 B
JavaScript
20 lines
658 B
JavaScript
/// <reference path="../pb_data/types.d.ts" />
|
|
|
|
/**
|
|
* Fires on every new `users` record - password signup and Google OAuth2
|
|
* signup both create one the same way, so this covers both uniformly -
|
|
* and creates that user's "General" project. Guarantees the REQUIRED
|
|
* documents.project relation always has somewhere to point, even for a
|
|
* brand new account that hasn't touched the project sidebar yet.
|
|
*/
|
|
onRecordAfterCreateSuccess((e) => {
|
|
let projects = e.app.findCollectionByNameOrId("projects")
|
|
let record = new Record(projects, {
|
|
name: "General",
|
|
owner: e.record.id,
|
|
isDefault: true,
|
|
})
|
|
e.app.save(record)
|
|
e.next()
|
|
}, "users")
|