121 lines
3.6 KiB
Plaintext
121 lines
3.6 KiB
Plaintext
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<meta charset="utf-8" />
|
|
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height" />
|
|
|
|
<title>Login to <%= name %></title>
|
|
|
|
<link id="favicon" type="image/png" rel="icon" href="/api/v1/cloudron/avatar">
|
|
<link rel="apple-touch-icon" href="/api/v1/cloudron/avatar">
|
|
<link rel="icon" href="/api/v1/cloudron/avatar">
|
|
|
|
<!-- Theme CSS -->
|
|
<link type="text/css" rel="stylesheet" href="/theme.css">
|
|
|
|
<!-- Fontawesome -->
|
|
<link type="text/css" rel="stylesheet" href="/3rdparty/fontawesome/css/all.css"/>
|
|
|
|
<!-- Bootstrap Core JavaScript -->
|
|
<script type="text/javascript" src="/3rdparty/js/jquery.min.js"></script>
|
|
<script type="text/javascript" src="/3rdparty/js/bootstrap.min.js"></script>
|
|
|
|
<style>
|
|
|
|
.card {
|
|
padding: 20px;
|
|
margin-bottom: 0;
|
|
max-width: 620px;
|
|
min-height: 100%;
|
|
}
|
|
|
|
.avatar {
|
|
margin-top: 20px;
|
|
}
|
|
|
|
@media(min-width:620px) {
|
|
.card {
|
|
margin-bottom: 15px;
|
|
margin-top: 100px;
|
|
min-height: auto;
|
|
}
|
|
|
|
.avatar {
|
|
margin-top: -84px
|
|
}
|
|
}
|
|
|
|
</style>
|
|
|
|
</head>
|
|
<body>
|
|
|
|
<div class="layout-root">
|
|
<div class="layout-content">
|
|
<div class="card">
|
|
<div class="row">
|
|
<div class="col-md-12" style="text-align: center;">
|
|
<img width="128" height="128" class="avatar" src="<%= iconUrl %>"/>
|
|
<br/>
|
|
<h1><small>Login to</small> <%= name %></h1>
|
|
</div>
|
|
</div>
|
|
<br/>
|
|
<div class="row">
|
|
<div class="col-md-12">
|
|
<form id="loginForm">
|
|
<div class="form-group">
|
|
<label class="control-label" for="inputUsername">Username</label>
|
|
<input type="text" class="form-control" id="inputUsername" name="username" autofocus required>
|
|
</div>
|
|
<div class="form-group">
|
|
<label class="control-label" for="inputPassword">Password</label>
|
|
<input type="password" class="form-control" name="password" id="inputPassword" required password-reveal>
|
|
</div>
|
|
<div class="form-group">
|
|
<label class="control-label" for="inputTotpToken">2FA Token</label>
|
|
<input type="text" class="form-control" name="totpToken" id="inputTotpToken" value="">
|
|
</div>
|
|
<button class="btn btn-primary btn-outline pull-right" type="submit">Log in</button>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
|
|
document.getElementById('loginForm').addEventListener('submit', function (event) {
|
|
event.preventDefault();
|
|
|
|
var apiUrl = '<%= submitUrl %>';
|
|
console.log('submit', apiUrl);
|
|
|
|
var body = {
|
|
username: document.getElementById('inputUsername').value,
|
|
password: document.getElementById('inputPassword').value,
|
|
totpToken: document.getElementById('inputTotpToken').value
|
|
};
|
|
|
|
fetch(apiUrl, {
|
|
method: 'POST',
|
|
body: JSON.stringify(body),
|
|
headers: { 'Content-type': 'application/json; charset=UTF-8' }
|
|
}).then(function (response) {
|
|
if (response.ok) return response.json();
|
|
return Promise.reject(response);
|
|
}).then(function (data) {
|
|
if (data.redirectTo) window.location.href = data.redirectTo;
|
|
else console.log('login success but missing redirectTo in data:', data);
|
|
}).catch(function (error) {
|
|
if (error.status === 401) document.getElementById('inputPassword').value = ''
|
|
console.warn('Something went wrong.', error);
|
|
});
|
|
});
|
|
|
|
</script>
|
|
|
|
</body>
|
|
</html>
|