mirror of
https://github.com/venera-app/venera.git
synced 2025-09-27 07:47:24 +00:00
authorize: auto-raise & skip on import (#56)
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter/scheduler.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:local_auth/local_auth.dart';
|
import 'package:local_auth/local_auth.dart';
|
||||||
import 'package:venera/utils/translations.dart';
|
import 'package:venera/utils/translations.dart';
|
||||||
@@ -14,6 +15,16 @@ class AuthPage extends StatefulWidget {
|
|||||||
|
|
||||||
class _AuthPageState extends State<AuthPage> {
|
class _AuthPageState extends State<AuthPage> {
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
|
if(SchedulerBinding.instance.lifecycleState != AppLifecycleState.paused) {
|
||||||
|
auth();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
super.initState();
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return PopScope(
|
return PopScope(
|
||||||
|
@@ -71,12 +71,14 @@ Future<void> importAppData(File file, [bool checkVersion = false]) async {
|
|||||||
LocalFavoritesManager().init();
|
LocalFavoritesManager().init();
|
||||||
}
|
}
|
||||||
if (await appdataFile.exists()) {
|
if (await appdataFile.exists()) {
|
||||||
// proxy settings should be kept
|
// proxy settings & authorization setting should be kept
|
||||||
var proxySettings = appdata.settings["proxy"];
|
var proxySettings = appdata.settings["proxy"];
|
||||||
|
var authSettings = appdata.settings["authorizationRequired"];
|
||||||
File(FilePath.join(App.dataPath, "appdata.json")).deleteIfExistsSync();
|
File(FilePath.join(App.dataPath, "appdata.json")).deleteIfExistsSync();
|
||||||
appdataFile.renameSync(FilePath.join(App.dataPath, "appdata.json"));
|
appdataFile.renameSync(FilePath.join(App.dataPath, "appdata.json"));
|
||||||
await appdata.init();
|
await appdata.init();
|
||||||
appdata.settings["proxy"] = proxySettings;
|
appdata.settings["proxy"] = proxySettings;
|
||||||
|
appdata.settings["authorizationRequired"] = authSettings;
|
||||||
appdata.saveData();
|
appdata.saveData();
|
||||||
}
|
}
|
||||||
if (await cookieFile.exists()) {
|
if (await cookieFile.exists()) {
|
||||||
|
Reference in New Issue
Block a user