-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
228adb5
commit 1bbcabb
Showing
4 changed files
with
63 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/** | ||
* Change access from one email to another. | ||
*/ | ||
|
||
const { RED_COLOR, yargs } = require('../shared/scim'); | ||
const { | ||
addMemberToGroup, | ||
findMemberByEmail, | ||
findOrProvisionUser, | ||
removeMemberFromWorkspace, | ||
} = require('./shared'); | ||
|
||
const argv = yargs | ||
.option('groupId', { | ||
alias: 'g', | ||
describe: 'The ID of the group to add the User to', | ||
demand: true, | ||
default: '7d3e5712-a873-43a8-a4b5-2ab138a9e2ea', | ||
}) | ||
.option('old', { | ||
alias: 'o', | ||
describe: "User's current email address", | ||
demand: true, | ||
}) | ||
.option('new', { | ||
alias: 'n', | ||
describe: "User's new email address", | ||
demand: true, | ||
}).argv; | ||
|
||
(async () => { | ||
const { groupId, old: oldEmail, new: newEmail } = argv; | ||
|
||
// Find the old member | ||
const oldMember = await findMemberByEmail(oldEmail); | ||
if (!oldMember) { | ||
return console.log(RED_COLOR, `No member by email <${oldEmail}> found`); | ||
} | ||
|
||
// Provision the new member | ||
const user = await findOrProvisionUser(newEmail); | ||
if (!user.id) { | ||
return console.log(RED_COLOR, 'Could not find or provision user'); | ||
} | ||
|
||
await addMemberToGroup(argv.groupId, user.id); | ||
await removeMemberFromWorkspace(oldMember.id); | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,4 +47,4 @@ | |
"memberCount": 4, | ||
"index": 3 | ||
} | ||
] | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters