mirror of
https://github.com/actix/examples
synced 2025-06-27 01:27:43 +02:00
restructure folders
This commit is contained in:
31
auth/simple-auth-server/static/index.html
Normal file
31
auth/simple-auth-server/static/index.html
Normal file
@ -0,0 +1,31 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
<title>Actix Web - Auth App</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<link rel="stylesheet" type="text/css" media="screen" href="main.css" />
|
||||
<script src="main.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div class="login">
|
||||
<h1>Email Invitation</h1>
|
||||
|
||||
<p>Please enter your email receive Invitation</p>
|
||||
<input class="field" type="text" placeholder="email" id="email" /> <br />
|
||||
<input class="btn" type="submit" value="Send Email" onclick="sendVerificationEmail()" />
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
<script>
|
||||
function sendVerificationEmail() {
|
||||
let email = document.querySelector('#email');
|
||||
|
||||
post('api/invitation', { email: email.value }).then(data => {
|
||||
alert('Please check your email.');
|
||||
email.value = '';
|
||||
console.error(data);
|
||||
});
|
||||
}
|
||||
</script>
|
37
auth/simple-auth-server/static/main.css
Normal file
37
auth/simple-auth-server/static/main.css
Normal file
@ -0,0 +1,37 @@
|
||||
/* CSSTerm.com Easy CSS login form */
|
||||
|
||||
.login {
|
||||
width:600px;
|
||||
margin:auto;
|
||||
border:1px #CCC solid;
|
||||
padding:0px 30px;
|
||||
background-color: #3b6caf;
|
||||
color:#FFF;
|
||||
}
|
||||
|
||||
.field {
|
||||
background: #1e4f8a;
|
||||
border:1px #03306b solid;
|
||||
padding:10px;
|
||||
margin:5px 25px;
|
||||
width:215px;
|
||||
color:#FFF;
|
||||
}
|
||||
|
||||
.login h1, p, .chbox, .btn {
|
||||
margin-left:25px;
|
||||
color:#fff;
|
||||
}
|
||||
|
||||
.btn {
|
||||
background-color: #00CCFF;
|
||||
border:1px #03306b solid;
|
||||
padding:10px 30px;
|
||||
font-weight:bold;
|
||||
margin:25px 25px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.forgot {
|
||||
color:#fff;
|
||||
}
|
19
auth/simple-auth-server/static/main.js
Normal file
19
auth/simple-auth-server/static/main.js
Normal file
@ -0,0 +1,19 @@
|
||||
function post(url = ``, data = {}) {
|
||||
// Default options are marked with *
|
||||
return fetch(url, {
|
||||
method: 'POST', // *GET, POST, PUT, DELETE, etc.
|
||||
mode: 'cors', // no-cors, cors, *same-origin
|
||||
cache: 'no-cache', // *default, no-cache, reload, force-cache, only-if-cached
|
||||
headers: {
|
||||
'Content-Type': 'application/json; charset=utf-8',
|
||||
},
|
||||
redirect: 'follow', // manual, *follow, error
|
||||
referrer: 'no-referrer', // no-referrer, *client
|
||||
body: JSON.stringify(data), // body data type must match "Content-Type" header
|
||||
}).then(response => response.json()); // parses response to JSON
|
||||
}
|
||||
|
||||
// window.addEventListener('load', function() {
|
||||
// console.log('All assets are loaded');
|
||||
// console.log(getUrlVars());
|
||||
// });
|
44
auth/simple-auth-server/static/register.html
Normal file
44
auth/simple-auth-server/static/register.html
Normal file
@ -0,0 +1,44 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
<title>Actix Web - Auth App</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<link rel="stylesheet" type="text/css" media="screen" href="main.css" />
|
||||
<script src="main.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div class="login">
|
||||
<h1>Register Account</h1>
|
||||
|
||||
<p>Please enter your email and new password</p>
|
||||
<input class="field" type="text" placeholder="email" id="email" />
|
||||
<input class="field" type="password" placeholder="Password" id="password" />
|
||||
<input class="btn" type="submit" value="Register" onclick="register()" />
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
<script>
|
||||
function getUrlVars() {
|
||||
var vars = {};
|
||||
var parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m, key, value) {
|
||||
vars[key] = value;
|
||||
});
|
||||
return vars;
|
||||
}
|
||||
function register() {
|
||||
let password = document.querySelector('#password');
|
||||
let invitation_id = getUrlVars().id;
|
||||
|
||||
post('api/register/' + invitation_id, { password: password.value }).then(data => {
|
||||
password.value = '';
|
||||
console.error(data);
|
||||
});
|
||||
}
|
||||
window.addEventListener('load', function() {
|
||||
let email = document.querySelector('#email');
|
||||
email.value = getUrlVars().email;
|
||||
console.log(getUrlVars());
|
||||
});
|
||||
</script>
|
Reference in New Issue
Block a user