Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
{
type: 'password',
name: 'password',
message: 'Password:',
validate: validator,
},
];
const answers = await inquirer.prompt(questions);
const data = {
username: answers.username,
password: answers.password,
};
let user = await UserManager.loginAsync('user-pass', data);
if (user) {
console.log(chalk.green(`\nSuccessfully logged in as ${user.nickname}!`));
return user;
} else {
throw new Error('Unexpected Error: No user returned from the Expo API');
}
}
if (val.trim() === '') {
return false;
}
return true;
},
});
}
const answers = await prompt(questions);
const data = {
username: username || answers.username,
password: password || answers.password,
};
let user = await UserManager.loginAsync('user-pass', data);
if (user) {
console.log(`\nSuccess. You are now logged in as ${chalk.green(user.username)}.`);
return user;
} else {
throw new Error('Unexpected Error: No user returned from the API');
}
}
async function githubAuthAsync(): Promise {
let user = await UserManager.loginAsync('github');
if (user) {
console.log(chalk.green(`\nSuccessfully logged in as ${user.nickname} with GitHub!`));
return user;
} else {
throw new Error('Unexpected Error: No user returned from the API');
}
}
_onSubmitLogin = (event) => {
event.preventDefault();
this.setState({isLoggingIn: true});
User.loginAsync({
username: this.state.username,
password: this._passwordInput.value,
}).then((user) => {
this.setState({errorMessage: null, isLoggingIn: false});
this.props.onLogin(user);
}, (err) => {
this.setState({errorMessage: err.message, isLoggingIn: false});
});
};