move auth feature from container to profile
This commit is contained in:
@@ -273,16 +273,6 @@ class TabRepository extends _$TabRepository {
|
||||
if (!ref.mounted) return false;
|
||||
|
||||
if (containerData != null) {
|
||||
if (containerData.metadata.authSettings.authenticationRequired) {
|
||||
// ignore: only_use_keep_alive_inside_keep_alive
|
||||
if (containerData.id != ref.read(selectedContainerProvider)) {
|
||||
logger.w(
|
||||
'Tried to open authenticated tab $tabId but container not selected',
|
||||
);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (containerData.metadata.useProxy) {
|
||||
final proxyPluginHealthy = await GeckoContainerProxyService()
|
||||
.healthcheck();
|
||||
@@ -380,20 +370,15 @@ class TabRepository extends _$TabRepository {
|
||||
|
||||
if (!ref.mounted) return;
|
||||
|
||||
//We only take containers without authentication!
|
||||
final availableContainers = await ref
|
||||
.read(containerRepositoryProvider.notifier)
|
||||
.getAllContainersWithCount();
|
||||
|
||||
final nextAvailableContainerUnauthenticated = availableContainers
|
||||
.firstWhereOrNull(
|
||||
(container) =>
|
||||
container.metadata.authSettings.authenticationRequired == false,
|
||||
);
|
||||
final nextAvailableContainer = availableContainers.firstOrNull;
|
||||
|
||||
if (!ref.mounted) return;
|
||||
|
||||
final nextContainerTabs = await nextAvailableContainerUnauthenticated
|
||||
final nextContainerTabs = await nextAvailableContainer
|
||||
.mapNotNull(
|
||||
(container) => ref
|
||||
.read(containerRepositoryProvider.notifier)
|
||||
@@ -404,15 +389,6 @@ class TabRepository extends _$TabRepository {
|
||||
if (nextContainerTabs.isNotEmpty) {
|
||||
return _tabsService.selectTab(tabId: nextContainerTabs!.first);
|
||||
}
|
||||
|
||||
if (ref.mounted &&
|
||||
availableContainers.any(
|
||||
(container) => container.metadata.authSettings.authenticationRequired,
|
||||
)) {
|
||||
//Last resort push new tab to avoid any authenticated tab is selected
|
||||
// ignore: avoid_redundant_argument_values
|
||||
await addTab(selectTab: true, private: false);
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> closeTab(String tabId) async {
|
||||
|
||||
@@ -41,7 +41,7 @@ final class TabRepositoryProvider
|
||||
}
|
||||
}
|
||||
|
||||
String _$tabRepositoryHash() => r'db35cef59703f15f1b099b6adb42f7623bec612f';
|
||||
String _$tabRepositoryHash() => r'f0ff983df4115bfed7ff3dbc8994592bc46a1daa';
|
||||
|
||||
abstract class _$TabRepository extends $Notifier<void> {
|
||||
void build();
|
||||
|
||||
+2
-11
@@ -25,7 +25,6 @@ import 'package:go_router/go_router.dart';
|
||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
import 'package:weblibre/features/geckoview/domain/repositories/tab.dart';
|
||||
import 'package:weblibre/features/geckoview/features/tabs/data/models/container_data.dart';
|
||||
import 'package:weblibre/features/geckoview/features/tabs/domain/providers/selected_container.dart';
|
||||
import 'package:weblibre/features/geckoview/features/tabs/presentation/widgets/container_chips.dart';
|
||||
import 'package:weblibre/presentation/icons/weblibre_icons.dart';
|
||||
import 'package:weblibre/utils/form_validators.dart';
|
||||
@@ -72,16 +71,8 @@ class OpenSharedContent extends HookConsumerWidget {
|
||||
child: ContainerChips(
|
||||
displayMenu: false,
|
||||
selectedContainer: selectedContainer.value,
|
||||
onSelected: (container) async {
|
||||
if (container != null) {
|
||||
if (await ref
|
||||
.read(selectedContainerProvider.notifier)
|
||||
.authenticateContainer(container)) {
|
||||
selectedContainer.value = container;
|
||||
}
|
||||
} else {
|
||||
selectedContainer.value = container;
|
||||
}
|
||||
onSelected: (container) {
|
||||
selectedContainer.value = container;
|
||||
},
|
||||
onDeleted: (container) {
|
||||
selectedContainer.value = null;
|
||||
|
||||
+5
@@ -53,6 +53,7 @@ import 'package:weblibre/features/geckoview/features/tabs/domain/repositories/co
|
||||
import 'package:weblibre/features/geckoview/features/tabs/domain/repositories/tab.dart';
|
||||
import 'package:weblibre/features/share_intent/domain/entities/shared_content.dart';
|
||||
import 'package:weblibre/features/user/data/models/general_settings.dart';
|
||||
import 'package:weblibre/features/user/domain/providers/profile_auth.dart';
|
||||
import 'package:weblibre/features/user/domain/repositories/cache.dart';
|
||||
import 'package:weblibre/features/user/domain/repositories/general_settings.dart';
|
||||
import 'package:weblibre/features/user/domain/services/local_authentication.dart';
|
||||
@@ -553,6 +554,10 @@ class _BrowserViewState extends ConsumerState<BrowserView>
|
||||
_timerPaused = false;
|
||||
}
|
||||
|
||||
unawaited(
|
||||
ref.read(profileAuthStateProvider.notifier).revalidateAfterResume(),
|
||||
);
|
||||
|
||||
if (_suggestionCountTime != null &&
|
||||
DateTime.now().difference(_suggestionCountTime!) >
|
||||
widget.suggestionTimeout) {
|
||||
|
||||
@@ -338,19 +338,8 @@ class SearchScreen extends HookConsumerWidget {
|
||||
height: 48,
|
||||
child: ContainerChips(
|
||||
selectedContainer: selectedContainer.value,
|
||||
onSelected: (container) async {
|
||||
if (container != null) {
|
||||
if (await ref
|
||||
.read(
|
||||
selectedContainerProvider
|
||||
.notifier,
|
||||
)
|
||||
.authenticateContainer(container)) {
|
||||
selectedContainer.value = container;
|
||||
}
|
||||
} else {
|
||||
selectedContainer.value = container;
|
||||
}
|
||||
onSelected: (container) {
|
||||
selectedContainer.value = container;
|
||||
},
|
||||
onDeleted: (container) {
|
||||
selectedContainer.value = null;
|
||||
|
||||
+2
-11
@@ -101,7 +101,6 @@ class TabSearch extends HookConsumerWidget {
|
||||
.then((containers) {
|
||||
return containers.firstWhereOrNull(
|
||||
(container) =>
|
||||
!container.metadata.authSettings.authenticationRequired &&
|
||||
containerIdsWithResults.value.containsKey(container.id),
|
||||
);
|
||||
});
|
||||
@@ -145,16 +144,8 @@ class TabSearch extends HookConsumerWidget {
|
||||
showUnassignedChip: containerIdsWithResults.value.containsKey(
|
||||
null,
|
||||
),
|
||||
onSelected: (container) async {
|
||||
if (container != null) {
|
||||
if (await ref
|
||||
.read(selectedContainerProvider.notifier)
|
||||
.authenticateContainer(container)) {
|
||||
selectedContainer.value = container;
|
||||
}
|
||||
} else {
|
||||
selectedContainer.value = container;
|
||||
}
|
||||
onSelected: (container) {
|
||||
selectedContainer.value = container;
|
||||
},
|
||||
onDeleted: (container) {
|
||||
selectedContainer.value = null;
|
||||
|
||||
@@ -26,49 +26,12 @@ import 'package:weblibre/data/database/converters/icon_data.dart';
|
||||
|
||||
part 'container_data.g.dart';
|
||||
|
||||
@CopyWith()
|
||||
@JsonSerializable()
|
||||
class ContainerAuthSettings with FastEquatable {
|
||||
final bool authenticationRequired;
|
||||
final bool lockOnAppBackground;
|
||||
final Duration? lockTimeout;
|
||||
|
||||
ContainerAuthSettings({
|
||||
required this.authenticationRequired,
|
||||
required this.lockOnAppBackground,
|
||||
required this.lockTimeout,
|
||||
});
|
||||
|
||||
ContainerAuthSettings.withDefaults({
|
||||
bool? authenticationRequired,
|
||||
bool? lockOnAppBackground,
|
||||
Duration? lockTimeout,
|
||||
}) : this(
|
||||
authenticationRequired: authenticationRequired ?? false,
|
||||
lockOnAppBackground: lockOnAppBackground ?? false,
|
||||
lockTimeout: lockTimeout,
|
||||
);
|
||||
|
||||
factory ContainerAuthSettings.fromJson(Map<String, dynamic> json) =>
|
||||
_$ContainerAuthSettingsFromJson(json);
|
||||
|
||||
Map<String, dynamic> toJson() => _$ContainerAuthSettingsToJson(this);
|
||||
|
||||
@override
|
||||
List<Object?> get hashParameters => [
|
||||
authenticationRequired,
|
||||
lockOnAppBackground,
|
||||
lockTimeout,
|
||||
];
|
||||
}
|
||||
|
||||
@CopyWith()
|
||||
@JsonSerializable(constructor: 'withDefaults')
|
||||
class ContainerMetadata with FastEquatable {
|
||||
@IconDataJsonConverter()
|
||||
final IconData? iconData;
|
||||
final String? contextualIdentity;
|
||||
final ContainerAuthSettings authSettings;
|
||||
|
||||
@JsonKey(defaultValue: false)
|
||||
final bool useProxy;
|
||||
@@ -81,7 +44,6 @@ class ContainerMetadata with FastEquatable {
|
||||
ContainerMetadata({
|
||||
required this.iconData,
|
||||
required this.contextualIdentity,
|
||||
required this.authSettings,
|
||||
required this.useProxy,
|
||||
required this.clearDataOnExit,
|
||||
required this.assignedSites,
|
||||
@@ -90,14 +52,12 @@ class ContainerMetadata with FastEquatable {
|
||||
ContainerMetadata.withDefaults({
|
||||
IconData? iconData,
|
||||
String? contextualIdentity,
|
||||
ContainerAuthSettings? authSettings,
|
||||
bool? useProxy,
|
||||
bool? clearDataOnExit,
|
||||
List<Uri>? assignedSites,
|
||||
}) : this(
|
||||
iconData: iconData,
|
||||
contextualIdentity: contextualIdentity,
|
||||
authSettings: authSettings ?? ContainerAuthSettings.withDefaults(),
|
||||
useProxy: useProxy ?? false,
|
||||
clearDataOnExit: clearDataOnExit ?? false,
|
||||
assignedSites: assignedSites,
|
||||
@@ -112,7 +72,6 @@ class ContainerMetadata with FastEquatable {
|
||||
List<Object?> get hashParameters => [
|
||||
iconData,
|
||||
contextualIdentity,
|
||||
authSettings,
|
||||
useProxy,
|
||||
clearDataOnExit,
|
||||
assignedSites,
|
||||
|
||||
@@ -6,96 +6,11 @@ part of 'container_data.dart';
|
||||
// CopyWithGenerator
|
||||
// **************************************************************************
|
||||
|
||||
abstract class _$ContainerAuthSettingsCWProxy {
|
||||
ContainerAuthSettings authenticationRequired(bool authenticationRequired);
|
||||
|
||||
ContainerAuthSettings lockOnAppBackground(bool lockOnAppBackground);
|
||||
|
||||
ContainerAuthSettings lockTimeout(Duration? lockTimeout);
|
||||
|
||||
/// Creates a new instance with the provided field values.
|
||||
/// Passing `null` to a nullable field nullifies it, while `null` for a non-nullable field is ignored. To update a single field use `ContainerAuthSettings(...).copyWith.fieldName(value)`.
|
||||
///
|
||||
/// Example:
|
||||
/// ```dart
|
||||
/// ContainerAuthSettings(...).copyWith(id: 12, name: "My name")
|
||||
/// ```
|
||||
ContainerAuthSettings call({
|
||||
bool authenticationRequired,
|
||||
bool lockOnAppBackground,
|
||||
Duration? lockTimeout,
|
||||
});
|
||||
}
|
||||
|
||||
/// Callable proxy for `copyWith` functionality.
|
||||
/// Use as `instanceOfContainerAuthSettings.copyWith(...)` or call `instanceOfContainerAuthSettings.copyWith.fieldName(value)` for a single field.
|
||||
class _$ContainerAuthSettingsCWProxyImpl
|
||||
implements _$ContainerAuthSettingsCWProxy {
|
||||
const _$ContainerAuthSettingsCWProxyImpl(this._value);
|
||||
|
||||
final ContainerAuthSettings _value;
|
||||
|
||||
@override
|
||||
ContainerAuthSettings authenticationRequired(bool authenticationRequired) =>
|
||||
call(authenticationRequired: authenticationRequired);
|
||||
|
||||
@override
|
||||
ContainerAuthSettings lockOnAppBackground(bool lockOnAppBackground) =>
|
||||
call(lockOnAppBackground: lockOnAppBackground);
|
||||
|
||||
@override
|
||||
ContainerAuthSettings lockTimeout(Duration? lockTimeout) =>
|
||||
call(lockTimeout: lockTimeout);
|
||||
|
||||
@override
|
||||
/// Creates a new instance with the provided field values.
|
||||
/// Passing `null` to a nullable field nullifies it, while `null` for a non-nullable field is ignored. To update a single field use `ContainerAuthSettings(...).copyWith.fieldName(value)`.
|
||||
///
|
||||
/// Example:
|
||||
/// ```dart
|
||||
/// ContainerAuthSettings(...).copyWith(id: 12, name: "My name")
|
||||
/// ```
|
||||
ContainerAuthSettings call({
|
||||
Object? authenticationRequired = const $CopyWithPlaceholder(),
|
||||
Object? lockOnAppBackground = const $CopyWithPlaceholder(),
|
||||
Object? lockTimeout = const $CopyWithPlaceholder(),
|
||||
}) {
|
||||
return ContainerAuthSettings(
|
||||
authenticationRequired:
|
||||
authenticationRequired == const $CopyWithPlaceholder() ||
|
||||
authenticationRequired == null
|
||||
? _value.authenticationRequired
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: authenticationRequired as bool,
|
||||
lockOnAppBackground:
|
||||
lockOnAppBackground == const $CopyWithPlaceholder() ||
|
||||
lockOnAppBackground == null
|
||||
? _value.lockOnAppBackground
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: lockOnAppBackground as bool,
|
||||
lockTimeout: lockTimeout == const $CopyWithPlaceholder()
|
||||
? _value.lockTimeout
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: lockTimeout as Duration?,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
extension $ContainerAuthSettingsCopyWith on ContainerAuthSettings {
|
||||
/// Returns a callable class used to build a new instance with modified fields.
|
||||
/// Example: `instanceOfContainerAuthSettings.copyWith(...)` or `instanceOfContainerAuthSettings.copyWith.fieldName(...)`.
|
||||
// ignore: library_private_types_in_public_api
|
||||
_$ContainerAuthSettingsCWProxy get copyWith =>
|
||||
_$ContainerAuthSettingsCWProxyImpl(this);
|
||||
}
|
||||
|
||||
abstract class _$ContainerMetadataCWProxy {
|
||||
ContainerMetadata iconData(IconData? iconData);
|
||||
|
||||
ContainerMetadata contextualIdentity(String? contextualIdentity);
|
||||
|
||||
ContainerMetadata authSettings(ContainerAuthSettings authSettings);
|
||||
|
||||
ContainerMetadata useProxy(bool useProxy);
|
||||
|
||||
ContainerMetadata clearDataOnExit(bool clearDataOnExit);
|
||||
@@ -112,7 +27,6 @@ abstract class _$ContainerMetadataCWProxy {
|
||||
ContainerMetadata call({
|
||||
IconData? iconData,
|
||||
String? contextualIdentity,
|
||||
ContainerAuthSettings authSettings,
|
||||
bool useProxy,
|
||||
bool clearDataOnExit,
|
||||
List<Uri>? assignedSites,
|
||||
@@ -133,10 +47,6 @@ class _$ContainerMetadataCWProxyImpl implements _$ContainerMetadataCWProxy {
|
||||
ContainerMetadata contextualIdentity(String? contextualIdentity) =>
|
||||
call(contextualIdentity: contextualIdentity);
|
||||
|
||||
@override
|
||||
ContainerMetadata authSettings(ContainerAuthSettings authSettings) =>
|
||||
call(authSettings: authSettings);
|
||||
|
||||
@override
|
||||
ContainerMetadata useProxy(bool useProxy) => call(useProxy: useProxy);
|
||||
|
||||
@@ -159,7 +69,6 @@ class _$ContainerMetadataCWProxyImpl implements _$ContainerMetadataCWProxy {
|
||||
ContainerMetadata call({
|
||||
Object? iconData = const $CopyWithPlaceholder(),
|
||||
Object? contextualIdentity = const $CopyWithPlaceholder(),
|
||||
Object? authSettings = const $CopyWithPlaceholder(),
|
||||
Object? useProxy = const $CopyWithPlaceholder(),
|
||||
Object? clearDataOnExit = const $CopyWithPlaceholder(),
|
||||
Object? assignedSites = const $CopyWithPlaceholder(),
|
||||
@@ -173,11 +82,6 @@ class _$ContainerMetadataCWProxyImpl implements _$ContainerMetadataCWProxy {
|
||||
? _value.contextualIdentity
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: contextualIdentity as String?,
|
||||
authSettings:
|
||||
authSettings == const $CopyWithPlaceholder() || authSettings == null
|
||||
? _value.authSettings
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
: authSettings as ContainerAuthSettings,
|
||||
useProxy: useProxy == const $CopyWithPlaceholder() || useProxy == null
|
||||
? _value.useProxy
|
||||
// ignore: cast_nullable_to_non_nullable
|
||||
@@ -294,24 +198,6 @@ extension $ContainerDataCopyWith on ContainerData {
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
ContainerAuthSettings _$ContainerAuthSettingsFromJson(
|
||||
Map<String, dynamic> json,
|
||||
) => ContainerAuthSettings(
|
||||
authenticationRequired: json['authenticationRequired'] as bool,
|
||||
lockOnAppBackground: json['lockOnAppBackground'] as bool,
|
||||
lockTimeout: json['lockTimeout'] == null
|
||||
? null
|
||||
: Duration(microseconds: (json['lockTimeout'] as num).toInt()),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$ContainerAuthSettingsToJson(
|
||||
ContainerAuthSettings instance,
|
||||
) => <String, dynamic>{
|
||||
'authenticationRequired': instance.authenticationRequired,
|
||||
'lockOnAppBackground': instance.lockOnAppBackground,
|
||||
'lockTimeout': instance.lockTimeout?.inMicroseconds,
|
||||
};
|
||||
|
||||
ContainerMetadata _$ContainerMetadataFromJson(Map<String, dynamic> json) =>
|
||||
ContainerMetadata.withDefaults(
|
||||
iconData: _$JsonConverterFromJson<Map<String, dynamic>, IconData>(
|
||||
@@ -319,11 +205,6 @@ ContainerMetadata _$ContainerMetadataFromJson(Map<String, dynamic> json) =>
|
||||
const IconDataJsonConverter().fromJson,
|
||||
),
|
||||
contextualIdentity: json['contextualIdentity'] as String?,
|
||||
authSettings: json['authSettings'] == null
|
||||
? null
|
||||
: ContainerAuthSettings.fromJson(
|
||||
json['authSettings'] as Map<String, dynamic>,
|
||||
),
|
||||
useProxy: json['useProxy'] as bool? ?? false,
|
||||
clearDataOnExit: json['clearDataOnExit'] as bool? ?? false,
|
||||
assignedSites: (json['assignedSites'] as List<dynamic>?)
|
||||
@@ -339,7 +220,6 @@ Map<String, dynamic> _$ContainerMetadataToJson(
|
||||
const IconDataJsonConverter().toJson,
|
||||
),
|
||||
'contextualIdentity': instance.contextualIdentity,
|
||||
'authSettings': instance.authSettings.toJson(),
|
||||
'useProxy': instance.useProxy,
|
||||
'clearDataOnExit': instance.clearDataOnExit,
|
||||
'assignedSites': instance.assignedSites?.map((e) => e.toString()).toList(),
|
||||
|
||||
@@ -27,7 +27,6 @@ import 'package:weblibre/features/geckoview/features/tabs/data/providers.dart';
|
||||
import 'package:weblibre/features/geckoview/features/tabs/domain/providers.dart';
|
||||
import 'package:weblibre/features/geckoview/features/tabs/domain/repositories/container.dart';
|
||||
import 'package:weblibre/features/geckoview/features/tabs/domain/repositories/tab.dart';
|
||||
import 'package:weblibre/features/user/domain/services/local_authentication.dart';
|
||||
|
||||
part 'selected_container.g.dart';
|
||||
|
||||
@@ -45,48 +44,23 @@ class SelectedContainer extends _$SelectedContainer {
|
||||
return null;
|
||||
}
|
||||
|
||||
Future<bool> authenticateContainer(ContainerData container) async {
|
||||
var passAuth = false;
|
||||
if (container.metadata.authSettings.authenticationRequired) {
|
||||
final authResult = await ref
|
||||
.read(localAuthenticationServiceProvider.notifier)
|
||||
.authenticate(
|
||||
authKey: 'container_access::${container.id}',
|
||||
localizedReason: 'Require authentication for container',
|
||||
settings: container.metadata.authSettings,
|
||||
useAuthCache: true,
|
||||
);
|
||||
|
||||
if (authResult) {
|
||||
passAuth = true;
|
||||
}
|
||||
} else {
|
||||
passAuth = true;
|
||||
}
|
||||
|
||||
return passAuth;
|
||||
}
|
||||
|
||||
Future<SetContainerResult> setContainerId(String id) async {
|
||||
final container = await ref
|
||||
.read(containerRepositoryProvider.notifier)
|
||||
.getContainerData(id);
|
||||
|
||||
if (ref.mounted && container != null) {
|
||||
final passAuth = await authenticateContainer(container);
|
||||
if (passAuth) {
|
||||
if (container.metadata.useProxy) {
|
||||
final proxyPluginHealthy = await GeckoContainerProxyService()
|
||||
.healthcheck();
|
||||
if (container.metadata.useProxy) {
|
||||
final proxyPluginHealthy = await GeckoContainerProxyService()
|
||||
.healthcheck();
|
||||
|
||||
if (proxyPluginHealthy) {
|
||||
state = id;
|
||||
return SetContainerResult.successHasProxy;
|
||||
}
|
||||
} else {
|
||||
if (proxyPluginHealthy) {
|
||||
state = id;
|
||||
return SetContainerResult.success;
|
||||
return SetContainerResult.successHasProxy;
|
||||
}
|
||||
} else {
|
||||
state = id;
|
||||
return SetContainerResult.success;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ final class SelectedContainerProvider
|
||||
}
|
||||
}
|
||||
|
||||
String _$selectedContainerHash() => r'e1d20f0c2e7764e82937ba486de52c92184c0e4a';
|
||||
String _$selectedContainerHash() => r'0ffa17823ec95c94b9cf9b2d005de19d6ff992f8';
|
||||
|
||||
abstract class _$SelectedContainer extends $Notifier<String?> {
|
||||
String? build();
|
||||
|
||||
@@ -32,19 +32,10 @@ import 'package:weblibre/features/geckoview/features/tabs/presentation/dialogs/d
|
||||
import 'package:weblibre/features/geckoview/features/tabs/presentation/screens/container_sites.dart';
|
||||
import 'package:weblibre/features/geckoview/features/tabs/presentation/widgets/color_picker_dialog.dart';
|
||||
import 'package:weblibre/features/geckoview/features/tabs/utils/container_colors.dart';
|
||||
import 'package:weblibre/features/user/domain/services/local_authentication.dart';
|
||||
import 'package:weblibre/presentation/icons/tor_icons.dart';
|
||||
|
||||
enum _DialogMode { create, edit }
|
||||
|
||||
const _timeoutOptions = <DropdownMenuItem<Duration?>>[
|
||||
DropdownMenuItem(child: Text('Immediately')),
|
||||
DropdownMenuItem(value: Duration(minutes: 1), child: Text('1 minute')),
|
||||
DropdownMenuItem(value: Duration(minutes: 5), child: Text('5 minutes')),
|
||||
DropdownMenuItem(value: Duration(minutes: 15), child: Text('15 minutes')),
|
||||
DropdownMenuItem(value: Duration(hours: 1), child: Text('1 hour')),
|
||||
];
|
||||
|
||||
class ContainerEditScreen extends HookConsumerWidget {
|
||||
final _DialogMode _mode;
|
||||
|
||||
@@ -77,7 +68,6 @@ class ContainerEditScreen extends HookConsumerWidget {
|
||||
final contextualIdentity = useState(
|
||||
initialContainer.metadata.contextualIdentity,
|
||||
);
|
||||
final authSettings = useState(initialContainer.metadata.authSettings);
|
||||
final useProxy = useState(initialContainer.metadata.useProxy);
|
||||
final clearDataOnExit = useState(initialContainer.metadata.clearDataOnExit);
|
||||
final assignedSites = useState(initialContainer.metadata.assignedSites);
|
||||
@@ -106,7 +96,6 @@ class ContainerEditScreen extends HookConsumerWidget {
|
||||
color: selectedColor.value,
|
||||
metadata: initialContainer.metadata.copyWith(
|
||||
contextualIdentity: contextualIdentity.value,
|
||||
authSettings: authSettings.value,
|
||||
useProxy: useProxy.value && contextualIdentity.value != null,
|
||||
clearDataOnExit:
|
||||
clearDataOnExit.value && contextualIdentity.value != null,
|
||||
@@ -114,24 +103,6 @@ class ContainerEditScreen extends HookConsumerWidget {
|
||||
),
|
||||
);
|
||||
|
||||
//Check for permissions, when auth is set or getting set
|
||||
if (initialContainer
|
||||
.metadata
|
||||
.authSettings
|
||||
.authenticationRequired ||
|
||||
container.metadata.authSettings.authenticationRequired) {
|
||||
final authResult = await ref
|
||||
.read(localAuthenticationServiceProvider.notifier)
|
||||
.authenticate(
|
||||
authKey: 'container_access::${container.id}',
|
||||
localizedReason: 'Require authentication for container',
|
||||
);
|
||||
|
||||
if (!authResult) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
switch (_mode) {
|
||||
case _DialogMode.create:
|
||||
await ref
|
||||
@@ -283,48 +254,6 @@ class ContainerEditScreen extends HookConsumerWidget {
|
||||
}
|
||||
: null,
|
||||
),
|
||||
SwitchListTile.adaptive(
|
||||
value: authSettings.value.authenticationRequired,
|
||||
title: const Text('Require Authentication'),
|
||||
secondary: const Icon(MdiIcons.fingerprint),
|
||||
contentPadding: EdgeInsets.zero,
|
||||
onChanged: (value) {
|
||||
authSettings.value = authSettings.value.copyWith
|
||||
.authenticationRequired(value);
|
||||
},
|
||||
),
|
||||
if (authSettings.value.authenticationRequired)
|
||||
CheckboxListTile.adaptive(
|
||||
value: authSettings.value.lockOnAppBackground,
|
||||
title: const Text('Auto-lock on background'),
|
||||
controlAffinity: ListTileControlAffinity.leading,
|
||||
onChanged: (value) {
|
||||
authSettings.value = authSettings.value.copyWith
|
||||
.lockOnAppBackground(value!);
|
||||
},
|
||||
),
|
||||
if (authSettings.value.authenticationRequired)
|
||||
CheckboxListTile.adaptive(
|
||||
value: authSettings.value.lockTimeout != null,
|
||||
title: const Text('Timeout'),
|
||||
controlAffinity: ListTileControlAffinity.leading,
|
||||
onChanged: (value) {
|
||||
final newValue = value!
|
||||
? _timeoutOptions[1].value
|
||||
: null;
|
||||
|
||||
authSettings.value = authSettings.value.copyWith
|
||||
.lockTimeout(newValue);
|
||||
},
|
||||
secondary: DropdownButton(
|
||||
value: authSettings.value.lockTimeout,
|
||||
items: _timeoutOptions,
|
||||
onChanged: (value) {
|
||||
authSettings.value = authSettings.value.copyWith
|
||||
.lockTimeout(value);
|
||||
},
|
||||
),
|
||||
),
|
||||
ListTile(
|
||||
leading: const Icon(Icons.web),
|
||||
title: const Text('Assigned Sites'),
|
||||
|
||||
Reference in New Issue
Block a user