diff --git a/src/structures/user.rs b/src/structures/user.rs index 9c4fbfc..ad473eb 100644 --- a/src/structures/user.rs +++ b/src/structures/user.rs @@ -71,8 +71,9 @@ impl User { // pub async fn fetch_relations(&self) {} - #[sql(crate::database::DB, "SELECT * FROM users LEFT JOIN sessions ON sessions.user_id = users.id WHERE verified = TRUE AND sessions.token = $1 LIMIT 1")] - pub async fn fetch_by_token(_token: &str) -> Result {} + pub async fn fetch_by_token(token: &str) -> Result { + db.fetch("SELECT * FROM users WHERE id = ( SELECT user_id FROM sessions WHERE verified = TRUE AND token = $1 )", vec![token.into()]).await + } pub fn to_public(&self) -> Self { Self {