spee.ch/public/assets/js/loginFunctions.js

22 lines
899 B
JavaScript
Raw Normal View History

function loginToChannel (event) {
const userName = document.getElementById('channel-login-name-input').value;
const password = document.getElementById('channel-login-password-input').value;
// prevent default
event.preventDefault()
validationFunctions.validateNewChannelLogin(userName, password)
2017-10-12 14:37:25 -07:00
.then(() => {
return sendAuthRequest(userName, password, '/login')
})
.then(result => {
2018-01-05 16:47:55 -08:00
window.location = '/';
})
.catch(error => {
2017-10-10 16:51:07 -07:00
const loginErrorDisplayElement = document.getElementById('login-error-display-element');
2017-10-12 14:37:25 -07:00
if (error.name){
validationFunctions.showError(loginErrorDisplayElement, error.message);
2017-10-12 14:37:25 -07:00
} else {
validationFunctions.showError(loginErrorDisplayElement, 'There was an error logging into your channel');
2017-10-12 14:37:25 -07:00
}
})
}