feat: implement email verification and password reset features

- Add EmailTokenService for handling email verification and password reset tokens.
- Create EmailService for sending verification and reset emails via SMTP.
- Update AuthService to handle email verification status during login.
- Modify user registration to redirect to a check email screen instead of issuing a token.
- Implement resend verification email functionality.
- Add deep link handling for email verification and password reset in the mobile app.
- Update mobile app routes and components to support new email verification flow.
- Enhance error handling for unverified emails during login attempts.
- Update configuration to include SMTP settings for email service.
This commit is contained in:
2026-03-14 23:38:15 -03:00
parent f5f4e878b4
commit d5af338ee1
38 changed files with 1146 additions and 75 deletions
+8 -6
View File
@@ -60,16 +60,14 @@ impl AuthService {
// Registro com email/senha
// -------------------------------------------------------------------------
pub async fn register(&self, email: String, password: String) -> Result<TokenPair, AppError> {
if let Some(_) = self.user_repo.find_by_email(&email).await? {
pub async fn register(&self, email: String, password: String) -> Result<User, AppError> {
if self.user_repo.find_by_email(&email).await?.is_some() {
return Err(AppError::Conflict("email already registered".into()));
}
let password_hash = hash_password(&password)?;
let user = User::new_with_password(email, password_hash);
let user = self.user_repo.create(&user).await?;
self.issue_token_pair(&user)
let new_user = User::new_with_password(email, password_hash);
Ok(self.user_repo.create(&new_user).await?)
}
// -------------------------------------------------------------------------
@@ -86,6 +84,10 @@ impl AuthService {
let hash = user.password_hash.as_deref().ok_or(AppError::Unauthorized)?;
verify_password(&password, hash)?;
if !user.email_verified {
return Err(AppError::EmailNotVerified);
}
self.issue_token_pair(&user)
}