Skip to content

Commit

Permalink
Merge pull request #120 from pliancy/fix/set-user-passwords
Browse files Browse the repository at this point in the history
fix: add support for setting user passwords
  • Loading branch information
santese authored Jul 26, 2024
2 parents 5561ec2 + 06834d7 commit b71e809
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
29 changes: 29 additions & 0 deletions src/lib/microsoft-partnercenter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,42 @@ export class MicrosoftPartnerCenter extends MicrosoftApiBase {
return data
}

async getCustomerUserByPrincipalName(
customerId: string,
principalName: string,
): Promise<User | undefined> {
const users = await this.getAllCustomerUsers(customerId)
return users.find((e) => e.userPrincipalName === principalName)
}

async getCustomerUserRoles(customerId: string, userId: string): Promise<UserRole[]> {
const { data } = await this.httpAgent.get(
`/customers/${customerId}/users/${userId}/directoryroles`,
)
return data.items
}

async setCustomerUserPassword(
customerId: string,
userId: string,
password: string,
forceChangePassword: boolean,
): Promise<User> {
const { data } = await this.httpAgent.patch(
`/customers/${customerId}/users/${userId}/resetpassword`,
{
passwordProfile: {
password,
forceChangePassword,
},
attributes: {
objectType: 'CustomerUser',
},
},
)
return data
}

async setCustomerUserRole(
customerId: string,
roleId: string,
Expand Down
2 changes: 1 addition & 1 deletion src/lib/types/users.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export interface User {
lastName: string
displayName: string
immutableId: string
passwordProfile: PasswordProfile
passwordProfile?: PasswordProfile
lastDirectorySyncTime: null
userDomainType: string
state: string
Expand Down

0 comments on commit b71e809

Please sign in to comment.