You've already forked authentication-service
mirror of
https://github.com/matrix-org/matrix-authentication-service.git
synced 2025-11-21 23:00:50 +03:00
storage: split the repository trait
This commit is contained in:
@@ -32,7 +32,7 @@ mod tests {
|
||||
CompatAccessTokenRepository, CompatRefreshTokenRepository, CompatSessionRepository,
|
||||
},
|
||||
user::UserRepository,
|
||||
Clock, Repository,
|
||||
Clock, Repository, RepositoryAccess,
|
||||
};
|
||||
use rand::SeedableRng;
|
||||
use rand_chacha::ChaChaRng;
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
//! Interactions with the database
|
||||
//! An implementation of the storage traits for a PostgreSQL database
|
||||
|
||||
#![forbid(unsafe_code)]
|
||||
#![deny(
|
||||
|
||||
@@ -27,7 +27,7 @@ use mas_storage::{
|
||||
UpstreamOAuthSessionRepository,
|
||||
},
|
||||
user::{BrowserSessionRepository, UserEmailRepository, UserPasswordRepository, UserRepository},
|
||||
Repository,
|
||||
Repository, RepositoryAccess, RepositoryTransaction,
|
||||
};
|
||||
use sqlx::{PgPool, Postgres, Transaction};
|
||||
|
||||
@@ -62,7 +62,9 @@ impl PgRepository {
|
||||
}
|
||||
}
|
||||
|
||||
impl Repository for PgRepository {
|
||||
impl Repository<DatabaseError> for PgRepository {}
|
||||
|
||||
impl RepositoryTransaction for PgRepository {
|
||||
type Error = DatabaseError;
|
||||
|
||||
fn save(self: Box<Self>) -> BoxFuture<'static, Result<(), Self::Error>> {
|
||||
@@ -72,6 +74,10 @@ impl Repository for PgRepository {
|
||||
fn cancel(self: Box<Self>) -> BoxFuture<'static, Result<(), Self::Error>> {
|
||||
self.txn.rollback().map_err(DatabaseError::from).boxed()
|
||||
}
|
||||
}
|
||||
|
||||
impl RepositoryAccess for PgRepository {
|
||||
type Error = DatabaseError;
|
||||
|
||||
fn upstream_oauth_link<'c>(
|
||||
&'c mut self,
|
||||
|
||||
@@ -31,7 +31,7 @@ mod tests {
|
||||
UpstreamOAuthSessionRepository,
|
||||
},
|
||||
user::UserRepository,
|
||||
Pagination, Repository,
|
||||
Pagination, RepositoryAccess,
|
||||
};
|
||||
use oauth2_types::scope::{Scope, OPENID};
|
||||
use rand::SeedableRng;
|
||||
|
||||
@@ -16,7 +16,7 @@ use chrono::Duration;
|
||||
use mas_storage::{
|
||||
clock::MockClock,
|
||||
user::{BrowserSessionRepository, UserEmailRepository, UserPasswordRepository, UserRepository},
|
||||
Repository,
|
||||
Repository, RepositoryAccess,
|
||||
};
|
||||
use rand::SeedableRng;
|
||||
use rand_chacha::ChaChaRng;
|
||||
|
||||
Reference in New Issue
Block a user