aws-user-service
Advanced tools
Comparing version 1.4.0 to 1.5.0
45
index.js
const MongoRepository = require('senter-mongo-repository') | ||
const AWS = require('aws-sdk') | ||
AWS.config.update({ region: process.env.REGION }) | ||
AWS.config.update({region: process.env.REGION}) | ||
var noOrganisationOptions = MongoRepository.BuildCallOptions(true, false) | ||
module.exports = class AwsUserService { | ||
constructor(authIntegrationUserPoolId, userRepository) { | ||
this.authIntegrationUserPoolId = authIntegrationUserPoolId | ||
constructor(userPoolId, userRepository) { | ||
this.userPoolId = userPoolId | ||
this.userRepository = userRepository | ||
@@ -51,3 +51,3 @@ this.cognitoidentityserviceprovider = new AWS.CognitoIdentityServiceProvider() | ||
const listUsersResponsePromise = this.cognitoidentityserviceprovider.listUsers({ | ||
UserPoolId: this.authIntegrationUserPoolId, | ||
UserPoolId: this.userPoolId, | ||
Filter: `sub = "${userId}"`, | ||
@@ -61,4 +61,5 @@ Limit: 1 | ||
const cognitoUser = result[0].Users[0] | ||
if (result[1]) { | ||
cognitoUser.organisationId = result[1].organisationId | ||
const senterUser = result[1] | ||
if (senterUser) { | ||
cognitoUser.organisationId = senterUser.organisationId | ||
} | ||
@@ -71,3 +72,3 @@ cognitoUser.id = userId | ||
const request = { | ||
UserPoolId: this.authIntegrationUserPoolId, | ||
UserPoolId: this.userPoolId, | ||
Filter: `email ^= "${partialEmail}"`, | ||
@@ -91,3 +92,3 @@ Limit: pageSize | ||
const request = { | ||
UserPoolId: this.authIntegrationUserPoolId, | ||
UserPoolId: this.userPoolId, | ||
Limit: pageSize | ||
@@ -110,3 +111,3 @@ } | ||
const cognitoResponse = await this.cognitoidentityserviceprovider.adminListGroupsForUser({ | ||
UserPoolId: this.authIntegrationUserPoolId, | ||
UserPoolId: this.userPoolId, | ||
Username: userId, | ||
@@ -143,6 +144,28 @@ Limit: 10 | ||
"Username": userId, | ||
"UserPoolId": this.authIntegrationUserPoolId | ||
"UserPoolId": this.userPoolId | ||
} | ||
return await this.cognitoidentityserviceprovider.adminUpdateUserAttributes(params).promise() | ||
} | ||
} | ||
async disableUser(userId) { | ||
const params = { | ||
UserPoolId: this.userPoolId, | ||
Username: userId | ||
} | ||
const response = await this.cognitoidentityserviceprovider.adminDisableUser(params) | ||
if (response.error) { | ||
throw response.error | ||
} | ||
} | ||
async enableUser(userId) { | ||
const params = { | ||
UserPoolId: this.userPoolId, | ||
Username: userId | ||
} | ||
const response = await this.cognitoidentityserviceprovider.adminEnableUser(params) | ||
if (response.error) { | ||
throw response.error | ||
} | ||
} | ||
} |
{ | ||
"name": "aws-user-service", | ||
"version": "1.4.0", | ||
"version": "1.5.0", | ||
"description": "Contain methods to work with asw user", | ||
@@ -14,2 +14,2 @@ "main": "index.js", | ||
} | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5543
137