fix(dimentorin): register mentor flow - zod regex attr, uuid id override in user & mentor repos
- Remove broken zod_rs regex() attribute (always fails, blocks password validation) - user repo create: honor entity.id instead of silently generating new v4 (broke FK mentor.user_id) - mentor repo create: set id explicitly (was NULL not-null violation)
This commit is contained in:
@@ -34,7 +34,7 @@ pub struct AuthLoginResponsetDto {
|
||||
pub struct AuthRegisterRequestDto {
|
||||
#[zod(email, min_length(1))]
|
||||
pub email: String,
|
||||
#[zod(min_length(8), regex(pattern = "^[A-Za-z\\d@$!%*?&]{8,}$"))]
|
||||
#[zod(min_length(8))]
|
||||
pub password: String,
|
||||
#[zod(min_length(2))]
|
||||
pub fullname: String,
|
||||
@@ -89,7 +89,7 @@ impl ZodValidate for AuthRefreshTokenRequestDto {
|
||||
pub struct AuthNewPasswordRequestDto {
|
||||
#[zod(min_length(1))]
|
||||
pub token: String,
|
||||
#[zod(min_length(8), regex(pattern = "^[A-Za-z\\d@$!%*?&]{8,}$"))]
|
||||
#[zod(min_length(8))]
|
||||
pub password: String,
|
||||
}
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ pub struct UsersSetNewPasswordRequestDto {
|
||||
pub struct UsersCreateRequestDto {
|
||||
#[zod(email, min_length(1))]
|
||||
pub email: String,
|
||||
#[zod(min_length(8), regex(pattern = "^[A-Za-z\\d@$!%*?&]{8,}$"))]
|
||||
#[zod(min_length(8))]
|
||||
pub password: String,
|
||||
#[zod(min_length(2))]
|
||||
pub fullname: String,
|
||||
|
||||
@@ -107,7 +107,9 @@ impl UserRepository for PostgresUserRepository {
|
||||
.ok()
|
||||
.or_else(|| entity.role.id.is_empty().then_some(Uuid::nil()));
|
||||
let active_model = UserActiveModel {
|
||||
id: ActiveValue::Set(Uuid::new_v4()),
|
||||
id: ActiveValue::Set(
|
||||
Uuid::parse_str(&entity.id).unwrap_or_else(|_| Uuid::new_v4()),
|
||||
),
|
||||
email: ActiveValue::Set(entity.email.clone()),
|
||||
password_hash: ActiveValue::Set(entity.password),
|
||||
username: ActiveValue::Set(entity.email.clone()),
|
||||
|
||||
Reference in New Issue
Block a user