docs(auth): add correct header

This commit was merged in pull request #62.
This commit is contained in:
2022-12-07 19:52:01 -05:00
parent 672aba7084
commit 5e83c9e74e
18 changed files with 557 additions and 120 deletions
@@ -1,11 +1,18 @@
// Author: Hugo Pointcheval
// Email: git@pcl.ovh
// -----
// File: app.dart
// Created Date: 19/08/2022 12:05:38
// Last Modified: Sat Dec 03 2022
// -----
// Copyright (c) 2022
// Copyright (C) 2022 WYATT GROUP
// Please see the AUTHORS file for details.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
import 'dart:async';
import 'dart:math';
@@ -14,6 +21,7 @@ import 'package:example_router/core/constants/form_field.dart';
import 'package:example_router/core/dependency_injection/get_it.dart';
import 'package:example_router/core/routes/router.dart';
import 'package:example_router/core/utils/custom_password.dart';
import 'package:example_router/core/utils/forms.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:go_router/go_router.dart';
@@ -69,7 +77,7 @@ class App extends StatelessWidget {
@override
Widget build(BuildContext context) {
AuthenticationState? previous;
AuthenticationState<int>? previous;
final AuthenticationCubit<int> authenticationCubit =
AuthenticationCubit(authenticationRepository: authenticationRepository);
@@ -85,29 +93,18 @@ class App extends StatelessWidget {
redirect: (context, state) {
final authState = authenticationCubit.state;
if (authState != previous) {
if (authState.status != previous?.status) {
previous = authState;
// Check if current user is logged in
final loggedIn =
authState.status == AuthenticationStatus.authenticated;
// Checking if current path is onboarding or not
final isOnboarding = AppRouter.publicRoutes.contains(state.subloc);
if (!loggedIn) {
if (authState.status == AuthenticationStatus.unauthenticated) {
debugPrint('Not logged');
if (isOnboarding) {
return null;
} else {
if (!isOnboarding) {
return '/';
}
} else {
} else if (authState.status == AuthenticationStatus.authenticated) {
debugPrint('Logged');
if (isOnboarding) {
return '/home';
} else {
return null;
}
return '/home';
}
}
return null;
@@ -116,9 +113,13 @@ class App extends StatelessWidget {
return MultiRepositoryProvider(
providers: [
RepositoryProvider<AuthenticationRepository>.value(
RepositoryProvider<AuthenticationRepository<int>>.value(
value: authenticationRepository,
),
RepositoryProvider<FormRepository>(
create: (context) =>
FormRepositoryImpl()..registerForm(AppForms.getEditProfileForm()),
),
],
child: MultiBlocProvider(
providers: [