1
0
mirror of https://gitlab.com/comunic/comunicapiv3 synced 2025-06-21 17:05:16 +00:00

Can get current user ID

This commit is contained in:
2020-05-24 17:57:47 +02:00
parent 3b1b377d82
commit 75024dbca6
7 changed files with 82 additions and 5 deletions

View File

@ -34,7 +34,7 @@ pub fn login_user(email: &str, password: &str, client: &APIClient) -> ResultBoxE
let new_token = UserAccessToken {
user_id: user.id,
client_id: client.id,
token: rand_str(150)
token: rand_str(150),
};
// Save it
@ -63,4 +63,14 @@ fn get_client_tokens(user_id: UserID, client: &APIClient) -> ResultBoxError<User
})
},
)
}
/// Find a user ID based on login token
pub fn get_user_by_login_token(token: &str, client: &APIClient) -> ResultBoxError<UserID> {
database::query_row(
QueryInfo::new(USER_ACCESS_TOKENS_TABLE)
.cond_u32("service_id", client.id)
.cond("token1", token),
|res| res.get_int64("user_id"),
)
}