diff options
| author | mrw1593 <botahamec@outlook.com> | 2023-06-22 20:36:06 -0400 |
|---|---|---|
| committer | mrw1593 <botahamec@outlook.com> | 2023-06-22 20:36:06 -0400 |
| commit | 31f80998a8eef32c0ef2d309bee68ab88f453bab (patch) | |
| tree | c4a4b9aaa14119f95c825375116052afb571941f /src/services/db/client.rs | |
| parent | 27ab8b4d2ea815a2bac432e7393adf19429135f9 (diff) | |
Implement the password grant
Diffstat (limited to 'src/services/db/client.rs')
| -rw-r--r-- | src/services/db/client.rs | 28 |
1 files changed, 27 insertions, 1 deletions
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<String>, + 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<Option<bool>, 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<MySqlQueryResult, sqlx::Error> { + 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, |
