Skip to content

Commit

Permalink
Test consolidated Link Identities page
Browse files Browse the repository at this point in the history
  • Loading branch information
cbullinger committed May 14, 2024
1 parent b59b8d5 commit 56fd7ed
Show file tree
Hide file tree
Showing 15 changed files with 257 additions and 25 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Linking credentials is not currently supported in the C++ SDK.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
You can link identities using the
:dotnet-sdk:`LinkCredentialsAsync() <reference/Realms.Sync.User.html#Realms_Sync_User_LinkCredentialsAsync_Realms_Sync_Credentials_>`.
This links authentication providers to a logged-in
:dotnet-sdk:`User <reference/Realms.Sync.User.html>` object.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
In the following example, we link a :ref:`Google authentication
<google-authentication>` provider to a logged-in user:

.. literalinclude:: /examples/generated/dotnet/UserLinkExamples.snippet.link2.cs
:language: csharp

In the following email/password example, we register the new :ref:`email/password
<email-password-authentication>` user before linking:
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
You can link identities by passing the :flutter-sdk:`Credentials <realm/Credentials-class.html>`
that you want to link to :flutter-sdk:`User.linkCredentials()
<realm/User/linkCredentials.html>`.

.. literalinclude:: /examples/generated/flutter/authenticate_users_test.snippet.link-user-credentials.dart
:language: dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
In the following example, we register the new :ref:`email/password
<email-password-authentication>` user before linking:
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
You link identities using
:java-sdk:`linkCredentials() <io/realm/mongodb/User.html#linkCredentials-io.realm.mongodb.Credentials->`
or :java-sdk:`linkCredentialsAsync()
<io/realm/mongodb/User.html#linkCredentialsAsync-io.realm.mongodb.Credentials-io.realm.mongodb.App.Callback->`.
This links the new user identity to the logged-in :java-sdk:`User
<io/realm/mongodb/User.html>` object.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
You can link identities using :js-sdk:`linkCredentials()
<classes/User.html#linkCredentials>`. This links authentication providers
to a logged-in ``User`` object.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
You link identities using
:kotlin-sync-sdk:`linkCredentials <-user/link-credentials.html>`.
This links the new user identity to the logged-in
:kotlin-sync-sdk:`User <{-user/index.html>`.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
You can link identities using ``linkUser(credentials:Credentials)``. This
links authentication providers to a logged-in ``User`` object.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
You can link identities using ``linkUser(credentials:Credentials)``. This
links authentication providers to a logged-in ``User`` object.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
You can link identities using :js-sdk:`linkCredentials()
<classes/User.html#linkCredentials>`. This links authentication providers
to a logged-in ``User`` object.
24 changes: 0 additions & 24 deletions source/includes/link-user-identities.rst

This file was deleted.

14 changes: 14 additions & 0 deletions source/includes/sdk-examples/users/link-user-identities-async.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
.. _sdk-async-await-link-user-identities:

Async/Await: Swift SDK
----------------------

.. versionadded:: 10.16.0

The Swift SDK provides an :swift-sdk:`async/await version of
User.linkUser<Extensions/User.html#/s:So7RLMUserC10RealmSwiftE8linkUser11credentials7Combine6FutureCyABs5Error_pGAC11CredentialsO_tF>`.

.. literalinclude:: /examples/generated/code/start/MultipleUsers.snippet.async-link-identity.swift
:language: swift

.. include:: /includes/swift-async-await-support.rst
59 changes: 59 additions & 0 deletions source/includes/sdk-examples/users/link-user-identities.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
.. tabs-drivers::

tabs:
- id: cpp
content: |

.. literalinclude:: /examples/MissingPlaceholders/api.cpp
:language: cpp

- id: csharp
content: |

.. literalinclude:: /examples/generated/dotnet/UserLinkExamples.snippet.link.cs
:language: csharp

- id: dart
content: |

.. literalinclude:: /examples/generated/flutter/authenticate_users_test.snippet.link-user-credentials-example.dart
:language: dart

- id: java
content: |

.. literalinclude:: /examples/generated/java/sync/LinkUserIdentitiesTest.snippet.link-users.java
:language: java

- id: javascript
content: |

.. literalinclude:: /examples/generated/code/start/link-identities.snippet.link-identities.js
:language: javascript
:emphasize-lines: 6

- id: kotlin
content: |

.. literalinclude:: /examples/generated/kotlin/AuthenticationTest.snippet.link-credentials.kt
:language: kotlin

- id: objectivec
content: |

.. literalinclude:: /examples/generated/code/start/MultipleUsers.snippet.link-identity-objc.m
:language: objectivec

- id: swift
content: |

.. literalinclude:: /examples/generated/code/start/MultipleUsers.snippet.link-identity.swift
:language: swift

- id: typescript
content: |

.. literalinclude:: /examples/generated/code/start/link-identities.snippet.link-identities.ts
:language: typescript
:emphasize-lines: 10

144 changes: 143 additions & 1 deletion source/sdk/users/link-user-identities.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,152 @@
Link User Identities
====================

.. meta::
:description: Link multiple App Services user credentials to a single user identity.
:keywords: code example

.. .. facet::
.. :name: programming_language
.. :values: [all of the SDKs?]

.. facet::
:name: genre
:values: tutorial

.. contents:: On this page
:local:
:backlinks: none
:depth: 2
:class: singlecol

Placeholder page for information about linking user identities.
.. tabs-selector:: drivers

Atlas Device SDK provides many authentication providers
to log users into your app. Each provider creates a unique user identity.
Atlas Device SDK lets you merge multiple credentials into one user identity.
For more information, refer to the :ref:`authentication-providers` documentation.

For example, consider an application that offers anonymous login, which allows
users to explore the app without registering. If a user wants to continue using
the application, they can create a permanent account by using another
authentication provider. The SDK creates a new ``User`` object, and the app can
link that new identity with the current user.

Note the following when linking user identities:

- Credentials must be linked *before* logging a user in. Once credentials are
used to login a user, you cannot link that credential anymore.
- You cannot link multiple email/password credentials together.

.. important:: Email/password Authentication Must Be Registered Before Linking

Users that authenticate with :ref:`email/password
<email-password-authentication>` *must* register the new email/password
before it can be linked to an existing user. This is only required for
email/password authentication.

There may be additional steps before the new account is created and can be
linked, depending on how you have configured email/password authentication
(for example, confirming the email address).

.. tabs-drivers::

.. tab::
:tabid: cpp

.. include:: /includes/api-details/cpp/users/link-user-identities-not-supported.rst

.. tab::
:tabid: csharp

.. include:: /includes/api-details/csharp/users/link-user-identities-description.rst

.. tab::
:tabid: dart

.. include:: /includes/api-details/dart/users/link-user-identities-description.rst

.. tab::
:tabid: java

.. include:: /includes/api-details/java/users/link-user-identities-description.rst

.. tab::
:tabid: javascript

.. include:: /includes/api-details/javascript/users/link-user-identities-description.rst

.. tab::
:tabid: kotlin

.. include:: /includes/api-details/kotlin/users/link-user-identities-description.rst

.. tab::
:tabid: objectivec

.. include:: /includes/api-details/objectivec/users/link-user-identities-description.rst

.. tab::
:tabid: swift

.. include:: /includes/api-details/swift/users/link-user-identities-description.rst

.. tab::
:tabid: typescript

.. include:: /includes/api-details/typescript/users/link-user-identities-description.rst

Link an Email/Password User
---------------------------

.. tabs-drivers::

.. tab::
:tabid: cpp

.. include:: /includes/api-details/cpp/users/link-user-identities-not-supported.rst

.. tab::
:tabid: csharp

.. include:: /includes/api-details/generic/users/link-user-identities-example.rst

.. tab::
:tabid: dart

.. include:: /includes/api-details/generic/users/link-user-identities-example.rst

.. tab::
:tabid: java

.. include:: /includes/api-details/generic/users/link-user-identities-example.rst

.. tab::
:tabid: javascript

.. include:: /includes/api-details/generic/users/link-user-identities-example.rst

.. tab::
:tabid: kotlin

.. include:: /includes/api-details/generic/users/link-user-identities-example.rst

.. tab::
:tabid: objectivec

.. include:: /includes/api-details/generic/users/link-user-identities-example.rst

.. tab::
:tabid: swift

.. include:: /includes/api-details/generic/users/link-user-identities-example.rst

.. tab::
:tabid: typescript

.. include:: /includes/api-details/generic/users/link-user-identities-example.rst

.. include:: /includes/sdk-examples/users/link-user-identities.rst

.. include:: /includes/sdk-examples/users/link-user-identities-async.rst

0 comments on commit 56fd7ed

Please sign in to comment.