Pour tout problème contactez-nous par mail : support@froggit.fr | La FAQ :grey_question: | Rejoignez-nous sur le Chat :speech_balloon:

Skip to content
Snippets Groups Projects
Commit ee9597e8 authored by Pierre Jarriges's avatar Pierre Jarriges
Browse files

wip admin web view

parent 6c5b376a
No related branches found
No related tags found
No related merge requests found
*+* {
box-sizing: border-box;
font-family: Lato, Arial, Helvetica, sans-serif
}
body {
margin: 0;
}
#admin-login-form {
display: grid;
width: 300px;
gap: 20px;
}
#admin-login-form input {
padding: 4px;
}
\ No newline at end of file
document.getElementById('admin-login-form').onsubmit = function (e) {
e.preventDefault();
fetch('/admin/login', { method: 'POST', body: new URLSearchParams(new FormData(e.target)) }).then(res => {
if (res.status >= 200 && res.status < 400) {
console.log(res)
window.location = '/admin/auth/workspace';
}
}).catch(err => console.log(err))
}
\ No newline at end of file
document.getElementById('admin-login-form').onsubmit = function (e) {
e.preventDefault();
fetch('/admin/login', { method: 'POST', body: new URLSearchParams(new FormData(e.target)) }).then(res => {
if (res.status >= 200 && res.status < 400) {
console.log(res)
window.location = '/admin/auth/workspace';
}
}).catch(err => console.log(err))
}
\ No newline at end of file
console.log("Hello JS")
\ No newline at end of file
......@@ -67,7 +67,7 @@ where
if let false = authenticate(&mut req, &token).await {
return Ok(req.into_response(
actix_web::HttpResponse::Unauthorized()
.body("Error 401 - Unauthorized") // TODO a proper 401 view ?
.body("<html><body>Error 401 - Unauthorized - Please go to <a href='/admin/login'>login page</a>.</body></html>") // TODO a proper 401 view ?
.map_into_right_body(),
));
}
......
......@@ -8,6 +8,7 @@ use actix_web::{
#[get("/workspace")]
async fn admin_workspace() -> impl Responder {
// TODO return admin static web view with js application
actix_web::HttpResponse::Ok().body("Welcome Admin")
}
......@@ -66,26 +67,33 @@ async fn admin_authenticate(
#[get("/login")]
pub async fn admin_login() -> impl Responder {
// TODO real HTML doc - create a module with admin views and a js file to load.
// TODO create a module with built-in admin static views
HttpResponse::Ok().body(
"
<form id='admin-login-form'>
<input type='text' name='username'/>
<input type='password' name='password' />
<input type='submit' />
</form>
<script>
document.getElementById('admin-login-form').onsubmit = function (e) {
e.preventDefault();
fetch('/admin/login', { method: 'POST', body: new URLSearchParams(new FormData(e.target)) }).then(res => {
if (res.status >= 200 && res.status < 400) {
console.log(res)
window.location = '/admin/auth/workspace';
}
<html lang='en' prefix='og: https://ogp.me/ns#'>
<head>
<meta charset='UTF-8'>
<meta http-equiv='X-UA-Compatible' content='IE=edge'>
<meta name='viewport' content='width=device-width, initial-scale=1.0'>
<title>Krutacea - Admin Login</title>
<link rel='stylesheet' href='/static/default/admin.css'>
</head>
}).catch(err => console.log(err))
}
</script>
<body>
<form id='admin-login-form'>
<div>
<label for='username'>Admin Id</label>
<input type='text' name='username'/>
</div>
<div>
<label for='password'>Password</label>
<input type='password' name='password' />
</div>
<input type='submit' />
</form>
</body>
<script src='/static/default/admin.js'></script>
</html>
",
)
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment