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 23:37:25 +02:00
.then(() => {
return sendAuthRequest(userName, password, '/login')
})
.then(result => {
2018-01-06 01:47:55 +01:00
window.location = '/';
})
.catch(error => {
2017-10-11 01:51:07 +02:00
const loginErrorDisplayElement = document.getElementById('login-error-display-element');
2017-10-12 23:37:25 +02:00
if (error.name){
validationFunctions.showError(loginErrorDisplayElement, error.message);
2017-10-12 23:37:25 +02:00
} else {
validationFunctions.showError(loginErrorDisplayElement, 'There was an error logging into your channel');
2017-10-12 23:37:25 +02:00
}
})
}