Skip to content

Commit 3978b4b

Browse files
committed
Remove WGER_API_KEY, this registration key is not needed anymore
1 parent 0a40758 commit 3978b4b

File tree

8 files changed

+6
-74
lines changed

8 files changed

+6
-74
lines changed

.github/workflows/build-release.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,9 @@ jobs:
6868
6969
- name: Build AAB
7070
run: flutter build appbundle --release
71-
env:
72-
WGER_API_KEY: ${{ secrets.WGER_API_KEY }}
7371

7472
- name: Build APK
7573
run: flutter build apk --release
76-
env:
77-
WGER_API_KEY: ${{ secrets.WGER_API_KEY }}
7874

7975
- name: Upload build to Play Store
8076
run: |

README.md

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -43,29 +43,9 @@ Alternatively, you can use the test server (the db is reset every day):
4343
Install Flutter and all its dependencies, and create a new virtual device:
4444
<https://flutter.dev/docs/get-started/install>.
4545

46-
The app currently uses flutter 3.22
46+
The app currently uses flutter 3.24
4747

4848
### 3
49-
The application will complain about an API key not being set. You can just
50-
ignore this during development, this is only important if you want to register
51-
directly over the app. If you just want to login, you can skip this section.
52-
53-
If you want to register directly over the app, you need to set a user on the backend
54-
that is allowed to do this. For this, create/register a new user, generate an api key
55-
and run ``python3 manage.py add-user-rest theusername`` (you can later list all the
56-
registered users with ``python3 manage.py list-users-api``).
57-
58-
Then create a new file ``wger.properties`` in ``fastlane/metadata/envfiles/`` and
59-
add the key:
60-
61-
```properties
62-
WGER_API_KEY=123456
63-
```
64-
65-
Alternatively, add the key as an environment variables, e.g. by running the `source`
66-
command on the file.
67-
68-
### 4
6949

7050
Start the application with ``flutter run`` or use your IDE
7151
(please note that depending on how you run your emulator you will need to change the IP address of

android/app/build.gradle

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -30,27 +30,6 @@ if (keystorePropertiesFile.exists()) {
3030
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
3131
}
3232

33-
// Key for wger.de REST API
34-
def wgerProperties = new Properties()
35-
def localMapsPropertiesFile = rootProject.file('../fastlane/metadata/envfiles/wger.properties')
36-
if (localMapsPropertiesFile.exists()) {
37-
project.logger.info('Load maps properties from local file')
38-
localMapsPropertiesFile.withReader('UTF-8') { reader ->
39-
wgerProperties.load(reader)
40-
}
41-
} else {
42-
project.logger.info('Load maps properties from environment')
43-
try {
44-
wgerProperties['WGER_API_KEY'] = System.getenv('WGER_API_KEY')
45-
} catch (NullPointerException e) {
46-
project.logger.warn('Failed to load WGER_API_KEY from environment.', e)
47-
}
48-
}
49-
def wgerApiKey = wgerProperties.getProperty('WGER_API_KEY')
50-
if (wgerApiKey == null) {
51-
wgerApiKey = ""
52-
project.logger.error('Wger Api Key not configured. Set it in `/fastlane/metadata/android/envfiles/wger.properties` or in the environment variable `WGER_API_KEY`')
53-
}
5433

5534
android {
5635
compileSdkVersion 34
@@ -80,7 +59,6 @@ android {
8059
targetSdkVersion 34
8160
versionCode flutterVersionCode.toInteger()
8261
versionName flutterVersionName
83-
manifestPlaceholders += [WGER_API_KEY: wgerApiKey]
8462
}
8563

8664
signingConfigs {

android/app/src/main/AndroidManifest.xml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,6 @@
2828
android:icon="@mipmap/ic_launcher"
2929
android:networkSecurityConfig="@xml/network_security_config">
3030

31-
<meta-data
32-
android:name="wger.api_key"
33-
android:value="${WGER_API_KEY}" />
3431
<meta-data
3532
android:name="wger.check_min_app_version"
3633
android:value="true" />

fastlane/metadata/android/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
If we use a new version, update the version used by
66

7-
* Github Actions in `android-release.yaml` in this repository
7+
* Github Actions in `build-release.yml` in this repository
88
* Fdroid build recipe
99
in [their repo](https://gitlab.com/fdroid/fdroiddata/-/blob/master/metadata/de.wger.flutter.yml).
1010
Since this can potentially take some time, it should happen well in advance

lib/helpers/consts.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ const TESTSERVER_USER_NAME = 'user';
3232
const TESTSERVER_PASSWORD = 'flutteruser';
3333

3434
/// Keys used in the android manifest
35-
const MANIFEST_KEY_API = 'wger.api_key';
3635
const MANIFEST_KEY_CHECK_UPDATE = 'wger.check_min_app_version';
3736

3837
/// Default weight unit is "kg"

lib/providers/auth.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ class AuthProvider with ChangeNotifier {
6464
} else if (Platform.isLinux || Platform.isMacOS) {
6565
metadata = {
6666
MANIFEST_KEY_CHECK_UPDATE: Platform.environment[MANIFEST_KEY_CHECK_UPDATE] ?? '',
67-
MANIFEST_KEY_API: Platform.environment[MANIFEST_KEY_API] ?? '',
6867
};
6968
}
7069
} on PlatformException {
@@ -105,6 +104,7 @@ class AuthProvider with ChangeNotifier {
105104
Map<String, String>? metadata,
106105
]) async {
107106
metadata ??= this.metadata;
107+
108108
if (!metadata.containsKey(MANIFEST_KEY_CHECK_UPDATE) ||
109109
metadata[MANIFEST_KEY_CHECK_UPDATE] == 'false') {
110110
return false;
@@ -138,7 +138,6 @@ class AuthProvider with ChangeNotifier {
138138
makeUri(serverUrl, REGISTRATION_URL),
139139
headers: {
140140
HttpHeaders.contentTypeHeader: 'application/json; charset=UTF-8',
141-
HttpHeaders.authorizationHeader: 'Token ${metadata[MANIFEST_KEY_API]}',
142141
HttpHeaders.userAgentHeader: getAppNameHeader(),
143142
HttpHeaders.acceptLanguageHeader: locale,
144143
},

lib/screens/auth_screen.dart

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import 'package:flutter_gen/gen_l10n/app_localizations.dart';
2323
import 'package:provider/provider.dart';
2424
import 'package:wger/exceptions/http_exception.dart';
2525
import 'package:wger/helpers/consts.dart';
26-
import 'package:wger/helpers/misc.dart';
2726
import 'package:wger/helpers/ui.dart';
2827
import 'package:wger/screens/update_app_screen.dart';
2928
import 'package:wger/theme/theme.dart';
@@ -37,6 +36,7 @@ enum AuthMode {
3736

3837
class AuthScreen extends StatelessWidget {
3938
const AuthScreen();
39+
4040
static const routeName = '/auth';
4141

4242
@override
@@ -113,7 +113,6 @@ class _AuthCardState extends State<AuthCard> {
113113
bool confirmIsObscure = true;
114114

115115
final GlobalKey<FormState> _formKey = GlobalKey();
116-
bool _canRegister = true;
117116
AuthMode _authMode = AuthMode.Login;
118117
bool _hideCustomServer = true;
119118
final Map<String, String> _authData = {
@@ -148,17 +147,6 @@ class _AuthCardState extends State<AuthCard> {
148147
_serverUrlController.text = value;
149148
});
150149

151-
// Check if the API key is set
152-
//
153-
// If not, the user will not be able to register via the app
154-
try {
155-
final metadata = Provider.of<AuthProvider>(context, listen: false).metadata;
156-
if (metadata.containsKey(MANIFEST_KEY_API) && metadata[MANIFEST_KEY_API] == '') {
157-
_canRegister = false;
158-
}
159-
} on PlatformException {
160-
_canRegister = false;
161-
}
162150
_preFillTextfields();
163151
}
164152

@@ -238,11 +226,6 @@ class _AuthCardState extends State<AuthCard> {
238226
}
239227

240228
void _switchAuthMode() {
241-
if (!_canRegister) {
242-
launchURL(DEFAULT_SERVER_PROD, context);
243-
return;
244-
}
245-
246229
if (_authMode == AuthMode.Login) {
247230
setState(() {
248231
_authMode = AuthMode.Signup;
@@ -482,9 +465,9 @@ class _AuthCardState extends State<AuthCard> {
482465
},
483466
child: Container(
484467
color: Colors.transparent,
485-
child: Row(
486-
mainAxisAlignment: MainAxisAlignment.center,
468+
child: Column(
487469
children: [
470+
// TODO: i18n!
488471
Text(
489472
text.substring(0, text.lastIndexOf('?') + 1),
490473
),

0 commit comments

Comments
 (0)