Created
December 7, 2021 07:59
-
-
Save hieptl/ee3d3ba2231885399ecd0b6ab11cba21 to your computer and use it in GitHub Desktop.
login.js - login cometchat - ZocDoc Clone
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const loginCometChat = async (id) => { | |
| if (!id) { | |
| return; | |
| } | |
| try { | |
| const user = await cometChat.login(id, `${cometChatConfig.cometChatAuthKey}`); | |
| if (user) { | |
| const authenticatedUser = await getUser(id); | |
| if (authenticatedUser) { | |
| AsyncStorage.setItem('auth', JSON.stringify(authenticatedUser)); | |
| setUser(authenticatedUser); | |
| navigation.navigate('Home'); | |
| } else { | |
| setIsLoading(false); | |
| showMessage('Info', 'Cannot load the authenticated information, please try again'); | |
| } | |
| } else { | |
| setIsLoading(false); | |
| showMessage('Error', 'Your username or password is not correct'); | |
| } | |
| } catch (error) { | |
| setIsLoading(false); | |
| showMessage('Error', 'Your username or password is not correct'); | |
| } | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment