UNPKG

@loopback/docs

Version:
39 lines (24 loc) 1.36 kB
--- lang: en title: 'API docs: authentication.useridentityservice.findorcreateuser' keywords: LoopBack 4.0, LoopBack 4 sidebar: lb4_sidebar editurl: https://github.com/strongloop/loopback-next/tree/master/packages/authentication permalink: /doc/en/lb4/apidocs.authentication.useridentityservice.findorcreateuser.html --- <!-- Do not edit this file. It is automatically generated by API Documenter. --> [Home](./index.md) &gt; [@loopback/authentication](./authentication.md) &gt; [UserIdentityService](./authentication.useridentityservice.md) &gt; [findOrCreateUser](./authentication.useridentityservice.findorcreateuser.md) ## UserIdentityService.findOrCreateUser() method find or create a local user using a profile from an external source <b>Signature:</b> ```typescript findOrCreateUser(userIdentity: I): Promise<U>; ``` ## Parameters | Parameter | Type | Description | | --- | --- | --- | | userIdentity | <code>I</code> | | <b>Returns:</b> `Promise<U>` ## Example async findOrCreateUser( ldapUser: LDAPUserIdentity, ): Promise<UserProfile> { let user: UserProfile = await this.userRepository.findOrCreate(<!-- -->{ name: ldapUser.cn, username: ldapUser.mail, roles: \_.map(ldapUser.memberof\['ou=roles,dc=mydomain,o=myOrg'\], 'cn') }<!-- -->); await this.linkExternalProfile(user.id, ldapUser); return user; }