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
9 changes: 8 additions & 1 deletion android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,14 @@ android {
keyPassword keyProperties.getProperty('keyPassword')
}
}
debug {}
debug {
if (signingConfigExists) {
storeFile file(keyProperties.getProperty('storeFile'))
storePassword keyProperties.getProperty('storePassword')
keyAlias keyProperties.getProperty('keyAlias')
keyPassword keyProperties.getProperty('keyPassword')
}
}
}

buildTypes {
Expand Down
47 changes: 34 additions & 13 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,16 @@

<!-- The following permissions are used in the Context Package -->

<!--Location Permissions-->
<!--Location
Permissions-->
Comment on lines +47 to +48

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

why this got into 2 lines?

<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />

<!--Foreground Service Permissions for Android >= 14 / SDK 34-->
<!--Foreground
Service Permissions for Android >= 14 / SDK 34-->
Comment on lines +53 to +54

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

why this got into 2 lines?

<uses-permission android:name="android.permission.FOREGROUND_SERVICE_LOCATION" />

<!-- for Android 9 (API 28 and below), use: -->
<uses-permission
android:name="com.google.android.gms.permission.ACTIVITY_RECOGNITION"
Expand Down Expand Up @@ -121,14 +123,6 @@
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />

<data android:scheme="carp-ws-prod-auth" android:host="auth" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />

<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />

Comment on lines -124 to -131

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

is this not used by anything?

<data android:scheme="http" />
<data android:host="carp.computerome.dk" />
<data android:pathPrefix="/auth/dev" />
Expand Down Expand Up @@ -171,15 +165,42 @@
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<!-- Deep linking -->
<intent-filter
android:autoVerify="true" >

<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />

<data android:scheme="https" android:host="study.app.carp.computerome.dk"
android:pathPattern="/auth/realms/Carp/login-actions/action-token" />
<data android:scheme="https" android:host="study.app.test.carp.dk"
android:pathPattern="/auth/realms/Carp/login-actions/action-token" />
<data android:scheme="https" android:host="study.app.dev.carp.dk"
android:pathPattern="/auth/realms/Carp/login-actions/action-token" />

</intent-filter>

<!-- Handle custom carp-studies URI scheme so deep links like
carp-studies:/login open the MainActivity (not a helper
callback activity) and keep the Flutter app running. -->
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="carp-studies" android:pathPrefix="/" />
</intent-filter>
</activity>
<activity
android:name="com.linusu.flutter_web_auth_2.CallbackActivity"
android:exported="true">
<intent-filter android:label="flutter_web_auth_2">
<intent-filter
android:label="flutter_web_auth_2">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="carp-studies" android:pathPrefix="/" />
<data android:scheme="carp-studies-anonymous" android:pathPrefix="/" />
</intent-filter>
</activity>
<activity
Expand Down
135 changes: 0 additions & 135 deletions ios/Podfile.lock

This file was deleted.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 8 additions & 1 deletion ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1510"
version = "1.3">
version = "1.7">

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

What is this version upgrade for?

<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
Expand Down Expand Up @@ -91,6 +91,13 @@
ReferencedContainer = "container:Runner.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<EnvironmentVariables>
<EnvironmentVariable
key = "DART_DEFINES"
value = "ZGVwbG95bWVudC1tb2RlPWRldg=="
isEnabled = "YES">
</EnvironmentVariable>
</EnvironmentVariables>
Comment on lines +94 to +100

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This needs explanation, dart define should be part of the build parameters or what is this for?

</LaunchAction>
<ProfileAction
buildConfiguration = "Profile"
Expand Down
9 changes: 0 additions & 9 deletions ios/Runner.xcworkspace/xcshareddata/swiftpm/Package.resolved

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions ios/Runner/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
<key>CFBundleURLSchemes</key>
<array>
<string>carp-studies</string>
<string>carp-studies-anonymous</string>
<string>carp-studies-auth</string>
</array>
</dict>
Expand Down
4 changes: 3 additions & 1 deletion ios/Runner/Runner.entitlements
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
<dict>
<key>com.apple.developer.associated-domains</key>
<array>
<string>applinks:carp.computerome.dk</string>
<string>applinks:study.app.dev.carp.dk</string>
<string>applinks:study.app.test.carp.dk</string>
<string>applinks:study.app.carp.computerome.dk</string>
Comment on lines +7 to +9

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

where is prod fro carp.dk

</array>
<key>com.apple.developer.authentication-services.autofill-credential-provider</key>
<true/>
Expand Down
4 changes: 2 additions & 2 deletions ios/Runner/RunnerRelease.entitlements
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
<string>development</string>
<key>com.apple.developer.associated-domains</key>
<array>
<string>webcredentials:carp.computerome.com</string>
<string>applinks:carp.computerome.dk</string>
<string>applinks:app.dev.carp.dk</string>
<string>applinks:app.carp.computerome.dk</string>
</array>
<key>com.apple.developer.authentication-services.autofill-credential-provider</key>
<true/>
Expand Down
20 changes: 20 additions & 0 deletions lib/carp_study_app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,26 @@ class CarpStudyAppState extends State<CarpStudyApp> {
return task?.widget ?? const ErrorPage();
},
),
// Handle external magic-link callbacks from the auth server. The
// identity provider posts a link like
// /auth/realms/Carp/login-actions/action-token?key=...
// We attempt to authenticate using the URI. On
// success we go to '/', on failure we redirect to the login page.
GoRoute(
path: '/auth/realms/Carp/login-actions/action-token',
parentNavigatorKey: _rootNavigatorKey,
redirect: (context, state) async {
// We don't show any page, but handle the magic link in the background.
try {
await bloc.backend.authenticateWithMagicLink(state.uri.toString());
return homeRoute;
} catch (error) {
debugPrint(
'Magic-link authentication failed: $error, redirecting to login page');
return LoginPage.route;
}
},
),
GoRoute(
path: LoginPage.route,
parentNavigatorKey: _rootNavigatorKey,
Expand Down
9 changes: 6 additions & 3 deletions lib/data/carp_backend.dart
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class CarpBackend {
authURL: uri,
clientId: 'studies-app',
redirectURI: Uri.parse('carp-studies-auth://auth'),
anonymousRedirectURI: Uri.parse('carp-studies:/anonymous'),
anonymousRedirectURI: Uri.parse('carp-studies-anonymous://anonymous'),
// For authentication at CAWS the path is '/auth/realms/Carp'
discoveryURL: uri.replace(pathSegments: [
'auth',
Expand Down Expand Up @@ -115,12 +115,15 @@ class CarpBackend {
Future<void> authenticateWithMagicLink(String uri) async {
try {
await initialize();
if (Platform.isIOS) {
sleep(const Duration(seconds: 1));
}
user = await CarpAuthService().authenticateWithMagicLink(uri);
LocalSettings().isAnonymous = true;
info('$runtimeType - ANONYMOUS User authenticated - user: $user');
print('$runtimeType - ANONYMOUS User authenticated - user: $user');
Comment on lines -120 to +123

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

why changed to print

} catch (error) {
user = null;
warning('$runtimeType - ANONYMOUS Error authenticating user - $error');
print('$runtimeType - ANONYMOUS Error authenticating user - $error');
}
}

Expand Down
1 change: 0 additions & 1 deletion lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import 'dart:io';

import 'package:app_version_update/data/models/app_version_result.dart';
import 'package:async/async.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/gestures.dart';

import 'package:flutter/material.dart';
Expand Down
7 changes: 6 additions & 1 deletion lib/ui/pages/login_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,15 @@ class _LoginPageState extends State<LoginPage> {
child: TextButton(
onPressed: () async {
bool isConnected = await bloc.checkConnectivity();
print("isConnected: $isConnected");

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

remove print

if (isConnected) {
await bloc.backend.initialize();
await bloc.backend.authenticate();
if (context.mounted) context.go(CarpStudyAppState.homeRoute);
if (context.mounted) {
WidgetsBinding.instance.addPostFrameCallback((_) {
context.go(CarpStudyAppState.homeRoute);
});
}
} else {
showDialog<bool>(
context: context,
Expand Down
Loading
Loading