aboutsummaryrefslogtreecommitdiff
path: root/planetwars-server/src/db
diff options
context:
space:
mode:
Diffstat (limited to 'planetwars-server/src/db')
-rw-r--r--planetwars-server/src/db/users.rs8
1 files changed, 6 insertions, 2 deletions
diff --git a/planetwars-server/src/db/users.rs b/planetwars-server/src/db/users.rs
index 3c071de..3a74c53 100644
--- a/planetwars-server/src/db/users.rs
+++ b/planetwars-server/src/db/users.rs
@@ -57,10 +57,14 @@ pub fn create_user(credentials: &Credentials, conn: &PgConnection) -> QueryResul
.get_result::<User>(conn)
}
-pub fn authenticate_user(credentials: &Credentials, db_conn: &PgConnection) -> Option<User> {
+pub fn find_user(username: &str, db_conn: &PgConnection) -> QueryResult<User> {
users::table
- .filter(users::username.eq(&credentials.username))
+ .filter(users::username.eq(username))
.first::<User>(db_conn)
+}
+
+pub fn authenticate_user(credentials: &Credentials, db_conn: &PgConnection) -> Option<User> {
+ find_user(credentials.username, db_conn)
.optional()
.unwrap()
.and_then(|user| {