ChatNet can be easily integrated with any other script that has a user authentication system by using Single Sign-On (SSO). This allows ChatNet to work smoothly alongside your existing user database, giving users a seamless experience.
By enabling SSO with ChatNet, your users can chat or join chat rooms without needing to re-register or log in again within ChatNet.
When a user logs in, details such as username, first name, last name, and avatar are automatically carried over to ChatNet.
Enable SSO in ChatNet
In your ChatNet Admin Dashboard, go to Integrations (SSO) in the sidebar. Complete the form by entering the required information, such as your domain and any custom details.
Embed the SSO Script on Your Website
Copy the following script and paste it into the code of your main website, preferably within the <head> or at the bottom of the <body> section:
<script type = 'text/javascript'> "use strict"; (function() { var ChatNetData = '{"chatnet_url":"https://demo4.chatnet.oncodes.com","email":"tony@oncodes.com","first_name":"Tony","last_name":"Stark","avatar_url":"https://www.gravatar.com/avatar/0a67ae61672d45b07f98311a8e676ffd","username":"tony"} '; window.cnUserData = JSON.parse(ChatNetData); var ocnw = document.createElement("script"); ocnw.type = "text/javascript"; ocnw.async = true; ocnw.src = cnUserData.chatnet_url + "/sso/js"; var el = document.getElementsByTagName("script")[0]; el.parentNode.insertBefore(ocnw, el); })(); </script>Update ChatNetData: Modify the ChatNetData variable to dynamically pass the currently logged-in user’s information:
This information will allow ChatNet to recognize the user, creating a new profile if needed or logging in the user automatically if their profile already exists.
Automatic User Login and Access
Once the script is set up and running on your site, it will send the logged-in user’s details to ChatNet. Users visiting ChatNet will be logged in automatically and have access to all their profile information within the chat.