Skip to content

Commit 6ffd8b5

Browse files
(DOCSP-39531): Consolidate Link User Identities page (#3350)
## Pull Request Info - SDK Docs Consolidation Jira ticket: https://jira.mongodb.org/browse/DOCSP-39531 Jira ticket: https://jira.mongodb.org/browse/DOCSP-37351 *Staged Page* - [Link User Identities](https://preview-mongodbdacharyc.gatsbyjs.io/realm/DOCSP-39531/sdk/users/link-user-identities/) *Page Source* Add links to every SDK's pages where you got the SDK-specific information: - [Flutter: Link User Identities](https://www.mongodb.com/docs/atlas/device-sdks/sdk/flutter/users/link-user-identities/) - [Java: Link User Identities](https://www.mongodb.com/docs/atlas/device-sdks/sdk/java/users/link-user-identities/) - [Kotlin: Link User Identities](https://www.mongodb.com/docs/atlas/device-sdks/sdk/kotlin/users/link-credentials/) - [.NET: Link User Identities](https://www.mongodb.com/docs/atlas/device-sdks/sdk/dotnet/manage-users/link-user-identities/) - [Node.js: Link User Identities](https://www.mongodb.com/docs/atlas/device-sdks/sdk/node/users/link-identities/) - [Swift: Link User Identities](https://www.mongodb.com/docs/atlas/device-sdks/sdk/swift/users/link-user-identities/) ### PR Author Checklist Before requesting a review for your PR, please check these items: - [x] Open the PR against the `feature-consolidated-sdk-docs` branch instead of `master` - [x] Tag the consolidated page for: - genre - meta.keywords - meta.description #### Naming - [x] Update Realm naming and the language around persistence layer/local/device per [this document](https://docs.google.com/document/d/126OczVxBWAwZ4P5ZsSM29WI3REvONEr1ald-mAwPtyQ/edit?usp=sharing) - [x] Include `.rst` files comply with [the naming guidelines](https://docs.google.com/document/d/1h8cr66zoEVeXytVfvDxlCSsUS5IZwvUQvfSCEXNMpek/edit#heading=h.ulh8b5f2hu9) #### Links and Refs - [x] Create new consolidated SDK ref targets starting with "_sdks-" for relevant sections - [x] Remove or update any SDK-specific refs to use the new consolidated SDK ref targets - [x] [Update any Kotlin API links](https://jira.mongodb.org/browse/DOCSP-32519) to use the new Kotlin SDK roles #### Content - [x] Shared code boxes have snippets or placeholders for all 9 languages - [x] API description sections have API details or a generic placeholder for all 9 languages - [x] Check related pages for relevant content to include - [x] Create a ticket for missing examples in each relevant SDK: Consolidation Gaps epic ### Reviewer Checklist As a reviewer, please check these items: - [x] Shared code example boxes contain language-specific snippets or placeholders for every language - [x] API reference details contain working API reference links or generic content - [x] Realm naming/language has been updated - [x] All relevant content from individual SDK pages is present on the consolidated page --------- Co-authored-by: Kyle Rollins <[email protected]>
1 parent 08af422 commit 6ffd8b5

10 files changed

+194
-30
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
You can link identities using the
2+
:dotnet-sdk:`LinkCredentialsAsync() <reference/Realms.Sync.User.html#Realms_Sync_User_LinkCredentialsAsync_Realms_Sync_Credentials_>`.
3+
This links the identity belonging to the credentials to the logged-in
4+
:dotnet-sdk:`User <reference/Realms.Sync.User.html>` object.
5+
6+
.. literalinclude:: /examples/generated/dotnet/UserLinkExamples.snippet.link.cs
7+
:language: csharp
8+
9+
In the example above, we must first register the new :ref:`email/password
10+
<email-password-authentication>` user before linking. If you are using any of
11+
the other :ref:`Auth Providers <authentication-providers>`, this step is
12+
unnecessary. The following example uses :ref:`Google authentication
13+
<google-authentication>` instead of EmailPassword.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
You can link identities by passing the :flutter-sdk:`Credentials <realm/Credentials-class.html>`
2+
that you want to link to :flutter-sdk:`User.linkCredentials() <realm/User/linkCredentials.html>`.
3+
4+
.. literalinclude:: /examples/generated/flutter/authenticate_users_test.snippet.link-user-credentials.dart
5+
:language: dart
6+
7+
In the example below, we register an anonymous user, then later register an
8+
email/password user and link the credentials.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
You link identities using
2+
:java-sdk:`linkCredentials() <io/realm/mongodb/User.html#linkCredentials(io.realm.mongodb.Credentials)>`
3+
or :java-sdk:`linkCredentialsAsync()
4+
<io/realm/mongodb/User.html#linkCredentialsAsync(io.realm.mongodb.Credentials,io.realm.mongodb.App.Callback)`.
5+
This links the new user identity to the logged-in :java-sdk:`User
6+
<io/realm/mongodb/User.html>` object.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2+
You can link identities using :js-sdk:`linkCredentials()
3+
<classes/User.html#linkCredentials>`. This links the identity that belongs
4+
to the credential to a logged-in ``User`` object.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
You link identities using
2+
:kotlin-sync-sdk:`linkCredentials <io.realm.kotlin.mongodb/-user/link-credentials.html>`.
3+
This links the identity belonging to the credential to the logged-in
4+
:kotlin-sync-sdk:`User <io.realm.kotlin.mongodb/-user/index.html>`.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
You can link identities using :objc-sdk:`-linkUserWithCredentials:completion:
2+
<Classes/RLMUser.html#/c:objc(cs)RLMUser(im)linkUserWithCredentials:completion:>`.
3+
This links the identity that belongs to the credential to a logged-in ``User``
4+
object.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
You can link identities using :swift-sdk:`linkUser(credentials:)
2+
<Extensions/User.html#/s:So7RLMUserC10RealmSwiftE8linkUser11credentials7Combine6FutureCyABs5Error_pGAC11CredentialsO_tF>`.
3+
This links the identity that belongs to the credential to a logged-in ``User``
4+
object.
5+
6+
.. literalinclude:: /examples/generated/code/start/MultipleUsers.snippet.link-identity.swift
7+
:language: swift
8+
9+
The SDK also provides an :swift-sdk:`async/await version of
10+
User.linkUser <Extensions/User.html#/s:So7RLMUserC10RealmSwiftE8linkUser11credentials7Combine6FutureCyABs5Error_pGAC11CredentialsO_tF>`.

source/includes/link-user-identities.rst

Lines changed: 0 additions & 24 deletions
This file was deleted.
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
.. tabs-drivers::
2+
3+
tabs:
4+
- id: csharp
5+
content: |
6+
7+
.. literalinclude:: /examples/generated/dotnet/UserLinkExamples.snippet.link2.cs
8+
:language: csharp
9+
10+
- id: dart
11+
content: |
12+
13+
.. literalinclude:: /examples/generated/flutter/authenticate_users_test.snippet.link-user-credentials-example.dart
14+
:language: dart
15+
16+
- id: java
17+
content: |
18+
19+
.. literalinclude:: /examples/generated/java/sync/LinkUserIdentitiesTest.snippet.link-users.java
20+
:language: java
21+
22+
- id: java-kotlin
23+
content: |
24+
25+
.. literalinclude:: /examples/generated/java/sync/LinkUserIdentitiesTest.snippet.link-users.kt
26+
:language: kotlin
27+
28+
- id: javascript
29+
content: |
30+
31+
.. literalinclude:: /examples/generated/code/start/link-identities.snippet.link-identities.js
32+
:language: javascript
33+
:emphasize-lines: 6
34+
35+
- id: kotlin
36+
content: |
37+
38+
.. literalinclude:: /examples/generated/kotlin/AuthenticationTest.snippet.link-credentials.kt
39+
:language: kotlin
40+
41+
- id: objectivec
42+
content: |
43+
44+
.. literalinclude:: /examples/generated/code/start/MultipleUsers.snippet.link-identity-objc.m
45+
:language: objectivec
46+
47+
- id: swift
48+
content: |
49+
50+
.. literalinclude:: /examples/generated/code/start/MultipleUsers.snippet.async-link-identity.swift
51+
:language: swift
52+
53+
- id: typescript
54+
content: |
55+
56+
.. literalinclude:: /examples/generated/code/start/link-identities.snippet.link-identities.ts
57+
:language: typescript
58+
:emphasize-lines: 10

source/sdk/users/link-user-identities.txt

Lines changed: 87 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,91 @@
44
Link User Identities
55
====================
66

7-
.. contents:: On this page
8-
:local:
9-
:backlinks: none
10-
:depth: 2
11-
:class: singlecol
7+
.. meta::
8+
:description: You can link user identities to associate multiple sets of credentials with the same user object.
9+
:keywords: Realm, Flutter SDK, Kotlin SDK, Java SDK, .NET SDK, Node.js SDK, Swift SDK, code example
1210

13-
Placeholder page for information about linking user identities.
11+
.. facet::
12+
:name: genre
13+
:values: reference
14+
15+
.. facet::
16+
:name: programming_language
17+
:values: csharp, dart, java, javascript/typescript, kotlin, objective-c, swift
18+
19+
.. tabs-selector:: drivers
20+
21+
Atlas Device SDK provides :ref:`many authentication providers
22+
<authentication-providers>` to log users into your app. Each provider has its
23+
own credentials that create a unique user identity. The SDK lets you merge
24+
multiple identities into a single user account.
25+
26+
User identities must be linked prior to logging a user in. Once the user is
27+
logged in, you cannot link the credential used to login to the user account.
28+
Also, you cannot link multiple email/password identities together.
29+
30+
Example
31+
-------
32+
33+
Consider an application that offers :ref:`anonymous login
34+
<anonymous-authentication>`, which allows users to explore the app without
35+
registering. If a user wants to continue using the application, they can
36+
create a permanent account with an authentication provider intended to
37+
persist user data over a longer period, such as email/password authentication.
38+
The SDK creates a new identity belonging to a new ``User`` object. The app can
39+
then link the new identity with the current user.
40+
41+
.. note::
42+
43+
Depending on how you have configured email/password authentication, there may
44+
be additional steps (confirming the email address, for example) before the
45+
new account is created and can be linked.
46+
47+
.. tabs-drivers::
48+
49+
.. tab::
50+
:tabid: csharp
51+
52+
.. include:: /includes/api-details/csharp/users/link-user-identities-example-description.rst
53+
54+
.. tab::
55+
:tabid: dart
56+
57+
.. include:: /includes/api-details/dart/users/link-user-identities-example-description.rst
58+
59+
.. tab::
60+
:tabid: java
61+
62+
.. include:: /includes/api-details/java/users/link-user-identities-example-description.rst
63+
64+
.. tab::
65+
:tabid: java-kotlin
66+
67+
.. include:: /includes/api-details/java/users/link-user-identities-example-description.rst
68+
69+
.. tab::
70+
:tabid: javascript
71+
72+
.. include:: /includes/api-details/javascript/users/link-user-identities-example-js-ts-description.rst
73+
74+
.. tab::
75+
:tabid: kotlin
76+
77+
.. include:: /includes/api-details/kotlin/users/link-user-identities-example-description.rst
78+
79+
.. tab::
80+
:tabid: objectivec
81+
82+
.. include:: /includes/api-details/objectivec/users/link-user-identities-example-description.rst
83+
84+
.. tab::
85+
:tabid: swift
86+
87+
.. include:: /includes/api-details/swift/users/link-user-identities-example-description.rst
88+
89+
.. tab::
90+
:tabid: typescript
91+
92+
.. include:: /includes/api-details/javascript/users/link-user-identities-example-js-ts-description.rst
93+
94+
.. include:: /includes/sdk-examples/users/link-user-identities-example.rst

0 commit comments

Comments
 (0)