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:
@@ -1,5 +1,6 @@
|
||||
import React, { useState } from 'react';
|
||||
import { View, Text, StyleSheet, TouchableOpacity, Alert } from 'react-native';
|
||||
import axios from 'axios';
|
||||
import { Link, useRouter } from 'expo-router';
|
||||
import { useForm, Controller } from 'react-hook-form';
|
||||
import { zodResolver } from '@hookform/resolvers/zod';
|
||||
@@ -42,8 +43,15 @@ export default function LoginScreen(): React.ReactElement {
|
||||
await setSession(session);
|
||||
router.replace('/(app)/(tabs)/home');
|
||||
} catch (err) {
|
||||
console.error('login error', err);
|
||||
Alert.alert('Erro', 'E-mail ou senha incorretos.');
|
||||
if (axios.isAxiosError(err) && err.response?.data?.code === 'EMAIL_NOT_VERIFIED') {
|
||||
Alert.alert(
|
||||
'E-mail não verificado',
|
||||
'Confirme seu e-mail antes de entrar. Verifique sua caixa de entrada.',
|
||||
[{ text: 'OK', onPress: () => router.push(`/(auth)/check-email?email=${encodeURIComponent(data.email)}`) }],
|
||||
);
|
||||
} else {
|
||||
Alert.alert('Erro', 'E-mail ou senha incorretos.');
|
||||
}
|
||||
} finally {
|
||||
setIsLoading(false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user