Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return new Promise((resolve) => {
const farm = farmOS(url, username, password);
farm.authenticate()
.then((tokenResponse) => {
// Save our username, password & token to the persistant store
storage.setItem('host', url);
storage.setItem('username', username);
storage.setItem('password', password);
storage.setItem('token', tokenResponse);
// Go back 1 page, or reroute to home page
if (window.history.length > 1) {
window.history.back();
resolve();
return;
}
router.push('/');
resolve();
.catch(() => {
// Check if the login attempt failed b/c it's http://, not https://
const noSslUrl = `http://${payload.farmosUrl}`;
const noSslfarm = farmOS(noSslUrl, username, password);
noSslfarm.authenticate() // eslint-disable-line
.then((tokenResponse) => {
// Save our username, password & token to the persistant store
storage.setItem('host', noSslUrl);
storage.setItem('username', username);
storage.setItem('password', password);
storage.setItem('token', tokenResponse);
// Go back 1 page, or reroute to home page
if (window.history.length > 1) {
window.history.back();
resolve();
return;
}
router.push('/');
resolve();
const lazyFarm = () => {
const host = localStorage.getItem('host');
const user = localStorage.getItem('username');
const password = localStorage.getItem('password');
return farmOS(host, user, password);
};
const farm = () => {
const host = localStorage.getItem('host');
const user = localStorage.getItem('username');
const password = localStorage.getItem('password');
return farmOS(host, user, password);
};
const lazyFarm = () => {
const host = localStorage.getItem('host');
const user = localStorage.getItem('username');
const password = localStorage.getItem('password');
return farmOS(host, user, password);
};
const farm = () => {
const host = localStorage.getItem('host');
const user = localStorage.getItem('username');
const password = localStorage.getItem('password');
return farmOS(host, user, password);
};