avam-client and oauth2
This commit is contained in:
60
src/lib/domain/api/ports/api_service.rs
Normal file
60
src/lib/domain/api/ports/api_service.rs
Normal file
@@ -0,0 +1,60 @@
|
||||
use crate::{
|
||||
domain::api::models::oauth::*, inbound::http::handlers::oauth::AuthorizationCodeRequest,
|
||||
};
|
||||
|
||||
use super::super::models::user::*;
|
||||
use std::future::Future;
|
||||
|
||||
pub trait ApiService: Clone + Send + Sync + 'static {
|
||||
// ---
|
||||
// USER
|
||||
// ---
|
||||
fn create_user(
|
||||
&self,
|
||||
req: CreateUserRequest,
|
||||
) -> impl Future<Output = Result<User, CreateUserError>> + Send;
|
||||
|
||||
fn get_user_session(
|
||||
&self,
|
||||
session: &axum_session::SessionAnySession, // TODO: Get rid of this and make cleaner
|
||||
) -> impl Future<Output = Option<User>> + Send;
|
||||
|
||||
fn activate_user_account(
|
||||
&self,
|
||||
token: ActivationToken,
|
||||
) -> impl Future<Output = Result<User, ActivateUserError>> + Send;
|
||||
|
||||
fn user_login(
|
||||
&self,
|
||||
req: UserLoginRequest,
|
||||
) -> impl Future<Output = Result<User, UserLoginError>> + Send;
|
||||
|
||||
fn forgot_password(&self, email: &EmailAddress) -> impl Future<Output = ()> + Send;
|
||||
|
||||
fn reset_password(
|
||||
&self,
|
||||
token: &PasswordResetToken,
|
||||
password: &Password,
|
||||
) -> impl Future<Output = Result<User, ResetPasswordError>> + Send;
|
||||
|
||||
fn find_user_by_password_reset_token(
|
||||
&self,
|
||||
token: &PasswordResetToken,
|
||||
) -> impl Future<Output = Option<User>> + Send;
|
||||
|
||||
// ---
|
||||
// OAUTH
|
||||
// ---
|
||||
fn find_client_by_id(&self, id: uuid::Uuid) -> impl Future<Output = Option<Client>> + Send;
|
||||
|
||||
fn generate_authorization_code(
|
||||
&self,
|
||||
user: &User,
|
||||
req: AuthorizeRequest,
|
||||
) -> impl Future<Output = Result<AuthorizationResponse, anyhow::Error>> + Send;
|
||||
|
||||
fn create_token(
|
||||
&self,
|
||||
req: AuthorizationCodeRequest,
|
||||
) -> impl Future<Output = Result<Option<TokenSubject>, TokenError>> + Send;
|
||||
}
|
Reference in New Issue
Block a user