Newer
Older
<!DOCTYPE html>
<html>
<head>
{% for src in js %}
<script type="text/javascript" src="{{ src }}"></script>
{% endfor %}
{% for src in css %}
<link type="text/css" rel="stylesheet" href="{{ src }}">
{% endfor %}
<link type="text/css" rel="stylesheet" href="{{ url_for( 'send_app_files', path = 'app.css' ) }}">
<script type="text/javascript">
baseurl = "{{ baseurl }}";
</script>
</head>
<body>
<div class="icnml_login">
<h1 style="margin-bottom: 0px">ICNML</h1>
<h4 style="margin-top: 0px">International Close Non-Matches Library</h4>
<div class="ui-widget-header ui-corner-top icnml_login_top">Please enter your login information</div>
<div class="ui-widget-content ui-corner-bottom icnml_login_form">
<div id="icnml_login_field" class="icnml_login_field">
<div style="text-align: right;">
<label for="username">Username</label>
</div>
<div>
<input id="username" name="username" type="text" style="width: 100%">
<div style="text-align: right;">
<label for="password">Password</label>
</div>
<div>
<input id="password" name="password" type="password" style="width: 100%">
<div id="icnml_login_error"></div>
<div class="icnml_login_button">
<a class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" id="login_button" role="button" aria-disabled="false">
<span class="ui-button-text">Login</span>
</a>
</div>
</div>
{
$( '#icnml_login_error' ).html( '' );
$( '#login_button > span' ).text( "Please wait..." );
var username = $( '#username' ).val();
var password = $( '#password' ).val();
$.ajax( {
url: '{{ url_for( 'do_login' ) }}',
dataType: 'json',
method: 'POST',
data: {
},
success: function( data )
{
if( ! data.error )
{
if( data.logged )
{
location.href = "{{ url_for( 'home' ) }}";
} else if( data.must_use_totp === true ) {
build_totp_form();
if( typeof data.message !== 'undefined' )
var message = data.message;
else
var message = 'Invalid username/password';
$( '#icnml_login_error' ).text( message );
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
var login_action_totp = function()
{
$( '#icnml_login_error' ).html( '' );
$( '#login_button > span' ).text( "Please wait..." );
$.ajax( {
url: '{{ url_for( 'do_login' ) }}',
dataType: 'json',
method: 'POST',
data: {
totp: $( '#totp' ).val()
},
success: function( data )
{
if( ! data.error )
{
if( data.logged )
{
location.href = "{{ url_for( 'home' ) }}";
} else {
if( typeof data.message !== 'undefined' )
$( '#icnml_login_error' ).text( data.message );
}
}
}
} );
}
var build_totp_form = function()
{
$( '#icnml_login_error' ).html( '' );
$( '#icnml_login_field' ).html( '' );
$( '#icnml_login_field' )
.append(
$( '<div />' )
.text( "TOTP" )
.css( "text-align", "right" )
)
.append(
$( '<div />' ).append(
$( '<input/>' )
.attr( "id", "totp" )
.attr( "name", "totp" )
.css( "width", "100%" )
.on( 'keyup', function( event )
{
if( event.keyCode == 13 )
{
event.preventDefault();
login_action_totp();
}
} )
)
);
$( '#totp' ).focus();
}
/* Events binding */
$( '#username' ).on( 'keyup', function( event )
{
if( event.keyCode == 13 )
{
event.preventDefault();
}
} );
$( '#password' ).on( 'keyup', function( event )
{
if( event.keyCode == 13 )
{
event.preventDefault();
$( '#login_button' ).on( 'click', login_action_password );
$( '#username' ).focus();