This repository has been archived by the owner on Oct 16, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Creating a user via graph Api (#107)
* added methods: creating getting and deleting a user via graph Api * Rebased and make lint happy Signed-off-by: Kiran Parajuli <[email protected]> * removed the check in deleting a user * fix after review Co-authored-by: Kiran Parajuli <[email protected]>
- Loading branch information
1 parent
3ad87fe
commit 10cd296
Showing
5 changed files
with
83 additions
and
5 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
const httpHelper = require('./httpHelper') | ||
const userSettings = require('./userSettings') | ||
const userHelper = require('./userSettings') | ||
|
||
|
||
exports.createUser = function ( | ||
user, | ||
password = null, | ||
displayName = null, | ||
email = null | ||
) { | ||
displayName = displayName || userHelper.getDisplayNameForUser(user) | ||
email = email || userHelper.getEmailAddressForUser(user) | ||
password = password || userHelper.getPasswordForUser(user) | ||
|
||
const body = JSON.stringify({ | ||
displayName, | ||
mail: email, | ||
onPremisesSamAccountName: user, | ||
passwordProfile: { password } | ||
}) | ||
userSettings.addUserToCreatedUsersList(user, password, displayName, email) | ||
return httpHelper | ||
.postGraph('users', 'admin', body) | ||
.then(res => httpHelper.checkStatus(res, 'Failed while creating user')) | ||
} | ||
|
||
exports.deleteUser = function (user) { | ||
return httpHelper | ||
.deleteGraph(`users/${user}`, 'admin') | ||
} | ||
|
||
exports.getUser = function (user) { | ||
return httpHelper | ||
.getGraph(`users/${user}`, 'admin') | ||
.then(res => httpHelper.checkStatus(res, 'user does not found')) | ||
} |
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