Support Topics Documentation Slack YouTube Blog

How to handle the same user login

I need some guiding here :slight_smile:
in my mobile app im login the users with cloud code (codeless) and that is working fine. however i find myself now needing to use the JS library login for real time messaging.

now my codeless login is using sms. so im not using any user defined password to login the user.
what i mean is every time the user want to login i send him sms containing the new password.
after successful login i put a random long password in the user password field so no one that know the sms can log in again using it.

so is there a way to notify the JS library that the user is logged in and have a token? or another way to log the user in the JS library if there is no password?

Hello @mohammad_altoiher

Once you received the user-token on the server (in Codeless) can you pass it to the client and then set it into the JS-SDK?

Regards, Vlad

Hey @vladimir-upirov
i have the user-token. how do i set it in JS-SDK?
this will fix my issue

try this one:

const user = {.... 'user-token': 'YOUR_USER_TOKEN' }

Backendless.Users.setLocalCurrentUser(user)
1 Like

Working! thank you!