Add emails
This commit is contained in:
parent
85c559cfb1
commit
f1089232c3
3 changed files with 27 additions and 3 deletions
5
migrations/20230816195409_email.sql
Normal file
5
migrations/20230816195409_email.sql
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
-- Add migration script here
|
||||||
|
CREATE TABLE emails (
|
||||||
|
id uuid REFERENCES accounts(id) NOT NULL,
|
||||||
|
mail TEXT NOT NULL PRIMARY KEY
|
||||||
|
);
|
||||||
17
src/main.rs
17
src/main.rs
|
|
@ -486,8 +486,21 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn home(_: State<Arc<AppState>>, User(_): User) -> Result<Html<String>, Error> {
|
#[derive(Serialize, Deserialize)]
|
||||||
Ok(Html(TEMPLATES.render("home.html", &global_context())?))
|
struct Mail {
|
||||||
|
mail: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn home(state: State<Arc<AppState>>, User(user): User) -> Result<Html<String>, Error> {
|
||||||
|
let mails = sqlx::query_as!(Mail, "SELECT mail FROM emails WHERE id = $1", user)
|
||||||
|
.fetch_all(&state.db)
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
let mut context = tera::Context::new();
|
||||||
|
context.insert("mails", &mails);
|
||||||
|
context.extend(global_context());
|
||||||
|
|
||||||
|
Ok(Html(TEMPLATES.render("home.html", &context)?))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,13 @@
|
||||||
<body>
|
<body>
|
||||||
<section class="section">
|
<section class="section">
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<h1 class="title">Mail management</h1>
|
<h1 class="title is-1">Mail management</h1>
|
||||||
|
<h2 class="title is-2">Mails</h2>
|
||||||
|
<ul>
|
||||||
|
{% for mail in mails %}
|
||||||
|
<li>{{mail.mail}}</li>
|
||||||
|
{% endfor %}
|
||||||
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
</body>
|
</body>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue