|
@@ -1,3 +1,4 @@
|
|
|
|
+use chrono::Utc;
|
|
use flowy_net::response::{ServerCode, ServerError};
|
|
use flowy_net::response::{ServerCode, ServerError};
|
|
use flowy_user::{entities::SignUpResponse, protobuf::SignUpParams};
|
|
use flowy_user::{entities::SignUpResponse, protobuf::SignUpParams};
|
|
use sqlx::PgPool;
|
|
use sqlx::PgPool;
|
|
@@ -10,12 +11,29 @@ pub struct Auth {
|
|
impl Auth {
|
|
impl Auth {
|
|
pub fn new(db_pool: Arc<PgPool>) -> Self { Self { db_pool } }
|
|
pub fn new(db_pool: Arc<PgPool>) -> Self { Self { db_pool } }
|
|
|
|
|
|
- pub fn sign_up(&self, params: SignUpParams) -> Result<SignUpResponse, ServerError> {
|
|
|
|
|
|
+ pub async fn sign_up(&self, params: SignUpParams) -> Result<SignUpResponse, ServerError> {
|
|
// email exist?
|
|
// email exist?
|
|
-
|
|
|
|
// generate user id
|
|
// generate user id
|
|
|
|
+ let result = sqlx::query!(
|
|
|
|
+ r#"
|
|
|
|
+ INSERT INTO user_table (id, email, name, create_time, password)
|
|
|
|
+ VALUES ($1, $2, $3, $4, $5)
|
|
|
|
+ "#,
|
|
|
|
+ uuid::Uuid::new_v4(),
|
|
|
|
+ params.email,
|
|
|
|
+ params.name,
|
|
|
|
+ Utc::now(),
|
|
|
|
+ "123".to_string()
|
|
|
|
+ )
|
|
|
|
+ .execute(self.db_pool.as_ref())
|
|
|
|
+ .await;
|
|
|
|
|
|
- unimplemented!()
|
|
|
|
|
|
+ let response = SignUpResponse {
|
|
|
|
+ uid: "".to_string(),
|
|
|
|
+ name: "".to_string(),
|
|
|
|
+ email: "".to_string(),
|
|
|
|
+ };
|
|
|
|
+ Ok(response)
|
|
}
|
|
}
|
|
|
|
|
|
pub fn is_email_exist(&self, email: &str) -> bool { true }
|
|
pub fn is_email_exist(&self, email: &str) -> bool { true }
|