Skip to main content

Class: ImsUserFindingService

backend-services/ims-user-finding.service.ImsUserFindingService

Constructors

constructor

new ImsUserFindingService(graphqlService, strategiesService, loginDataService, imsUserService, backendUserService)

Parameters

NameType
graphqlServiceGraphqlService
strategiesServiceStrategiesService
loginDataServiceUserLoginDataService
imsUserServiceUserLoginDataImsUserService
backendUserServiceBackendUserService

Defined in

gropius-login-service/backend/src/backend-services/ims-user-finding.service.ts:28

Properties

backendUserService

Private Readonly backendUserService: BackendUserService

Defined in

gropius-login-service/backend/src/backend-services/ims-user-finding.service.ts:33


graphqlService

Private Readonly graphqlService: GraphqlService

Defined in

gropius-login-service/backend/src/backend-services/ims-user-finding.service.ts:29


imsUserService

Private Readonly imsUserService: UserLoginDataImsUserService

Defined in

gropius-login-service/backend/src/backend-services/ims-user-finding.service.ts:32


logger

Private Readonly logger: Logger

Defined in

gropius-login-service/backend/src/backend-services/ims-user-finding.service.ts:27


loginDataService

Private Readonly loginDataService: UserLoginDataService

Defined in

gropius-login-service/backend/src/backend-services/ims-user-finding.service.ts:31


strategiesService

Private Readonly strategiesService: StrategiesService

Defined in

gropius-login-service/backend/src/backend-services/ims-user-finding.service.ts:30

Methods

checkFieldsDirectly

Private checkFieldsDirectly(node, requiredTemplatedValues, fieldsToCheck?): boolean

Checks if the values of the specified fields on the templatedValues match the values of those fields on the node Deletes the keys that were compared from templatedValue

Can be used directly on e.g. the ims as node to check the description or on the templated fields of the ims to check those

Parameters

NameTypeDescription
nodeobjectThe node object containing all values of keys to potentially check
requiredTemplatedValuesobjectThe values that the node object must match to pass. All fields to check will be deleted from this object
fieldsToCheck?string[]The names of the fields that should be checked for equivalence on the node object directly instead of on its templated fields. If not given, all keys of templatedFields will be matched

Returns

boolean

true iff all specified keys that the templatedValues had a value fore matched, false else

Defined in

gropius-login-service/backend/src/backend-services/ims-user-finding.service.ts:78


checkIfInstanceMatches

Private checkIfInstanceMatches(strategy, instance, ims, imsTemplatedValues): Promise<boolean>

Parameters

NameType
strategyStrategy
instanceStrategyInstance
imsobject
imsTemplatedValuesObject

Returns

Promise<boolean>

Defined in

gropius-login-service/backend/src/backend-services/ims-user-finding.service.ts:97


checkImsUserExists

checkImsUserExists(imsUser): Promise<boolean>

Checks for the existance of a IMSUser with the neo4jid specified in the given UserLoginDataImsUser

Meant to check database consistency. For a properly created UserLoginDataImsUser this should always return true

Parameters

NameType
imsUserUserLoginDataImsUser

Returns

Promise<boolean>

true iff the UserLoginDataImsUser has a valid associated IMSUser in the backend

Defined in

gropius-login-service/backend/src/backend-services/ims-user-finding.service.ts:473


createAndLinkImsUsersForLoginData

createAndLinkImsUsersForLoginData(loginData): Promise<UserLoginDataImsUser[]>

Performs IMSUser search creation and linkage

Steps:

  • Searches all IMSUser instances in the backend that match the given login data.
  • For IMSs which don't have a single matching IMSUser, creates new IMSUsers in the backend.
  • For all found and created IMSUsers, finds existing ims user entities in the database
  • If there is an ims user entity with a different login data, fails. Filters are to unprecise
  • Creates new ims user entities for all found and created IMSUsers that don't have an entity yet
  • If the login data has a user linked: For all created ims user entities links the corresponding IMSUser and GropiusUser

Parameters

NameTypeDescription
loginDataUserLoginDataThe login data for which to perform ims user search and linking

Returns

Promise<UserLoginDataImsUser[]>

A list of all ims user entitites created as result of the search (not including existing entities)

Defined in

gropius-login-service/backend/src/backend-services/ims-user-finding.service.ts:431


createAndLinkSingleImsUser

createAndLinkSingleImsUser(imsUserId): Promise<UserLoginDataImsUser>

Parameters

NameType
imsUserIdstring

Returns

Promise<UserLoginDataImsUser>

Defined in

gropius-login-service/backend/src/backend-services/ims-user-finding.service.ts:252


createImsUserEntitiesForNeo4jIds

Private createImsUserEntitiesForNeo4jIds(neo4jImsUserIds, loginData): Promise<UserLoginDataImsUser[]>

Creates and saves ims user entities for the given neo4jids and links them to the given login data object.

Caller must make sure, that no ims user entity for the given neo4j ids exist yet.

Parameters

NameTypeDescription
neo4jImsUserIdsstring[]The list of neo4j ids for which to create a ims user in the database
loginDataUserLoginDataThe login data to link with the newly created ims user

Returns

Promise<UserLoginDataImsUser[]>

The list of all the ims user entites crated

Defined in

gropius-login-service/backend/src/backend-services/ims-user-finding.service.ts:402


createNewImsUserInBackendForLoginDataAndIms

createNewImsUserInBackendForLoginDataAndIms(loginData, imsId): Promise<string>

Parameters

NameType
loginDataUserLoginData
imsIdstring

Returns

Promise<string>

Defined in

gropius-login-service/backend/src/backend-services/ims-user-finding.service.ts:338


extractFieldsFromObject

Private extractFieldsFromObject(data, fields): Object

Extracts a subset of fields from the given object, deletes them from the given object and returns them as seperate object

Parameters

NameTypeDescription
dataobjectThe object to extract fields from. This will be modified using delete
fieldsstring[]The names of the fields to remove from the object

Returns

Object

An object with the extracted fields

Defined in

gropius-login-service/backend/src/backend-services/ims-user-finding.service.ts:157


findImsUserIdsForLoginData

findImsUserIdsForLoginData(loginData): Promise<{ imsIdsWithoutImsUsers: string[] ; imsUserIds: string[] }>

Searches for IMSUsers that match the given login data as well as imss that don't have a single matching user

Works by searching for IMSs of which the templated fields (and direct values) match the object given by the strategy instance. Then on these IMSs searches for IMSUsers of which the templated fields (and direct values) match the object given by the login data.

Parameters

NameTypeDescription
loginDataUserLoginDataThe login data instance to search imsUsers and imss for

Returns

Promise<{ imsIdsWithoutImsUsers: string[] ; imsUserIds: string[] }>

The ims users that match the given logn data and all imss that have no ims user matching the given login data

Defined in

gropius-login-service/backend/src/backend-services/ims-user-finding.service.ts:296


findLoginDataForImsUser

findLoginDataForImsUser(imsUserId): Promise<UserLoginData>

Parameters

NameType
imsUserIdstring

Returns

Promise<UserLoginData>

Defined in

gropius-login-service/backend/src/backend-services/ims-user-finding.service.ts:232


generateImsUserWithDifferentLoginDataError

Private generateImsUserWithDifferentLoginDataError(imsUserNeo4jId, loginDataExpectedId, loginDataActualId): string

Throws an error with the following message: Text for when an ims user entity is found in the database, which has a different login data than the login data for which the ims user was found using matching of templated values on ims and ims users

Parameters

NameTypeDescription
imsUserNeo4jIdstringThe neo4j id of the ims user that was found to have a conflice
loginDataExpectedIdstringThe database id of the login data that is currently being processed and for which the given ims user was found
loginDataActualIdstringThe database id of the login data that is already associated with the given ims user

Returns

string

Defined in

gropius-login-service/backend/src/backend-services/ims-user-finding.service.ts:47


getKnownImsUsersForIds

Private getKnownImsUsersForIds(imsUserIds): Promise<{ id: string ; imsUser: UserLoginDataImsUser ; loginDataId: string }[]>

Loads the ims user entities from the database for a given set of backend ids of ims users. Additionally fetches the id of the login data to which the entity belongs.

For every given id returns the given id, the ims user entity (if existing) and the login data id (if ims user entity exists). If ims user doesn't exist, just returns the given neo4jid

Parameters

NameTypeDescription
imsUserIdsstring[]The ist of neo4j/backend ids for which to fetch the ims user

Returns

Promise<{ id: string ; imsUser: UserLoginDataImsUser ; loginDataId: string }[]>

The list of the ims user entities loaded for the given neo4j id and the id of the login data

Defined in

gropius-login-service/backend/src/backend-services/ims-user-finding.service.ts:378


getMatchingInstance

Private getMatchingInstance(ims, imsTemplatedValues): Promise<{ instance: StrategyInstance ; strategy: Strategy }>

Parameters

NameType
imsobject
imsTemplatedValuesObject

Returns

Promise<{ instance: StrategyInstance ; strategy: Strategy }>

Defined in

gropius-login-service/backend/src/backend-services/ims-user-finding.service.ts:117


getMatchingLoginData

getMatchingLoginData(matchingInstance, matchingStrategy, imsUserTemplatedValues, imsUser): Promise<UserLoginData>

Parameters

NameType
matchingInstanceStrategyInstance
matchingStrategyStrategy
imsUserTemplatedValuesobject
imsUserObject
imsUser.displayNamestring
imsUser.email?string
imsUser.idstring
imsUser.username?string

Returns

Promise<UserLoginData>

Defined in

gropius-login-service/backend/src/backend-services/ims-user-finding.service.ts:192


transformObjectToFilterObject

Private transformObjectToFilterObject(data): Object

Converts an object of string keys and values to an object with the same keys where the values are wrapped as a filter for graphql.

Example:

  • Input: {test: "123", other: "key"}
  • Output: {test: {eq: "123"}, other: {eq: "key"}}

Parameters

NameTypeDescription
dataObjectThe object for which to wrap the values in (string) filters

Returns

Object

The filter object

Defined in

gropius-login-service/backend/src/backend-services/ims-user-finding.service.ts:177