aboutsummaryrefslogtreecommitdiff
path: root/planetwars-server/src/db/sessions.rs
diff options
context:
space:
mode:
authorIlion Beyst <ilion.beyst@gmail.com>2022-10-12 22:52:15 +0200
committerIlion Beyst <ilion.beyst@gmail.com>2022-10-12 22:52:15 +0200
commitae57359353cf31ff374a8932999742920878bf00 (patch)
tree0db27d394a2a61a5cc94e73014c82954829c1338 /planetwars-server/src/db/sessions.rs
parented016773b112460ebbf0ff023b0915545229ed41 (diff)
downloadplanetwars.dev-ae57359353cf31ff374a8932999742920878bf00.tar.xz
planetwars.dev-ae57359353cf31ff374a8932999742920878bf00.zip
upgrade to diesel 2.0
Diffstat (limited to 'planetwars-server/src/db/sessions.rs')
-rw-r--r--planetwars-server/src/db/sessions.rs6
1 files changed, 3 insertions, 3 deletions
diff --git a/planetwars-server/src/db/sessions.rs b/planetwars-server/src/db/sessions.rs
index a91d954..f8108cc 100644
--- a/planetwars-server/src/db/sessions.rs
+++ b/planetwars-server/src/db/sessions.rs
@@ -6,7 +6,7 @@ use diesel::{insert_into, prelude::*, Insertable, RunQueryDsl};
use rand::{self, Rng};
#[derive(Insertable)]
-#[table_name = "sessions"]
+#[diesel(table_name = sessions)]
struct NewSession {
token: String,
user_id: i32,
@@ -19,7 +19,7 @@ pub struct Session {
pub token: String,
}
-pub fn create_session(user: &User, conn: &PgConnection) -> Session {
+pub fn create_session(user: &User, conn: &mut PgConnection) -> Session {
let new_session = NewSession {
token: gen_session_token(),
user_id: user.id,
@@ -31,7 +31,7 @@ pub fn create_session(user: &User, conn: &PgConnection) -> Session {
.unwrap()
}
-pub fn find_user_by_session(token: &str, conn: &PgConnection) -> QueryResult<(Session, User)> {
+pub fn find_user_by_session(token: &str, conn: &mut PgConnection) -> QueryResult<(Session, User)> {
sessions::table
.inner_join(users::table)
.filter(sessions::token.eq(&token))