From 31f80998a8eef32c0ef2d309bee68ab88f453bab Mon Sep 17 00:00:00 2001 From: mrw1593 Date: Thu, 22 Jun 2023 20:36:06 -0400 Subject: Implement the password grant --- src/services/db/client.rs | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) (limited to 'src/services/db/client.rs') diff --git a/src/services/db/client.rs b/src/services/db/client.rs index 70701d7..b8942e9 100644 --- a/src/services/db/client.rs +++ b/src/services/db/client.rs @@ -19,6 +19,7 @@ pub struct ClientRow { pub client_type: ClientType, pub allowed_scopes: String, pub default_scopes: Option, + pub is_trusted: bool, } #[derive(Clone, FromRow)] @@ -77,7 +78,8 @@ pub async fn get_client_response<'c>( alias, type as `client_type: ClientType`, allowed_scopes, - default_scopes + default_scopes, + trusted as `is_trusted: bool` FROM clients WHERE id = ?", id ) @@ -158,6 +160,16 @@ pub async fn get_client_secret<'c>( Ok(Some(hash)) } +pub async fn is_client_trusted<'c>( + executor: impl Executor<'c, Database = MySql>, + id: Uuid, +) -> Result, RawUnexpected> { + query_scalar!("SELECT trusted as `t: bool` FROM clients WHERE id = ?", id) + .fetch_optional(executor) + .await + .unexpect() +} + pub async fn get_client_redirect_uris<'c>( executor: impl Executor<'c, Database = MySql>, id: Uuid, @@ -328,6 +340,20 @@ pub async fn update_client_default_scopes<'c>( .await } +pub async fn update_client_trusted<'c>( + executor: impl Executor<'c, Database = MySql>, + id: Uuid, + is_trusted: bool, +) -> Result { + query!( + "UPDATE clients SET trusted = ? WHERE id = ?", + is_trusted, + id + ) + .execute(executor) + .await +} + pub async fn update_client_redirect_uris<'c>( mut transaction: Transaction<'c, MySql>, id: Uuid, -- cgit v1.2.3