Skip to content

Instantly share code, notes, and snippets.

@hieptl
Created December 7, 2021 07:59
Show Gist options
  • Select an option

  • Save hieptl/ee3d3ba2231885399ecd0b6ab11cba21 to your computer and use it in GitHub Desktop.

Select an option

Save hieptl/ee3d3ba2231885399ecd0b6ab11cba21 to your computer and use it in GitHub Desktop.
login.js - login cometchat - ZocDoc Clone
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