Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions docs.json
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,12 @@
"pages": [
"fundamentals/user-roles-and-permissions"
]
},
{
"group": "Guides",
"pages": [
"fundamentals/user-auth"
]
}
]
},
Expand Down
56 changes: 56 additions & 0 deletions fundamentals/user-auth.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
---
title: "Authentication and User Management"
description: "Create users, issue auth tokens, and log users into CometChat."
---

## Create and Log In a User

### Guide details

This guide provides a step-by-step guide on creating and logging in a user using the CometChat platform with authentication using the Authentication Token. Additionally, you will need to make sure you have initialized CometChat in your app prior to logging in the user.

### Introduction

To log in a user, they must first be registered on the CometChat server. For first-time logins, the user needs to be created in CometChat. After this initial creation, we can generate an authentication token for the user.

This authentication token, created via the CometChat API, will be used on the front-end to log the user into the **CometChat UI Kit, SDK, or Widget**.

Once the user is successfully logged into CometChat, we can proceed to request or post any necessary data for the app.

## Prerequisites

* CometChat App (You can create one via the [CometChat Dashboard](https://app.cometchat.com/apps)).
* CometChat UI Kit or SDK (Custom Widget as well).
* Your application: Front-end and Back-end / Server Side.

## Create Chat User in CometChat

1. Handle the user creation endpoint in your application.
2. Add the user to your database.
3. Invoke the [CometChat API endpoint to create a user](https://api-explorer.cometchat.com/reference/creates-user).

* Optionally, pass a parameter to generate an authentication token for this user.

4. CometChat will respond with the authentication token to your server.
5. Your server will send the successful user creation response to your front-end application.
6. Utilize the CometChat auth token to log the user into the [CometChat SDK / UI Kit](https://www.cometchat.com/docs/javascript-chat-sdk/authentication#login-using-auth-token), or [Widget](/widget/html/integration#3-backend-created-user-auth-token-login).

<Frame>
<img src="/images/create-chat-user.png" alt="CometChat - Create Chat User" />
</Frame>

## Log In an Existing User

1. Authenticate the user within your application.
2. Your API will then request a CometChat auth token for the user. You can call the [create auth token API endpoint](https://api-explorer.cometchat.com/reference/create-authtoken) to create a new one.
3. Your server responds with the successful retrieval of the CometChat auth token to your front-end application.
4. Utilize the CometChat auth token to log the user into the [CometChat SDK / UI Kit](https://www.cometchat.com/docs/javascript-chat-sdk/authentication#login-using-auth-token),
5. If you’re using the **Widget Builder**, refer to the documentation on **[auth token–based user login](/widget/html/integration#3-backend-created-user-auth-token-login)**.

<Frame>
<img src="/images/log-in-chat-user.png" alt="CometChat - Logging On a User" />
</Frame>

## Migrate Existing Users to CometChat

If you need to migrate the existing users, refer to the [Data Import Guide](https://www.cometchat.com/docs/rest-api/data-import)
Binary file added images/create-chat-user.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/log-in-chat-user.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion notifications/android-push-notifications.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ description: "Setup FCM and CometChat for message and call push notifications on
---

<Card
title="Kotlin Sample App"
title="Android UI Kit Sample App (Kotlin)"
icon="github"
href="https://github.com/cometchat/cometchat-uikit-android/tree/v5/sample-app-kotlin%2Bpush-notification"
>
Expand Down
2 changes: 1 addition & 1 deletion notifications/ios-apns-push-notifications.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ description: "Implement APNs push notifications with CometChat UIKit for iOS, in
---

<Card
title="iOS UIKit Sample App"
title="iOS UI Kit Sample App"
icon="github"
href="https://github.com/cometchat/cometchat-uikit-ios/tree/v5/SampleAppPushNotificationAPNs/Push%20Notification%20%2B%20VoIP"
>
Expand Down
2 changes: 1 addition & 1 deletion notifications/ios-fcm-push-notifications.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ description: "Guide to integrating Firebase Cloud Messaging (FCM) push notificat
<Note>FCM doesn't support VoIP pushes; use APNs + PushKit for VoIP calls.</Note>

<Card
title="iOS UIKit Sample App"
title="iOS UI Kit Sample App"
icon="github"
href="https://github.com/cometchat/cometchat-uikit-ios/tree/v5/SampleAppPushNotificationAPNs/Push%20Notification%20%2B%20VoIP"
>
Expand Down