Merge branch 'develop' into feature/fd-466
This commit is contained in:
commit
78e776a6b5
|
@ -1,10 +1,13 @@
|
|||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
import 'dart:developer';
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:hub/backend/notifications/firebase_messaging_service.dart';
|
||||
import 'package:hub/shared/helpers/base_storage.dart';
|
||||
import 'package:hub/shared/helpers/storage_helper.dart';
|
||||
import 'package:hub/shared/utils/dialog_util.dart';
|
||||
import 'package:hub/shared/utils/log_util.dart';
|
||||
import 'package:hub/shared/utils/validator_util.dart';
|
||||
|
||||
import '/flutter_flow/flutter_flow_util.dart';
|
||||
|
@ -768,7 +771,15 @@ class LoginCall {
|
|||
(await StorageHelper().get(SecureStorageKey.deviceType.value, Storage.SecureStorage)) ?? '';
|
||||
final String description =
|
||||
(await StorageHelper().get(SecureStorageKey.deviceDescription.value, Storage.SecureStorage)) ?? '';
|
||||
final String token = await FirebaseMessagingService.getToken();
|
||||
late final String token;
|
||||
try {
|
||||
token = await FirebaseMessagingService.getToken();
|
||||
if(token == null || token.isEmpty) throw Exception('Token is empty'); }
|
||||
catch (e, s) {
|
||||
token = '';
|
||||
log('Error getting token', error: e, stackTrace: s);
|
||||
LogUtil.requestAPIFailed('login.php', email, "Login", e, s);
|
||||
}
|
||||
|
||||
return ApiManager.instance.makeApiCall(
|
||||
callName: 'login',
|
||||
|
|
|
@ -271,7 +271,7 @@ class _AppState extends State<App> with WidgetsBindingObserver {
|
|||
|
||||
@override
|
||||
void didChangeAppLifecycleState(AppLifecycleState state) async {
|
||||
await LocalizationService.processLocals(context);
|
||||
if(state == AppLifecycleState.resumed) await _initializeNotificationService();
|
||||
}
|
||||
|
||||
@override
|
||||
|
|
|
@ -44,8 +44,7 @@ class AuthenticationService {
|
|||
final ApiCallResponse? response;
|
||||
final LoginCall callback = PhpGroup.loginCall;
|
||||
String deviceDescription = randomString(10, 10, true, false, false);
|
||||
await StorageHelper()
|
||||
.set(SecureStorageKey.deviceDescription.value, deviceDescription, Storage.SecureStorage);
|
||||
await StorageHelper().set(SecureStorageKey.deviceDescription.value, deviceDescription, Storage.SecureStorage);
|
||||
|
||||
final String? devUUID;
|
||||
final String userUUID;
|
||||
|
@ -85,9 +84,7 @@ class AuthenticationService {
|
|||
DialogUtil.error(context, response.jsonBody['error_msg'].toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
} return;
|
||||
} catch (e, s) {
|
||||
DialogUtil.errorDefault(context);
|
||||
LogUtil.requestAPIFailed('login.php', emailAdress.toString(), "Login", e, s);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// ignore_for_file: curly_braces_in_flow_control_structures
|
||||
// ignore_for_file: curly_braces_in_flow_control_structures, use_build_context_synchronously, unrelated_type_equality_checks
|
||||
|
||||
import 'dart:developer';
|
||||
|
||||
|
@ -204,14 +204,6 @@ class LocalizationService {
|
|||
final bool isAuthenticated = userUUID.isNotEmpty && devUUID.isNotEmpty;
|
||||
final bool isDevLinked = !errorMsg.contains('Esse dispositivo nao pertence a esse usuario');
|
||||
log('() => isLinked: $errorMsg');
|
||||
if (isAuthenticated && isDevLinked) await DialogUtil.error(context, errorMsg).whenComplete(() async => await selectLocal(context));
|
||||
if (isAuthenticated && !isDevLinked) {
|
||||
errorMsg = FFLocalizations.of(context).getVariableText(
|
||||
ptText: 'Não foi possível vincular o dispositivo, tente novamente',
|
||||
enText: 'Unable to link device, try again',
|
||||
);
|
||||
await DialogUtil.warning(context, errorMsg);
|
||||
}
|
||||
if (!isAuthenticated) {
|
||||
errorMsg = FFLocalizations.of(context).getVariableText(
|
||||
ptText: 'Erro ao obter credenciais de autenticação',
|
||||
|
@ -220,6 +212,21 @@ class LocalizationService {
|
|||
await DialogUtil.error(context, errorMsg);
|
||||
// await DialogUtil.error(context, errorMsg).whenComplete(() async => await AuthenticationService.signOut(context));
|
||||
}
|
||||
else if (isAuthenticated && !isDevLinked) {
|
||||
final String log = '''
|
||||
|
||||
devUUID: $devUUID
|
||||
userUUID: $userUUID
|
||||
|
||||
''';
|
||||
errorMsg = FFLocalizations.of(context).getVariableText(
|
||||
ptText: 'Não foi possível vincular o dispositivo, tente novamente.',
|
||||
enText: 'Unable to link device, try again',
|
||||
);
|
||||
await DialogUtil.warning(context, errorMsg+log);
|
||||
}
|
||||
else if (isAuthenticated && isDevLinked) await DialogUtil.error(context, errorMsg).whenComplete(() async => await selectLocal(context));
|
||||
|
||||
}
|
||||
|
||||
static Future<bool> _handleUnavailable(BuildContext context, List<dynamic> locals) async {
|
||||
|
|
Loading…
Reference in New Issue