feat: fix login redirection
This commit is contained in:
parent
ba4e4af609
commit
066cc62262
@ -1,5 +1,5 @@
|
||||
use actix_identity::Identity;
|
||||
use actix_web::{web, HttpMessage, HttpRequest, HttpResponse, Responder};
|
||||
use actix_web::{http::header::LOCATION, web, HttpMessage, HttpRequest, HttpResponse, Responder};
|
||||
use serde::Deserialize;
|
||||
use sqlx::PgPool;
|
||||
|
||||
@ -22,9 +22,9 @@ async fn route(
|
||||
if let Some(user) = result {
|
||||
let hash = hash_plain_password_with_salt(&form.password, &user.salt).unwrap();
|
||||
if hash == user.password {
|
||||
Identity::login(&request.extensions(), user.id.to_string());
|
||||
Identity::login(&request.extensions(), user.id.to_string()).unwrap();
|
||||
|
||||
return HttpResponse::Ok().body("Angemeldet!");
|
||||
return HttpResponse::Found().insert_header((LOCATION, "/")).finish();
|
||||
} else {
|
||||
return HttpResponse::Unauthorized().body("Nutzername oder Passwort falsch.");
|
||||
}
|
||||
|
@ -1,7 +1,12 @@
|
||||
{% extends "nav.html" %}
|
||||
|
||||
{% block content %}
|
||||
<p>
|
||||
Content
|
||||
</p>
|
||||
<section class="section">
|
||||
<div class="container">
|
||||
<h1 class="title">
|
||||
Vefügbarkeit für |datum|
|
||||
</h1>
|
||||
|
||||
</div>
|
||||
</section>
|
||||
{% endblock %}
|
||||
|
@ -1,15 +1,26 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block body %}
|
||||
<h1>Brass - Anmeldung</h1>
|
||||
<p>Gib dein Nutzernamen und das Passwort ein:</p>
|
||||
<form>
|
||||
<label for="email">E-Mail:</label>
|
||||
<input name="email" type="text">
|
||||
<section class="section">
|
||||
<div class="container">
|
||||
<h1 class="title">Brass - Anmeldung</h1>
|
||||
<form class="box">
|
||||
<div class="field">
|
||||
<label class="label" for="email">E-Mail:</label>
|
||||
<div class="control">
|
||||
<input class="input" placeholder="max.mustermann@example.com" name="email" type="text">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<label for="password">Passwort:</label>
|
||||
<input name="password" type="password">
|
||||
<div class="field">
|
||||
<label class="label" for="password">Passwort:</label>
|
||||
<div class="control">
|
||||
<input class="input" placeholder="**********" name="password" type="password">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<input type="submit" formmethod="post">
|
||||
<input class="button is-primary" type="submit" value="Anmelden" formmethod="post">
|
||||
</form>
|
||||
</div>
|
||||
</section>
|
||||
{% endblock %}
|
||||
|
Loading…
x
Reference in New Issue
Block a user