Skip to content

Commit

Permalink
Fix Authentication bug
Browse files Browse the repository at this point in the history
  • Loading branch information
javad-zobeidi committed Jan 19, 2025
1 parent fd66793 commit 2a54478
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion lib/src/authentication/authenticate.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class Authenticate extends Middleware {
String guard = await getSession<String?>('auth_guard') ?? '';
Map<String, dynamic> user =
await getSession<Map<String, dynamic>?>('auth_user') ?? {};
Auth().guard(guard).login(user);
Auth().guard(guard).login(user[guard]);
} else {
throw Unauthenticated(
message: loginPath,
Expand Down
11 changes: 5 additions & 6 deletions lib/src/authentication/authentication.dart
Original file line number Diff line number Diff line change
Expand Up @@ -88,15 +88,14 @@ class Auth {
/// function does not return anything.
Future<void> _updateSession() async {
await setSession('logged_in', true);

if (await getSession<Map?>('auth_user') != _user) {
await setSession('auth_guard', _userGuard);
Map<String, dynamic> user =
await getSession<Map<String, dynamic>?>('auth_user') ?? {};
if (_user != user) {
await deleteSession('auth_user');
await setSession('auth_user', _user);
}

if (await getSession<String?>('auth_guard') != _userGuard) {
await setSession('auth_guard', _userGuard);
}

_loggedIn = true;
}

Expand Down

0 comments on commit 2a54478

Please sign in to comment.