Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
doLogin(login, password, cred) {
if (this.tinode.isAuthenticated()) {
// Already logged in. Go to default screen.
HashNavigation.navigateTo('');
return;
}
// Sanitize and package credentail.
cred = Tinode.credential(cred);
// Try to login with login/password. If they are not available, try token. If no token, ask for login/password.
let promise = null;
let token = this.tinode.getAuthToken();
if (login && password) {
this.setState({password: null});
promise = this.tinode.loginBasic(login, password, cred);
} else if (token) {
promise = this.tinode.loginToken(token.token, cred);
}
if (promise) {
promise.then((ctrl) => {
if (ctrl.code >= 300 && ctrl.text === 'validate credentials') {
this.setState({loadSpinnerVisible: false});
if (cred) {
this.handleError("Code does not match", 'warn');
.then(() => {
return this.tinode.createAccountBasic(login_, password_,
{public: public_, tags: tags_, cred: Tinode.credential(cred_)});
}).then((ctrl) => {
if (ctrl.code >= 300 && ctrl.text == 'validate credentials') {