Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
authorityId: authority.id,
authorityUserId: token.sub,
details: {}
},
{
recordId: v4(),
createdByAuthorizationId: authorizationId,
createdAt: new Date()
}
);
}
}
// Create a new user.
if (!credential && authority.details.createsUnmatchedUsers) {
const user = await User.write(
tx,
{
id: v4(),
enabled: true,
type: "human",
name: token.name || ""
},
{
recordId: v4(),
createdByAuthorizationId: authorizationId,
createdAt: new Date()
}
);
credential = await OpenIdCredential.write(
tx,
tx.query("INSERT INTO authx.user (id) VALUES ($1)", [user.data.id]),
tx.query("INSERT INTO authx.authority (id) VALUES ($1)", [
authority.data.id
]),
tx.query("INSERT INTO authx.credential (id) VALUES ($1)", [
credential.data.id
]),
tx.query("INSERT INTO authx.role (id) VALUES ($1)", [role.data.id]),
tx.query("INSERT INTO authx.authorization (id) VALUES ($1)", [
authorization.data.id
])
]);
// insert the records
await Promise.all([
User.write(tx, user.data, user.metadata),
PasswordAuthority.write(tx, authority.data, authority.metadata),
PasswordCredential.write(tx, credential.data, credential.metadata),
Role.write(tx, role.data, role.metadata),
Authorization.write(tx, authorization.data, authorization.metadata)
]);
}
insert: (tx: PoolClient) =>
User.write(
tx,
{
id: "eaa9fa5e-088a-4ae2-a6ab-f120006b20a9",
enabled: true,
type: "human",
name: "Pam Beesly-Halpert"
},
{
recordId: "60cd702f-8cb5-4aa2-aae6-7fd9778f8d50",
createdByAuthorizationId: "f0e54748-c7bb-4724-ad8b-7dabb66aafa9",
createdAt: new Date("2019-03-06T21:07:59.814Z")
}
)
},