blob: 2f24053ae1ed380003606e0b83dc06b38bb6a838 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
'use strict';
const config = require('../config.js');
const BaseView = require('./base_view.js');
class LoginView extends BaseView {
constructor() {
super();
this.template = this.getTemplate('login-template');
}
render(options) {
this.showView(this.template());
const form = this.contentHolder.querySelector('form');
this.decorateValidator(form);
const userNameField = document.getElementById('user-name');
const passwordField = document.getElementById('user-password');
const rememberUserField = document.getElementById('remember-user');
userNameField.setAttribute('pattern', config.service.userNameRegex);
passwordField.setAttribute('pattern', config.service.passwordRegex);
form.addEventListener('submit', e => {
e.preventDefault();
this.clearMessages();
this.disableForm(form);
options
.login(
userNameField.value,
passwordField.value,
rememberUserField.checked)
.then(() => {
this.enableForm(form);
})
.catch(errorMessage => {
this.enableForm(form);
this.notifyError(errorMessage);
});
});
}
}
module.exports = LoginView;
|
© 2015 - 2026 Jakob L. Kreuze