Log improvements (#444)

This commit is contained in:
Neeraj Gupta 2024-02-09 10:47:03 +05:30 committed by GitHub
parent cb1376f338
commit 310d32def2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 51 additions and 33 deletions

View file

@ -469,10 +469,14 @@ class Configuration {
return _preferences.setBool(keyShouldShowLockScreen, value);
}
void setVolatilePassword(String? volatilePassword) {
void setVolatilePassword(String volatilePassword) {
_volatilePassword = volatilePassword;
}
void resetVolatilePassword() {
_volatilePassword = null;
}
String? getVolatilePassword() {
return _volatilePassword;
}

View file

@ -105,8 +105,8 @@ class _EmailEntryPageState extends State<EmailEntryPage> {
isFormValid: _isFormValid(),
buttonText: context.l10n.createAccount,
onPressedFunction: () {
_config.setVolatilePassword(_passwordController1.text);
UserService.instance.setEmail(_email!);
_config.setVolatilePassword(_passwordController1.text);
UserService.instance.setRefSource(_referralSource);
UserService.instance
.sendOtt(context, _email!, isCreateAccountScreen: true);

View file

@ -60,7 +60,10 @@ class _PasswordEntryPageState extends State<PasswordEntryPage> {
if (_volatilePassword != null) {
Future.delayed(
Duration.zero,
() => _showRecoveryCodeDialog(_volatilePassword!),
() => _showRecoveryCodeDialog(
_volatilePassword!,
usingVolatilePassword: true,
),
);
}
_password1FocusNode.addListener(() {
@ -421,15 +424,21 @@ class _PasswordEntryPageState extends State<PasswordEntryPage> {
return logOutFromOther;
}
Future<void> _showRecoveryCodeDialog(String password) async {
Future<void> _showRecoveryCodeDialog(
String password, {
bool usingVolatilePassword = false,
}) async {
final l10n = context.l10n;
final dialog =
createProgressDialog(context, l10n.generatingEncryptionKeysTitle);
await dialog.show();
try {
if (usingVolatilePassword) {
_logger.info('Using volatile password');
}
final KeyGenResult result =
await Configuration.instance.generateKey(password);
Configuration.instance.setVolatilePassword(null);
Configuration.instance.resetVolatilePassword();
await dialog.hide();
onDone() async {
final dialog = createProgressDialog(context, l10n.pleaseWait);
@ -437,7 +446,7 @@ class _PasswordEntryPageState extends State<PasswordEntryPage> {
try {
await UserService.instance.setAttributes(result);
await dialog.hide();
Configuration.instance.setVolatilePassword(null);
Configuration.instance.resetVolatilePassword();
Navigator.of(context).pushAndRemoveUntil(
MaterialPageRoute(
builder: (BuildContext context) {

View file

@ -40,7 +40,7 @@ class _PasswordReentryPageState extends State<PasswordReentryPage> {
_passwordController.text = _volatilePassword!;
Future.delayed(
Duration.zero,
() => verifyPassword(_volatilePassword!),
() => verifyPassword(_volatilePassword!, usingVolatilePassword: true),
);
}
_passwordFocusNode.addListener(() {
@ -90,11 +90,16 @@ class _PasswordReentryPageState extends State<PasswordReentryPage> {
);
}
Future<void> verifyPassword(String password) async {
Future<void> verifyPassword(
String password, {
bool usingVolatilePassword = false,
}) async {
FocusScope.of(context).unfocus();
final dialog =
createProgressDialog(context, context.l10n.pleaseWait);
final dialog = createProgressDialog(context, context.l10n.pleaseWait);
await dialog.show();
if (usingVolatilePassword) {
_logger.info("Using volatile password");
}
try {
final kek = await Configuration.instance.decryptSecretsAndGetKeyEncKey(
password,
@ -140,8 +145,8 @@ class _PasswordReentryPageState extends State<PasswordReentryPage> {
}
return;
}
Configuration.instance.resetVolatilePassword();
await dialog.hide();
Configuration.instance.setVolatilePassword(null);
unawaited(
Navigator.of(context).pushAndRemoveUntil(
MaterialPageRoute(
@ -149,7 +154,7 @@ class _PasswordReentryPageState extends State<PasswordReentryPage> {
return const HomePage();
},
),
(route) => false,
(route) => false,
),
);
}
@ -183,7 +188,7 @@ class _PasswordReentryPageState extends State<PasswordReentryPage> {
children: [
Padding(
padding:
const EdgeInsets.symmetric(vertical: 30, horizontal: 20),
const EdgeInsets.symmetric(vertical: 30, horizontal: 20),
child: Text(
context.l10n.welcomeBack,
style: Theme.of(context).textTheme.headlineMedium,
@ -218,19 +223,19 @@ class _PasswordReentryPageState extends State<PasswordReentryPage> {
),
suffixIcon: _passwordInFocus
? IconButton(
icon: Icon(
_passwordVisible
? Icons.visibility
: Icons.visibility_off,
color: Theme.of(context).iconTheme.color,
size: 20,
),
onPressed: () {
setState(() {
_passwordVisible = !_passwordVisible;
});
},
)
icon: Icon(
_passwordVisible
? Icons.visibility
: Icons.visibility_off,
color: Theme.of(context).iconTheme.color,
size: 20,
),
onPressed: () {
setState(() {
_passwordVisible = !_passwordVisible;
});
},
)
: null,
),
style: const TextStyle(
@ -276,9 +281,9 @@ class _PasswordReentryPageState extends State<PasswordReentryPage> {
.textTheme
.titleMedium!
.copyWith(
fontSize: 14,
decoration: TextDecoration.underline,
),
fontSize: 14,
decoration: TextDecoration.underline,
),
),
),
),
@ -302,9 +307,9 @@ class _PasswordReentryPageState extends State<PasswordReentryPage> {
.textTheme
.titleMedium!
.copyWith(
fontSize: 14,
decoration: TextDecoration.underline,
),
fontSize: 14,
decoration: TextDecoration.underline,
),
),
),
),

View file

@ -1,6 +1,6 @@
name: ente_auth
description: ente two-factor authenticator
version: 2.0.31+231
version: 2.0.32+232
publish_to: none
environment: