Created
October 18, 2021 13:59
-
-
Save hieptl/504da4ca9ee3ff1ebd85488ab999b9f8 to your computer and use it in GitHub Desktop.
Login.tsx - Log in to CometChat - Ionic Chat App
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
... | |
cometChat.login(firebaseUid, `${process.env.REACT_APP_COMETCHAT_AUTH_KEY}`).then( | |
(User: any) => { | |
// User loged in successfully. | |
// save authenticated user to local storage. | |
localStorage.setItem('auth', JSON.stringify(User)); | |
// save authenticated user to context. | |
setUser(User); | |
// hide loading. | |
setIsLoading(false); | |
// redirect to home page. | |
history.push('/'); | |
}, (error: any) => { | |
console.log(error); | |
// User login failed, check error and take appropriate action. | |
setIsLoading(false); | |
alert(`Your user's name or password is not correct`); | |
} | |
); | |
... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment