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.
added methods: creating getting and deleting a user via graph Api
- Loading branch information
1 parent
f886d3e
commit c64af0c
Showing
4 changed files
with
76 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
const httpHelper = require('./httpHelper') | ||
const userHelper = require('./userSettings') | ||
|
||
|
||
exports.createUser = async 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': displayName, | ||
'mail': email, | ||
'onPremisesSamAccountName': user, | ||
'passwordProfile': { 'password': password } | ||
}) | ||
|
||
console.log('step2 - create') | ||
return httpHelper | ||
.postGraph('users', 'admin', body) | ||
.then(res => httpHelper.checkStatus(res, 'Failed while creating user')) | ||
} | ||
|
||
exports.deleteUser = async function (user) { | ||
console.log('step1 - delete') | ||
return httpHelper | ||
.deleteGraph(`users/${user}`, 'admin') | ||
.then(res => httpHelper.checkStatus(res, 'Failed while deleting user')) | ||
} | ||
|
||
exports.getUser = async function (user) { | ||
console.log('step3 - init') | ||
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