spee.ch/views/partials/channelLogin.handlebars

35 lines
1.4 KiB
Handlebars
Raw Normal View History

2017-09-21 01:04:58 +02:00
<p>
<form id="channel-login-form">
<div id="login-error-display-element" class="info-message info-message--failure"></div>
<div>
<label for="login-channel-name">Channel Name: </label>
@<input type="text" name="login-channel-name" id="login-channel-name" class="input-text input-text--primary" placeholder="" value="">
</div>
<div>
<label for="login-channel-password" >Password: </label>
<input type="password" name="login-channel-password" id="login-channel-password" class="input-text input-text--primary" placeholder="" value="">
</div>
</form>
</p>
<button onclick="loginToChannel(event)">Login</button>
<script type="text/javascript">
function loginToChannel (event) {
2017-09-26 07:49:27 +02:00
const channelName = document.getElementById('login-channel-name').value;
2017-09-21 01:04:58 +02:00
const password = document.getElementById('login-channel-password').value;
const loginErrorDisplayElement = document.getElementById('login-error-display-element');
// prevent default
event.preventDefault()
// send request
sendAuthRequest(channelName, password, '/login')
.then(() => {
console.log('login success');
window.location.href = '/';
})
.catch(error => {
showError(loginErrorDisplayElement, error);
console.log('login failure:', error);
})
}
</script>