Add register page

This commit is contained in:
Jackzie 2025-04-15 20:33:06 -05:00
parent 3603237f30
commit 692aeb4383
5 changed files with 96 additions and 3 deletions

View file

@ -108,7 +108,7 @@ async fn rocket() -> _ {
api::library::move_file, api::library::upload_file, api::library::download_file, api::library::list_files, api::library::get_file, api::library::delete_file,
])
.mount("/auth", routes![
ui::auth::login
ui::auth::login, ui::auth::login_handler, ui::auth::register, ui::auth::register_handler,
])
.mount("/", routes![
ui::help::about,

View file

@ -6,8 +6,21 @@ pub async fn login(route: &Route) -> Template {
Template::render("auth/login", context! { route: route.uri.path() })
}
#[post("/login")]
pub async fn login_handler(route: &Route) -> Template {
Template::render("auth/login", context! { route: route.uri.path() })
}
#[get("/register")]
pub async fn register(route: &Route) -> Template {
Template::render("auth/register", context! { route: route.uri.path() })
}
#[post("/register")]
pub async fn register_handler(route: &Route) -> Template {
Template::render("auth/register", context! { route: route.uri.path() })
}

View file

@ -4,6 +4,7 @@
<ul>
<li><a href="https://www.flaticon.com/free-icons/default" title="default icons">Default icons created by kliwir art -
Flaticon</a></li>
<li><a href="https://webgradients.com/">https://webgradients.com/</a></li>
</ul>
</div>

View file

@ -18,7 +18,7 @@
<div class="field">
<label class="label">Password</label>
<div class="control has-icons-left">
<input required name="password" class="input" type="text" placeholder="hunter2">
<input required name="password" class="input" type="password" placeholder="hunter2">
<span class="icon is-small is-left">
<i class="fas fa-key"></i>
</span>
@ -42,7 +42,11 @@
</div>
</form>
<br>
<a href="/auth/forgot-password">Forgot password?</a>
<span>
{{#if can_register}}
<a href="/auth/register">Register</a>
| {{/if}}<a href="/auth/forgot-password">Forgot password?</a>
</span>
<div class="field is-pulled-right">
<div class="control">
<div class="select is-small">

View file

@ -0,0 +1,75 @@
{{#> layouts/default body-class="has-background-white-ter login-bg" }}
<br><br>
<div class="container py-6" style="width:20%"> <!-- TODO: fix width on mobile -->
<h1 class="title is-1 has-text-centered">storage-app</h1>
<div class="box is-radiusless">
<h4 class="title is-4 has-text-centered">Register</h4>
{{#if can_register }}
<form method="post" action="/auth/register">
<div class="field">
<label class="label">Username</label>
<div class="control has-icons-left">
<input required name="username" class="input" type="text" placeholder="Username">
<span class="icon is-small is-left">
<i class="fas fa-user"></i>
</span>
</div>
{{!-- <p class="help is-success">This username is available</p> --}}
</div>
<div class="field">
<label class="label">Email</label>
<div class="control has-icons-left">
<input required name="username" class="input" type="email" placeholder="Email">
<span class="icon is-small is-left">
<i class="fas fa-email"></i>
</span>
</div>
{{!-- <p class="help is-success">This username is available</p> --}}
</div>
<div class="field">
<label class="label">Password</label>
<div class="control has-icons-left">
<input required name="password" class="input" type="password" placeholder="hunter2">
<span class="icon is-small is-left">
<i class="fas fa-key"></i>
</span>
</div>
{{!-- <p class="help is-success">This username is available</p> --}}
</div>
<div class="field">
<label class="label">Password (confirm)</label>
<div class="control has-icons-left">
<input required name="password" class="input" type="password" placeholder="hunter2">
<span class="icon is-small is-left">
<i class="fas fa-key"></i>
</span>
</div>
{{!-- <p class="help is-success">This username is available</p> --}}
</div>
<hr>
<div class="buttons">
<button class="button is-link is-fullwidth" type="submit" >Register</button>
</div>
</form>
{{else}}
<div class="block ml-2 content">
<p><i class="fas fa-xmark"></i>Registeration has been disabled</p>
{{!-- <p>Contact administrator</p> --}}
</div>
{{/if}}
<span>
<a href="/auth/login">Login</a>
</span>
<div class="field is-pulled-right">
<div class="control">
<div class="select is-small">
<select>
<option selected value="en-us">English</option>
</select>
</div>
</div>
</div>
</div>
</div>
{{/layouts/default}}