AppFlowy/rust-lib/flowy-user/src/handlers/auth.rs

37 lines
1.0 KiB
Rust
Raw Normal View History

2021-07-09 15:31:44 +00:00
use crate::domain::{user::*, user_session::UserSession};
2021-07-08 13:23:44 +00:00
use flowy_dispatch::prelude::*;
2021-07-09 15:31:44 +00:00
use std::{convert::TryInto, sync::Arc};
// tracing instrument 👉🏻 https://docs.rs/tracing/0.1.26/tracing/attr.instrument.html
#[tracing::instrument(
2021-07-05 13:23:13 +00:00
name = "user_sign_in",
skip(data),
fields(
email = %data.email,
)
)]
pub async fn user_sign_in(data: Data<SignInRequest>) -> ResponseResult<SignInResponse, String> {
let _params: SignInParams = data.into_inner().try_into()?;
// TODO: user sign in
let response = SignInResponse::new(true);
2021-07-05 13:23:13 +00:00
response_ok(response)
}
#[tracing::instrument(
name = "user_sign_up",
2021-07-09 15:31:44 +00:00
skip(data, session),
2021-07-05 13:23:13 +00:00
fields(
email = %data.email,
)
)]
2021-07-09 15:31:44 +00:00
pub async fn user_sign_up(
data: Data<SignUpRequest>,
session: ModuleData<Arc<UserSession>>,
) -> ResponseResult<SignUpResponse, String> {
let _params: SignUpParams = data.into_inner().try_into()?;
// TODO: user sign up
2021-07-05 13:23:13 +00:00
let fake_resp = SignUpResponse::new(true);
response_ok(fake_resp)
}