1
Fork 0
mirror of https://github.com/redstrate/Kawari.git synced 2025-06-30 03:37:45 +00:00

Move restoring character backup to it's own page

This commit is contained in:
Joshua Goins 2025-06-23 21:42:30 -04:00
parent ddb67383af
commit d612a95be9
4 changed files with 35 additions and 10 deletions

View file

@ -4,13 +4,5 @@
{% set current_page = "home" %}
{% block accountbody %}
<!-- TODO: Move to it's own page. -->
<h2>Upload Character Backup</h2>
<form method='post' enctype="multipart/form-data">
<div class="mb-3">
<label for="charbak" class="form-label">Backup file</label>
<input type="file" id="charbak" name="charbak" accept="application/zip" class="form-control"/>
</div>
<button type='submit' class="btn btn-primary">Upload</button>
</form>
<p>See sidebar<p>
{% endblock %}

View file

@ -13,6 +13,11 @@
Home
</a>
</li>
<li class="nav-item">
<a href="/account/app/svc/restore" class="nav-link {% if current_page == 'restore' %}active{% endif %}" >
Restore Backup
</a>
</li>
<li>
<a href="/account/app/svc/mbrPasswd" class="nav-link {% if current_page == 'changepassword' %}active{% endif %}">
Change Password

View file

@ -0,0 +1,15 @@
{% extends "account_base.html" %}
{% block title %}Restore Backup{% endblock %}
{% set current_page = "restore" %}
{% block accountbody %}
<h2>Upload Character Backup</h2>
<form method='post' enctype="multipart/form-data">
<div class="mb-3">
<label for="charbak" class="form-label">Backup file</label>
<input type="file" id="charbak" name="charbak" accept="application/zip" class="form-control"/>
</div>
<button type='submit' class="btn btn-primary">Upload</button>
</form>
{% endblock %}

View file

@ -59,6 +59,12 @@ fn setup_default_environment() -> Environment<'static> {
.expect("Failed to find template!"),
)
.unwrap();
env.add_template_owned(
"restore.html",
std::fs::read_to_string("resources/templates/restore.html")
.expect("Failed to find template!"),
)
.unwrap();
env
}
@ -297,6 +303,12 @@ async fn cancel_account(jar: CookieJar) -> (CookieJar, Redirect) {
(jar.remove("cis_sessid"), Redirect::to("/"))
}
async fn restore_backup() -> Html<String> {
let environment = setup_default_environment();
let template = environment.get_template("restore.html").unwrap();
Html(template.render(context! {}).unwrap())
}
#[tokio::main]
async fn main() {
tracing_subscriber::fmt::init();
@ -320,10 +332,11 @@ async fn main() {
.route("/oauth/oa/registligt", get(register))
.route("/oauth/oa/registlist", post(do_register))
.route("/account/app/svc/manage", get(account))
.route("/account/app/svc/manage", post(upload_character_backup))
.route("/account/app/svc/logout", get(logout))
.route("/account/app/svc/mbrPasswd", get(change_password))
.route("/account/app/svc/mbrCancel", get(cancel_account))
.route("/account/app/svc/restore", get(restore_backup))
.route("/account/app/svc/restore", post(upload_character_backup))
.with_state(state)
.nest_service("/static", ServeDir::new("resources/static"))
.layer(cors);