diff --git a/src/db.rs b/src/db.rs index 38178e5..9a558c9 100644 --- a/src/db.rs +++ b/src/db.rs @@ -84,7 +84,7 @@ impl OAuthDatabase { /// Applicant: client pub async fn trusted_register_access(&mut self, app: &crate::oauth_types::oauth_application::OAuthHashedApplication, scope: &crate::oauth_types::oauth_scope::OAuthScope) -> Result<(), tokio_postgres::Error> { let access = crate::oauth_types::oauth_access::OAuthApplicationAccess::create(app, scope); - self.psql_execute("insert into ApplicationAccess(access_id, client_id, scope_id) values($1, $2, $3)", &[&access.access_id, &access.client_id, &access.scope_id]).await?; + self.psql_execute("insert into ApplicationAccess(access_id, client_id, scope_id) values ($1, $2, $3)", &[&access.access_id, &access.client_id, &access.scope_id]).await?; Ok(()) } @@ -98,15 +98,22 @@ impl OAuthDatabase { /// Issue a master token. /// Applicant: master - pub async fn trusted_issue_master_token(&mut self, description: &String) -> Result { + pub async fn trusted_issue_master_db_token(&mut self, description: &String) -> Result { // TEST: functionality let access = crate::oauth_types::oauth_access::OAuthMasterDBAccess::create(description); let hashed = crate::oauth_types::oauth_access::OAuthHashedMasterDBAccess::from(&access); - self.psql_execute("insert into MasterDBAccess(master_db_id, master_db_token, master_db_desc) values($1, $2, $3)", &[&hashed.master_db_id, &hashed.master_db_token, &hashed.master_db_desc]).await?; + self.psql_execute("insert into MasterDBAccess(master_db_id, master_db_token, master_db_desc) values ($1, $2, $3)", &[&hashed.master_db_id, &hashed.master_db_token, &hashed.master_db_desc]).await?; Ok(access) } // TODO: other type of db tokens + pub async fn trusted_issue_resource_db_token(&mut self, resource_id: &Uuid, description: &String) -> Result { + // TEST: functionality + let access = crate::oauth_types::oauth_access::OAuthResourceDBAccess::create(resource_id, description); + let hashed = crate::oauth_types::oauth_access::OAuthHashedResourceDBAccess::from(&access); + self.psql_execute("insert into ResourceDBAccess(resource_db_id, resource_id, resource_db_token, resource_db_desc) values ($1, $2, $3, $4)", &[&hashed.resource_db_id, &hashed.resource_id, &hashed.resource_db_token, &hashed.resource_db_desc]).await?; + Ok(access) + } } #[cfg(test)]