mirror of
https://github.com/wger-project/flutter.git
synced 2026-02-18 00:17:48 +01:00
Remove WGER_API_KEY, this registration key is not needed anymore
This commit is contained in:
4
.github/workflows/build-release.yml
vendored
4
.github/workflows/build-release.yml
vendored
@@ -68,13 +68,9 @@ jobs:
|
||||
|
||||
- name: Build AAB
|
||||
run: flutter build appbundle --release
|
||||
env:
|
||||
WGER_API_KEY: ${{ secrets.WGER_API_KEY }}
|
||||
|
||||
- name: Build APK
|
||||
run: flutter build apk --release
|
||||
env:
|
||||
WGER_API_KEY: ${{ secrets.WGER_API_KEY }}
|
||||
|
||||
- name: Upload build to Play Store
|
||||
run: |
|
||||
|
||||
22
README.md
22
README.md
@@ -43,29 +43,9 @@ Alternatively, you can use the test server (the db is reset every day):
|
||||
Install Flutter and all its dependencies, and create a new virtual device:
|
||||
<https://flutter.dev/docs/get-started/install>.
|
||||
|
||||
The app currently uses flutter 3.22
|
||||
The app currently uses flutter 3.24
|
||||
|
||||
### 3
|
||||
The application will complain about an API key not being set. You can just
|
||||
ignore this during development, this is only important if you want to register
|
||||
directly over the app. If you just want to login, you can skip this section.
|
||||
|
||||
If you want to register directly over the app, you need to set a user on the backend
|
||||
that is allowed to do this. For this, create/register a new user, generate an api key
|
||||
and run ``python3 manage.py add-user-rest theusername`` (you can later list all the
|
||||
registered users with ``python3 manage.py list-users-api``).
|
||||
|
||||
Then create a new file ``wger.properties`` in ``fastlane/metadata/envfiles/`` and
|
||||
add the key:
|
||||
|
||||
```properties
|
||||
WGER_API_KEY=123456
|
||||
```
|
||||
|
||||
Alternatively, add the key as an environment variables, e.g. by running the `source`
|
||||
command on the file.
|
||||
|
||||
### 4
|
||||
|
||||
Start the application with ``flutter run`` or use your IDE
|
||||
(please note that depending on how you run your emulator you will need to change the IP address of
|
||||
|
||||
@@ -30,27 +30,6 @@ if (keystorePropertiesFile.exists()) {
|
||||
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
|
||||
}
|
||||
|
||||
// Key for wger.de REST API
|
||||
def wgerProperties = new Properties()
|
||||
def localMapsPropertiesFile = rootProject.file('../fastlane/metadata/envfiles/wger.properties')
|
||||
if (localMapsPropertiesFile.exists()) {
|
||||
project.logger.info('Load maps properties from local file')
|
||||
localMapsPropertiesFile.withReader('UTF-8') { reader ->
|
||||
wgerProperties.load(reader)
|
||||
}
|
||||
} else {
|
||||
project.logger.info('Load maps properties from environment')
|
||||
try {
|
||||
wgerProperties['WGER_API_KEY'] = System.getenv('WGER_API_KEY')
|
||||
} catch (NullPointerException e) {
|
||||
project.logger.warn('Failed to load WGER_API_KEY from environment.', e)
|
||||
}
|
||||
}
|
||||
def wgerApiKey = wgerProperties.getProperty('WGER_API_KEY')
|
||||
if (wgerApiKey == null) {
|
||||
wgerApiKey = ""
|
||||
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`')
|
||||
}
|
||||
|
||||
android {
|
||||
compileSdkVersion 34
|
||||
@@ -80,7 +59,6 @@ android {
|
||||
targetSdkVersion 34
|
||||
versionCode flutterVersionCode.toInteger()
|
||||
versionName flutterVersionName
|
||||
manifestPlaceholders += [WGER_API_KEY: wgerApiKey]
|
||||
}
|
||||
|
||||
signingConfigs {
|
||||
|
||||
@@ -28,9 +28,6 @@
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:networkSecurityConfig="@xml/network_security_config">
|
||||
|
||||
<meta-data
|
||||
android:name="wger.api_key"
|
||||
android:value="${WGER_API_KEY}" />
|
||||
<meta-data
|
||||
android:name="wger.check_min_app_version"
|
||||
android:value="true" />
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
If we use a new version, update the version used by
|
||||
|
||||
* Github Actions in `android-release.yaml` in this repository
|
||||
* Github Actions in `build-release.yml` in this repository
|
||||
* Fdroid build recipe
|
||||
in [their repo](https://gitlab.com/fdroid/fdroiddata/-/blob/master/metadata/de.wger.flutter.yml).
|
||||
Since this can potentially take some time, it should happen well in advance
|
||||
|
||||
@@ -32,7 +32,6 @@ const TESTSERVER_USER_NAME = 'user';
|
||||
const TESTSERVER_PASSWORD = 'flutteruser';
|
||||
|
||||
/// Keys used in the android manifest
|
||||
const MANIFEST_KEY_API = 'wger.api_key';
|
||||
const MANIFEST_KEY_CHECK_UPDATE = 'wger.check_min_app_version';
|
||||
|
||||
/// Default weight unit is "kg"
|
||||
|
||||
@@ -64,7 +64,6 @@ class AuthProvider with ChangeNotifier {
|
||||
} else if (Platform.isLinux || Platform.isMacOS) {
|
||||
metadata = {
|
||||
MANIFEST_KEY_CHECK_UPDATE: Platform.environment[MANIFEST_KEY_CHECK_UPDATE] ?? '',
|
||||
MANIFEST_KEY_API: Platform.environment[MANIFEST_KEY_API] ?? '',
|
||||
};
|
||||
}
|
||||
} on PlatformException {
|
||||
@@ -105,6 +104,7 @@ class AuthProvider with ChangeNotifier {
|
||||
Map<String, String>? metadata,
|
||||
]) async {
|
||||
metadata ??= this.metadata;
|
||||
|
||||
if (!metadata.containsKey(MANIFEST_KEY_CHECK_UPDATE) ||
|
||||
metadata[MANIFEST_KEY_CHECK_UPDATE] == 'false') {
|
||||
return false;
|
||||
@@ -138,7 +138,6 @@ class AuthProvider with ChangeNotifier {
|
||||
makeUri(serverUrl, REGISTRATION_URL),
|
||||
headers: {
|
||||
HttpHeaders.contentTypeHeader: 'application/json; charset=UTF-8',
|
||||
HttpHeaders.authorizationHeader: 'Token ${metadata[MANIFEST_KEY_API]}',
|
||||
HttpHeaders.userAgentHeader: getAppNameHeader(),
|
||||
HttpHeaders.acceptLanguageHeader: locale,
|
||||
},
|
||||
|
||||
@@ -23,7 +23,6 @@ import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:wger/exceptions/http_exception.dart';
|
||||
import 'package:wger/helpers/consts.dart';
|
||||
import 'package:wger/helpers/misc.dart';
|
||||
import 'package:wger/helpers/ui.dart';
|
||||
import 'package:wger/screens/update_app_screen.dart';
|
||||
import 'package:wger/theme/theme.dart';
|
||||
@@ -37,6 +36,7 @@ enum AuthMode {
|
||||
|
||||
class AuthScreen extends StatelessWidget {
|
||||
const AuthScreen();
|
||||
|
||||
static const routeName = '/auth';
|
||||
|
||||
@override
|
||||
@@ -113,7 +113,6 @@ class _AuthCardState extends State<AuthCard> {
|
||||
bool confirmIsObscure = true;
|
||||
|
||||
final GlobalKey<FormState> _formKey = GlobalKey();
|
||||
bool _canRegister = true;
|
||||
AuthMode _authMode = AuthMode.Login;
|
||||
bool _hideCustomServer = true;
|
||||
final Map<String, String> _authData = {
|
||||
@@ -148,17 +147,6 @@ class _AuthCardState extends State<AuthCard> {
|
||||
_serverUrlController.text = value;
|
||||
});
|
||||
|
||||
// Check if the API key is set
|
||||
//
|
||||
// If not, the user will not be able to register via the app
|
||||
try {
|
||||
final metadata = Provider.of<AuthProvider>(context, listen: false).metadata;
|
||||
if (metadata.containsKey(MANIFEST_KEY_API) && metadata[MANIFEST_KEY_API] == '') {
|
||||
_canRegister = false;
|
||||
}
|
||||
} on PlatformException {
|
||||
_canRegister = false;
|
||||
}
|
||||
_preFillTextfields();
|
||||
}
|
||||
|
||||
@@ -238,11 +226,6 @@ class _AuthCardState extends State<AuthCard> {
|
||||
}
|
||||
|
||||
void _switchAuthMode() {
|
||||
if (!_canRegister) {
|
||||
launchURL(DEFAULT_SERVER_PROD, context);
|
||||
return;
|
||||
}
|
||||
|
||||
if (_authMode == AuthMode.Login) {
|
||||
setState(() {
|
||||
_authMode = AuthMode.Signup;
|
||||
@@ -482,9 +465,9 @@ class _AuthCardState extends State<AuthCard> {
|
||||
},
|
||||
child: Container(
|
||||
color: Colors.transparent,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
child: Column(
|
||||
children: [
|
||||
// TODO: i18n!
|
||||
Text(
|
||||
text.substring(0, text.lastIndexOf('?') + 1),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user