feat: implement authentication flow and session management

- Update RootLayout to handle authentication state and redirect users based on their auth status.
- Create an Index component to redirect unauthenticated users to the login page.
- Modify ApiAuthRepository to fetch user session data using access and refresh tokens.
- Introduce a new container file to manage use case instances for authentication and filament operations.
- Enhance authStore to validate tokens and fetch user data from the API.
- Add babel-plugin-module-resolver for improved module imports.
- Update package.json scripts for running the app on Android and iOS.
- Add expo-camera dependency for camera functionalities.
- Update tsconfig.json to include infrastructure path mapping.
This commit is contained in:
2026-03-14 13:22:17 -03:00
parent d7fb768d3b
commit 416e13893c
68 changed files with 1778 additions and 99 deletions
+5 -2
View File
@@ -10,6 +10,8 @@ import { Header } from '@presentation/components/layout/Header';
import { Input } from '@presentation/components/ui/Input';
import { Button } from '@presentation/components/ui/Button';
import { colors, typography, spacing } from '@shared/theme';
import { registerUseCase } from '@infrastructure/container';
import { useAuthStore } from '@store/authStore';
const schema = z.object({
email: z.string().email('E-mail inválido'),
@@ -29,6 +31,7 @@ type FormData = z.infer<typeof schema>;
*/
export default function RegisterScreen(): React.ReactElement {
const router = useRouter();
const setSession = useAuthStore((s) => s.setSession);
const [isLoading, setIsLoading] = useState(false);
const { control, handleSubmit, formState: { errors } } = useForm<FormData>({
@@ -39,8 +42,8 @@ export default function RegisterScreen(): React.ReactElement {
async function onSubmit(data: FormData): Promise<void> {
setIsLoading(true);
try {
// TODO: injetar RegisterUseCase
console.log('register', data);
const session = await registerUseCase.execute({ email: data.email, password: data.password });
await setSession(session);
router.replace('/(auth)/verify-email');
} catch {
Alert.alert('Erro', 'Não foi possível criar sua conta.');