Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,21 @@ class AuthenticationService {
await dotenv.load();
auth0 = Auth0(dotenv.get('AUTH0_DOMAIN'), dotenv.get('AUTH0_CLIENT_ID'));

// fyi: This will refresh the token if needed
await auth0.credentialsManager.credentials();

await setCurrentClientMode();

if (await hasRequiredTokens()) {
bool loginValid = await hasRequiredTokens() &&
await auth0.credentialsManager.hasValidCredentials();

if (loginValid) {
log('message: Tokens found in storage');
await setRequiredTokens();
await fetchUser();
} else {
log('message: No valid credentials found');
logout();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this mean the logout logic has been missing the whole time? 😮

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well it wasn't being checked when starting the app, otherwise it was.

}
}

Expand Down Expand Up @@ -179,6 +188,10 @@ class AuthenticationService {
creds = await auth0
.webAuthentication(scheme: 'fccapp')
.login(parameters: {'connection': connectionType});

await auth0.credentialsManager.storeCredentials(creds);

log('set new credentials');
}
} on WebAuthenticationException {
// NOTE: The most likely case is that the user canceled the login
Expand All @@ -202,6 +215,7 @@ class AuthenticationService {
String accessToken = connectionType == 'email'
? emailLoginRes.data['access_token']
: creds.accessToken;

res = await _dio.get(
'$baseApiURL/mobile-login',
options: Options(
Expand Down Expand Up @@ -344,7 +358,6 @@ class AuthenticationService {
);
}

await auth0.credentialsManager.clearCredentials();
// ignore: unnecessary_null_comparison
if (res != null) {
Navigator.pop(context);
Expand All @@ -363,6 +376,7 @@ class AuthenticationService {
await store.delete(key: 'csrf_token');
await store.delete(key: 'jwt_access_token');
userModel = null;
auth0.credentialsManager.clearCredentials();
}

Future<void> fetchUser() async {
Expand Down
24 changes: 12 additions & 12 deletions mobile-app/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,10 @@ packages:
dependency: transitive
description:
name: async
sha256: d2872f9c19731c2e5f10444b14686eb7cc85c76274bd6c16e1816bff9a3bab63
sha256: "758e6d74e971c3e5aceb4110bfd6698efc7f501675bcfe0c775459a8140750eb"
url: "https://pub.dev"
source: hosted
version: "2.12.0"
version: "2.13.0"
audio_service:
dependency: "direct main"
description:
Expand Down Expand Up @@ -394,10 +394,10 @@ packages:
dependency: transitive
description:
name: fake_async
sha256: "6a95e56b2449df2273fd8c45a662d6947ce1ebb7aafe80e550a3f68297f3cacc"
sha256: "5368f224a74523e8d2e7399ea1638b37aecfca824a3cc4dfdf77bf1fa905ac44"
url: "https://pub.dev"
source: hosted
version: "1.3.2"
version: "1.3.3"
ffi:
dependency: transitive
description:
Expand Down Expand Up @@ -1029,10 +1029,10 @@ packages:
dependency: transitive
description:
name: intl
sha256: d6f56758b7d3014a48af9701c085700aac781a92a87a62b1333b46d8879661cf
sha256: "3df61194eb431efc39c4ceba583b95633a403f46c9fd341e550ce0bfa50e9aa5"
url: "https://pub.dev"
source: hosted
version: "0.19.0"
version: "0.20.2"
io:
dependency: transitive
description:
Expand Down Expand Up @@ -1093,10 +1093,10 @@ packages:
dependency: transitive
description:
name: leak_tracker
sha256: c35baad643ba394b40aac41080300150a4f08fd0fd6a10378f8f7c6bc161acec
sha256: "6bb818ecbdffe216e81182c2f0714a2e62b593f4a4f13098713ff1685dfb6ab0"
url: "https://pub.dev"
source: hosted
version: "10.0.8"
version: "10.0.9"
leak_tracker_flutter_testing:
dependency: transitive
description:
Expand Down Expand Up @@ -1922,10 +1922,10 @@ packages:
dependency: transitive
description:
name: vm_service
sha256: "0968250880a6c5fe7edc067ed0a13d4bae1577fe2771dcf3010d52c4a9d3ca14"
sha256: ddfa8d30d89985b96407efce8acbdd124701f96741f2d981ca860662f1c0dc02
url: "https://pub.dev"
source: hosted
version: "14.3.1"
version: "15.0.0"
watcher:
dependency: transitive
description:
Expand Down Expand Up @@ -1962,10 +1962,10 @@ packages:
dependency: transitive
description:
name: webdriver
sha256: "3d773670966f02a646319410766d3b5e1037efb7f07cc68f844d5e06cd4d61c8"
sha256: "2f3a14ca026957870cfd9c635b83507e0e51d8091568e90129fbf805aba7cade"
url: "https://pub.dev"
source: hosted
version: "3.0.4"
version: "3.1.0"
webview_flutter:
dependency: transitive
description:
Expand Down
Loading