add auto create/delete IAMs
parent
9ea79a5ebc
commit
ade901e6be
|
@ -90,31 +90,37 @@ export default async function departmentPager(client: Client): Promise<NodeJS.Ti
|
|||
if (!pager) continue;
|
||||
if (pager.num.startsWith('00') && !member.roles.includes('662163685439045632')) {
|
||||
await client.db.PagerNumber.deleteOne({ num: pager.num });
|
||||
await client.util.authClient.deleteUser({ id: member.id });
|
||||
client.util.signale.log(`Pager Number '${pager.num}' has been deleted.`);
|
||||
await client.util.removeUserFromMailingList(pager.emailAddresses[0], 'all-staff');
|
||||
}
|
||||
if (pager.num.startsWith('01') && !member.roles.includes('701454855952138300')) {
|
||||
await client.db.PagerNumber.deleteOne({ num: pager.num });
|
||||
await client.util.authClient.deleteUser({ id: member.id });
|
||||
client.util.signale.log(`Pager Number '${pager.num}' has been deleted.`);
|
||||
await client.util.removeUserFromMailingList(pager.emailAddresses[0], 'all-staff');
|
||||
}
|
||||
if (pager.num.startsWith('10') && !member.roles.includes('701454780828221450')) {
|
||||
await client.db.PagerNumber.deleteOne({ num: pager.num });
|
||||
await client.util.authClient.deleteUser({ id: member.id });
|
||||
client.util.signale.log(`Pager Number '${pager.num}' has been deleted.`);
|
||||
await client.util.removeUserFromMailingList(pager.emailAddresses[0], 'all-staff');
|
||||
}
|
||||
if (pager.num.startsWith('20') && !member.roles.includes('455972169449734144')) {
|
||||
await client.db.PagerNumber.deleteOne({ num: pager.num });
|
||||
await client.util.authClient.deleteUser({ id: member.id });
|
||||
client.util.signale.log(`Pager Number '${pager.num}' has been deleted.`);
|
||||
await client.util.removeUserFromMailingList(pager.emailAddresses[0], 'all-staff');
|
||||
}
|
||||
if (pager.num.startsWith('21') && !member.roles.includes('453689940140883988')) {
|
||||
await client.db.PagerNumber.deleteOne({ num: pager.num });
|
||||
await client.util.authClient.deleteUser({ id: member.id });
|
||||
client.util.signale.log(`Pager Number '${pager.num}' has been deleted.`);
|
||||
await client.util.removeUserFromMailingList(pager.emailAddresses[0], 'all-staff');
|
||||
}
|
||||
if (pager.num.startsWith('22') && !member.roles.includes('701481967149121627')) {
|
||||
await client.db.PagerNumber.deleteOne({ num: pager.num });
|
||||
await client.util.authClient.deleteUser({ id: member.id });
|
||||
client.util.signale.log(`Pager Number '${pager.num}' has been deleted.`);
|
||||
await client.util.removeUserFromMailingList(pager.emailAddresses[0], 'all-staff');
|
||||
}
|
||||
|
@ -149,9 +155,25 @@ export default async function departmentPager(client: Client): Promise<NodeJS.Ti
|
|||
});
|
||||
if (await client.db.PagerNumber.findOne({ num: randomPagerNumber })) continue;
|
||||
pager = await newNumber.save();
|
||||
await client.util.authClient.createUser({
|
||||
email: acknowledgement.emailAddress,
|
||||
name: member.username,
|
||||
user_id: member.id,
|
||||
connection: 'Staff-Database',
|
||||
email_verified: true,
|
||||
app_metadata: {
|
||||
boardOfDirectors: true,
|
||||
},
|
||||
picture: member.avatarURL,
|
||||
});
|
||||
const passwordTicket = await client.util.authClient.createPasswordChangeTicket({
|
||||
email: acknowledgement.emailAddress,
|
||||
connection_id: 'con_T3ELEx2reigKMSlP',
|
||||
});
|
||||
logNewPager(client, randomPagerNumber, member);
|
||||
client.getDMChannel(member.id).then((chan) => {
|
||||
chan.createMessage(`__**Pager Number Creation**__\nYour individual pager number has been automatically created. Your number (PN) is ${randomPagerNumber}.`);
|
||||
chan.createMessage(`__**Library of Code sp-us | Identity Access Management**__\n__Reset Password__\n\nPlease click on the link below to change your IAM password.\n${passwordTicket.ticket}`);
|
||||
});
|
||||
} else if (!pager && member.roles.includes('701454855952138300')) {
|
||||
// Supervisors
|
||||
|
@ -173,10 +195,26 @@ export default async function departmentPager(client: Client): Promise<NodeJS.Ti
|
|||
discordIDs: [member.id],
|
||||
});
|
||||
if (await client.db.PagerNumber.findOne({ num: randomPagerNumber })) continue;
|
||||
logNewPager(client, randomPagerNumber, member);
|
||||
pager = await newNumber.save();
|
||||
await client.util.authClient.createUser({
|
||||
email: acknowledgement.emailAddress,
|
||||
name: member.username,
|
||||
user_id: member.id,
|
||||
connection: 'Staff-Database',
|
||||
email_verified: true,
|
||||
app_metadata: {
|
||||
supervisor: true,
|
||||
},
|
||||
picture: member.avatarURL,
|
||||
});
|
||||
const passwordTicket = await client.util.authClient.createPasswordChangeTicket({
|
||||
email: acknowledgement.emailAddress,
|
||||
connection_id: 'con_T3ELEx2reigKMSlP',
|
||||
});
|
||||
logNewPager(client, randomPagerNumber, member);
|
||||
client.getDMChannel(member.id).then((chan) => {
|
||||
chan.createMessage(`__**Pager Number Creation**__\nYour individual pager number has been automatically created. Your number (PN) is ${randomPagerNumber}.`);
|
||||
chan.createMessage(`__**Library of Code sp-us | Identity Access Management**__\n__Reset Password__\n\nPlease click on the link below to change your IAM password.\n${passwordTicket.ticket}`);
|
||||
});
|
||||
} else if (!pager && member.roles.includes('701454780828221450')) {
|
||||
// Technicians
|
||||
|
@ -199,10 +237,26 @@ export default async function departmentPager(client: Client): Promise<NodeJS.Ti
|
|||
discordIDs: [member.id],
|
||||
});
|
||||
if (await client.db.PagerNumber.findOne({ num: randomPagerNumber })) continue;
|
||||
logNewPager(client, randomPagerNumber, member);
|
||||
pager = await newNumber.save();
|
||||
await client.util.authClient.createUser({
|
||||
email: acknowledgement.emailAddress,
|
||||
name: member.username,
|
||||
user_id: member.id,
|
||||
connection: 'Staff-Database',
|
||||
email_verified: true,
|
||||
app_metadata: {
|
||||
technician: true,
|
||||
},
|
||||
picture: member.avatarURL,
|
||||
});
|
||||
const passwordTicket = await client.util.authClient.createPasswordChangeTicket({
|
||||
email: acknowledgement.emailAddress,
|
||||
connection_id: 'con_T3ELEx2reigKMSlP',
|
||||
});
|
||||
logNewPager(client, randomPagerNumber, member);
|
||||
client.getDMChannel(member.id).then((chan) => {
|
||||
chan.createMessage(`__**Pager Number Creation**__\nYour individual pager number has been automatically created. Your number (PN) is ${randomPagerNumber}.`);
|
||||
chan.createMessage(`__**Library of Code sp-us | Identity Access Management**__\n__Reset Password__\n\nPlease click on the link below to change your IAM password.\n${passwordTicket.ticket}`);
|
||||
});
|
||||
} else if (!pager && member.roles.includes('455972169449734144')) {
|
||||
// Moderators
|
||||
|
@ -225,10 +279,26 @@ export default async function departmentPager(client: Client): Promise<NodeJS.Ti
|
|||
discordIDs: [member.id],
|
||||
});
|
||||
if (await client.db.PagerNumber.findOne({ num: randomPagerNumber })) continue;
|
||||
logNewPager(client, randomPagerNumber, member);
|
||||
pager = await newNumber.save();
|
||||
await client.util.authClient.createUser({
|
||||
email: acknowledgement.emailAddress,
|
||||
name: member.username,
|
||||
user_id: member.id,
|
||||
connection: 'Staff-Database',
|
||||
email_verified: true,
|
||||
app_metadata: {
|
||||
moderator: true,
|
||||
},
|
||||
picture: member.avatarURL,
|
||||
});
|
||||
const passwordTicket = await client.util.authClient.createPasswordChangeTicket({
|
||||
email: acknowledgement.emailAddress,
|
||||
connection_id: 'con_T3ELEx2reigKMSlP',
|
||||
});
|
||||
logNewPager(client, randomPagerNumber, member);
|
||||
client.getDMChannel(member.id).then((chan) => {
|
||||
chan.createMessage(`__**Pager Number Creation**__\nYour individual pager number has been automatically created. Your number (PN) is ${randomPagerNumber}.`);
|
||||
chan.createMessage(`__**Library of Code sp-us | Identity Access Management**__\n__Reset Password__\n\nPlease click on the link below to change your IAM password.\n${passwordTicket.ticket}`);
|
||||
});
|
||||
} else if (!pager && member.roles.includes('453689940140883988')) {
|
||||
// Core Team
|
||||
|
@ -251,10 +321,26 @@ export default async function departmentPager(client: Client): Promise<NodeJS.Ti
|
|||
discordIDs: [member.id],
|
||||
});
|
||||
if (await client.db.PagerNumber.findOne({ num: randomPagerNumber })) continue;
|
||||
logNewPager(client, randomPagerNumber, member);
|
||||
pager = await newNumber.save();
|
||||
await client.util.authClient.createUser({
|
||||
email: acknowledgement.emailAddress,
|
||||
name: member.username,
|
||||
user_id: member.id,
|
||||
connection: 'Staff-Database',
|
||||
email_verified: true,
|
||||
app_metadata: {
|
||||
coreTeam: true,
|
||||
},
|
||||
picture: member.avatarURL,
|
||||
});
|
||||
const passwordTicket = await client.util.authClient.createPasswordChangeTicket({
|
||||
email: acknowledgement.emailAddress,
|
||||
connection_id: 'con_T3ELEx2reigKMSlP',
|
||||
});
|
||||
logNewPager(client, randomPagerNumber, member);
|
||||
client.getDMChannel(member.id).then((chan) => {
|
||||
chan.createMessage(`__**Pager Number Creation**__\nYour individual pager number has been automatically created. Your number (PN) is ${randomPagerNumber}.`);
|
||||
chan.createMessage(`__**Library of Code sp-us | Identity Access Management**__\n__Reset Password__\n\nPlease click on the link below to change your IAM password.\n${passwordTicket.ticket}`);
|
||||
});
|
||||
} else if (!pager && member.roles.includes('701481967149121627')) {
|
||||
// Associates
|
||||
|
@ -277,10 +363,26 @@ export default async function departmentPager(client: Client): Promise<NodeJS.Ti
|
|||
discordIDs: [member.id],
|
||||
});
|
||||
if (await client.db.PagerNumber.findOne({ num: randomPagerNumber })) continue;
|
||||
logNewPager(client, randomPagerNumber, member);
|
||||
pager = await newNumber.save();
|
||||
await client.util.authClient.createUser({
|
||||
email: acknowledgement.emailAddress,
|
||||
name: member.username,
|
||||
user_id: member.id,
|
||||
connection: 'Staff-Database',
|
||||
email_verified: true,
|
||||
app_metadata: {
|
||||
associate: true,
|
||||
},
|
||||
picture: member.avatarURL,
|
||||
});
|
||||
const passwordTicket = await client.util.authClient.createPasswordChangeTicket({
|
||||
email: acknowledgement.emailAddress,
|
||||
connection_id: 'con_T3ELEx2reigKMSlP',
|
||||
});
|
||||
logNewPager(client, randomPagerNumber, member);
|
||||
client.getDMChannel(member.id).then((chan) => {
|
||||
chan.createMessage(`__**Pager Number Creation**__\nYour individual pager number has been automatically created. Your number (PN) is ${randomPagerNumber}.`);
|
||||
chan.createMessage(`__**Library of Code sp-us | Identity Access Management**__\n__Reset Password__\n\nPlease click on the link below to change your IAM password.\n${passwordTicket.ticket}`);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue