45 lines
No EOL
1.7 KiB
Handlebars
45 lines
No EOL
1.7 KiB
Handlebars
|
|
<form id="channel-login-form">
|
|
<div class="row row--wide">
|
|
<div class="column column--3">
|
|
<label class="label" for="login-channel-name">Name:</label>
|
|
</div><div class="column column--4">
|
|
<div id="login-error-display-element" class="info-message info-message--failure"></div>
|
|
<div class="input-text--primary">
|
|
<span>@</span>
|
|
<input type="text" name="login-channel-name" id="login-channel-name" class="input-text" placeholder="" value="">
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="row row--wide">
|
|
<div class="column column--3">
|
|
<label class="label" for="login-channel-password" >Password:</label>
|
|
</div><div class="column column--4">
|
|
<input type="password" name="login-channel-password" id="login-channel-password" class="input-text input-text--primary" placeholder="" value="">
|
|
</div>
|
|
</div>
|
|
<div class="row row--wide">
|
|
<button onclick="loginToChannel(event)">Login</button>
|
|
</div>
|
|
</form>
|
|
|
|
|
|
<script type="text/javascript">
|
|
function loginToChannel (event) {
|
|
const channelName = document.getElementById('login-channel-name').value;
|
|
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> |