Record login for users
This commit is contained in:
@@ -17,6 +17,7 @@ use axum::{
|
||||
extract::State,
|
||||
response::{Html, IntoResponse, Redirect, Response},
|
||||
};
|
||||
use chrono::Utc;
|
||||
use sqlx::PgPool;
|
||||
use uuid::Uuid;
|
||||
use validator::Validate;
|
||||
@@ -77,7 +78,8 @@ async fn get_posts(
|
||||
sqlx::query_as!(
|
||||
PostEntry,
|
||||
r#"
|
||||
SELECT p.post_id, p.author_id, u.username AS author, p.title, p.content, p.published_at
|
||||
SELECT p.post_id, p.author_id, u.username AS author,
|
||||
p.title, p.content, p.published_at, p.last_modified
|
||||
FROM posts p
|
||||
LEFT JOIN users u ON p.author_id = u.user_id
|
||||
ORDER BY p.published_at DESC
|
||||
@@ -99,7 +101,8 @@ pub async fn get_posts_page(
|
||||
sqlx::query_as!(
|
||||
PostEntry,
|
||||
r#"
|
||||
SELECT p.post_id, p.author_id, u.username AS author, p.title, p.content, p.published_at
|
||||
SELECT p.post_id, p.author_id, u.username AS author,
|
||||
p.title, p.content, p.published_at, p.last_modified
|
||||
FROM posts p
|
||||
LEFT JOIN users u ON p.author_id = u.user_id
|
||||
ORDER BY p.published_at DESC
|
||||
@@ -151,10 +154,11 @@ pub async fn update_post(
|
||||
sqlx::query!(
|
||||
"
|
||||
UPDATE posts
|
||||
SET title = $1, content = $2 WHERE post_id = $3
|
||||
SET title = $1, content = $2, last_modified = $3 WHERE post_id = $4
|
||||
",
|
||||
form.title,
|
||||
form.content,
|
||||
Utc::now(),
|
||||
post_id
|
||||
)
|
||||
.execute(&connection_pool)
|
||||
@@ -257,7 +261,8 @@ async fn get_post_data(
|
||||
sqlx::query_as!(
|
||||
PostEntry,
|
||||
r#"
|
||||
SELECT p.post_id, p.author_id, u.username AS author, p.title, p.content, p.published_at
|
||||
SELECT p.post_id, p.author_id, u.username AS author,
|
||||
p.title, p.content, p.published_at, last_modified
|
||||
FROM posts p
|
||||
LEFT JOIN users u ON p.author_id = u.user_id
|
||||
WHERE p.post_id = $1
|
||||
|
||||
Reference in New Issue
Block a user