mirror of
https://github.com/ente-io/ente.git
synced 2025-07-03 05:56:17 +00:00
[mob][photos] Require Authentication on App Reopen from Guest View (#3131)
This PR introduces a security enhancement that requires authentication when the app is reopened after being closed while in guest view.
This commit is contained in:
commit
73cae89fc5
@ -112,7 +112,8 @@ Future<void> _runInForeground(AdaptiveThemeMode? savedThemeMode) async {
|
||||
builder: (args) =>
|
||||
EnteApp(_runBackgroundTask, _killBGTask, locale, savedThemeMode),
|
||||
lockScreen: const LockScreen(),
|
||||
enabled: await Configuration.instance.shouldShowLockScreen(),
|
||||
enabled: await Configuration.instance.shouldShowLockScreen() ||
|
||||
localSettings.isOnGuestView(),
|
||||
locale: locale,
|
||||
lightTheme: lightThemeData,
|
||||
darkTheme: darkThemeData,
|
||||
|
@ -9,6 +9,7 @@ import 'package:logging/logging.dart';
|
||||
import "package:photos/core/configuration.dart";
|
||||
import "package:photos/generated/l10n.dart";
|
||||
import "package:photos/l10n/l10n.dart";
|
||||
import "package:photos/service_locator.dart";
|
||||
import "package:photos/services/user_service.dart";
|
||||
import "package:photos/theme/ente_theme.dart";
|
||||
import "package:photos/ui/components/buttons/icon_button_widget.dart";
|
||||
@ -346,6 +347,7 @@ class _LockScreenState extends State<LockScreen>
|
||||
lockedTimeInSeconds = 15;
|
||||
isTimerRunning = false;
|
||||
});
|
||||
await localSettings.setOnGuestView(false);
|
||||
} else {
|
||||
if (!_hasPlacedAppInBackground) {
|
||||
if (_lockscreenSetting.getInvalidAttemptCount() > 4 &&
|
||||
|
@ -21,6 +21,7 @@ import 'package:photos/models/gallery_type.dart';
|
||||
import "package:photos/models/metadata/common_keys.dart";
|
||||
import "package:photos/models/ml/face/person.dart";
|
||||
import 'package:photos/models/selected_files.dart';
|
||||
import "package:photos/service_locator.dart";
|
||||
import 'package:photos/services/collections_service.dart';
|
||||
import 'package:photos/services/hidden_service.dart';
|
||||
import 'package:photos/services/machine_learning/face_ml/feedback/cluster_feedback.dart';
|
||||
@ -581,6 +582,7 @@ class _FileSelectionActionsWidgetState
|
||||
"guest_view",
|
||||
),
|
||||
);
|
||||
await localSettings.setOnGuestView(true);
|
||||
routeToPage(context, page, forceCustomPageRoute: true).ignore();
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
Bus.instance.fire(GuestViewEvent(true, false));
|
||||
|
@ -15,6 +15,7 @@ import "package:photos/generated/l10n.dart";
|
||||
import "package:photos/models/file/extensions/file_props.dart";
|
||||
import 'package:photos/models/file/file.dart';
|
||||
import "package:photos/models/file/file_type.dart";
|
||||
import "package:photos/service_locator.dart";
|
||||
import "package:photos/services/local_authentication_service.dart";
|
||||
import "package:photos/ui/common/fast_scroll_physics.dart";
|
||||
import 'package:photos/ui/tools/editor/image_editor_page.dart';
|
||||
@ -156,6 +157,7 @@ class _DetailPageState extends State<DetailPage> {
|
||||
final authenticated = await _requestAuthentication();
|
||||
if (authenticated) {
|
||||
Bus.instance.fire(GuestViewEvent(false, false));
|
||||
await localSettings.setOnGuestView(false);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -475,6 +475,7 @@ class FileAppBarState extends State<FileAppBar> {
|
||||
Future<void> _onTapGuestView() async {
|
||||
if (await LocalAuthentication().isDeviceSupported()) {
|
||||
Bus.instance.fire(GuestViewEvent(true, true));
|
||||
await localSettings.setOnGuestView(true);
|
||||
} else {
|
||||
await showErrorDialog(
|
||||
context,
|
||||
@ -492,6 +493,7 @@ class FileAppBarState extends State<FileAppBar> {
|
||||
);
|
||||
if (hasAuthenticated) {
|
||||
Bus.instance.fire(GuestViewEvent(false, false));
|
||||
await localSettings.setOnGuestView(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -15,6 +15,7 @@ class LocalSettings {
|
||||
static const kEnableMultiplePart = "ls.enable_multiple_part";
|
||||
static const kRateUsPromptThreshold = 2;
|
||||
static const shouldLoopVideoKey = "video.should_loop";
|
||||
static const onGuestViewKey = "on_guest_view";
|
||||
|
||||
final SharedPreferences _prefs;
|
||||
|
||||
@ -91,4 +92,12 @@ class LocalSettings {
|
||||
bool shouldLoopVideo() {
|
||||
return _prefs.getBool(shouldLoopVideoKey) ?? true;
|
||||
}
|
||||
|
||||
Future<void> setOnGuestView(bool value) {
|
||||
return _prefs.setBool(onGuestViewKey, value);
|
||||
}
|
||||
|
||||
bool isOnGuestView() {
|
||||
return _prefs.getBool(onGuestViewKey) ?? false;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user