Skip to content

Commit

Permalink
Fix expiry of token breaks authentication #164
Browse files Browse the repository at this point in the history
  • Loading branch information
LarsRefsgaard committed Jun 27, 2023
1 parent 8ad9f5e commit 77d59d5
Showing 1 changed file with 23 additions and 8 deletions.
31 changes: 23 additions & 8 deletions lib/carp_study_app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,16 @@ class CarpStudyAppState extends State<CarpStudyApp> {
HomePage(child: child),
routes: [
GoRoute(
path: '/',
parentNavigatorKey: _shellNavigatorKey,
redirect: (context, state) =>
bloc.hasInformedConsentBeenAccepted ? '/tasks' : '/consent',
),
path: '/',
parentNavigatorKey: _shellNavigatorKey,
redirect: (context, state) {
if (bloc.user == null) {
return '/login';
}
return bloc.hasInformedConsentBeenAccepted
? '/tasks'
: '/consent';
}),
GoRoute(
path: '/tasks',
parentNavigatorKey: _shellNavigatorKey,
Expand Down Expand Up @@ -103,8 +108,12 @@ class CarpStudyAppState extends State<CarpStudyApp> {
GoRoute(
path: '/consent',
parentNavigatorKey: _rootNavigatorKey,
redirect: (context, state) =>
bloc.studyId == null ? '/invitations' : null,
redirect: (context, state) {
if (bloc.hasInformedConsentBeenAccepted) {
return '/tasks';
}
return bloc.studyId == null ? '/invitations' : null;
},
builder: (context, state) => InformedConsentPage(
bloc.data.informedConsentViewModel,
),
Expand Down Expand Up @@ -136,7 +145,13 @@ class CarpStudyAppState extends State<CarpStudyApp> {
GoRoute(
path: '/invitations',
parentNavigatorKey: _rootNavigatorKey,
redirect: (context, state) => bloc.user == null ? '/login' : null,
redirect: (context, state) {
if (bloc.studyId != null) {
return '/consent';
}

return bloc.user == null ? '/login' : null;
},
builder: (context, state) =>
InvitationListPage(bloc.data.invitationsListViewModel),
),
Expand Down

0 comments on commit 77d59d5

Please sign in to comment.