Improve UX for login via password
This commit is contained in:
parent
6f032eeba3
commit
0c4e5b7da6
2 changed files with 19 additions and 10 deletions
|
@ -216,14 +216,17 @@ class Configuration {
|
||||||
Future<Uint8List> decryptSecretsAndGetKeyEncKey(
|
Future<Uint8List> decryptSecretsAndGetKeyEncKey(
|
||||||
String password,
|
String password,
|
||||||
KeyAttributes attributes,
|
KeyAttributes attributes,
|
||||||
|
{
|
||||||
|
Uint8List? keyEncryptionKey,
|
||||||
|
}
|
||||||
) async {
|
) async {
|
||||||
_logger.info('Start decryptAndSaveSecrets');
|
_logger.info('Start decryptAndSaveSecrets');
|
||||||
final keyEncryptionKey = await CryptoUtil.deriveKey(
|
keyEncryptionKey ??= await CryptoUtil.deriveKey(
|
||||||
utf8.encode(password) as Uint8List,
|
utf8.encode(password) as Uint8List,
|
||||||
Sodium.base642bin(attributes.kekSalt),
|
Sodium.base642bin(attributes.kekSalt),
|
||||||
attributes.memLimit,
|
attributes.memLimit,
|
||||||
attributes.opsLimit,
|
attributes.opsLimit,
|
||||||
);
|
);
|
||||||
|
|
||||||
_logger.info('user-key done');
|
_logger.info('user-key done');
|
||||||
Uint8List key;
|
Uint8List key;
|
||||||
|
|
|
@ -25,6 +25,7 @@ import 'package:ente_auth/ui/account/password_entry_page.dart';
|
||||||
import 'package:ente_auth/ui/account/password_reentry_page.dart';
|
import 'package:ente_auth/ui/account/password_reentry_page.dart';
|
||||||
import 'package:ente_auth/ui/account/recovery_page.dart';
|
import 'package:ente_auth/ui/account/recovery_page.dart';
|
||||||
import 'package:ente_auth/ui/components/buttons/button_widget.dart';
|
import 'package:ente_auth/ui/components/buttons/button_widget.dart';
|
||||||
|
import 'package:ente_auth/ui/home_page.dart';
|
||||||
import 'package:ente_auth/ui/two_factor_authentication_page.dart';
|
import 'package:ente_auth/ui/two_factor_authentication_page.dart';
|
||||||
import 'package:ente_auth/ui/two_factor_recovery_page.dart';
|
import 'package:ente_auth/ui/two_factor_recovery_page.dart';
|
||||||
import 'package:ente_auth/utils/crypto_util.dart';
|
import 'package:ente_auth/utils/crypto_util.dart';
|
||||||
|
@ -521,14 +522,15 @@ class UserService {
|
||||||
isDismissible: true,
|
isDismissible: true,
|
||||||
);
|
);
|
||||||
await dialog.show();
|
await dialog.show();
|
||||||
|
late Uint8List keyEncryptionKey;
|
||||||
try {
|
try {
|
||||||
final kek = await CryptoUtil.deriveKey(
|
keyEncryptionKey = await CryptoUtil.deriveKey(
|
||||||
utf8.encode(userPassword) as Uint8List,
|
utf8.encode(userPassword) as Uint8List,
|
||||||
CryptoUtil.base642bin(srpAttributes.kekSalt),
|
CryptoUtil.base642bin(srpAttributes.kekSalt),
|
||||||
srpAttributes.memLimit,
|
srpAttributes.memLimit,
|
||||||
srpAttributes.opsLimit,
|
srpAttributes.opsLimit,
|
||||||
);
|
);
|
||||||
final loginKey = await CryptoUtil.deriveLoginKey(kek);
|
final loginKey = await CryptoUtil.deriveLoginKey(keyEncryptionKey);
|
||||||
final Uint8List identity = Uint8List.fromList(
|
final Uint8List identity = Uint8List.fromList(
|
||||||
utf8.encode(srpAttributes.srpUserID),
|
utf8.encode(srpAttributes.srpUserID),
|
||||||
);
|
);
|
||||||
|
@ -571,12 +573,16 @@ class UserService {
|
||||||
final String twoFASessionID = response.data["twoFactorSessionID"];
|
final String twoFASessionID = response.data["twoFactorSessionID"];
|
||||||
Configuration.instance.setVolatilePassword(userPassword);
|
Configuration.instance.setVolatilePassword(userPassword);
|
||||||
if (twoFASessionID.isNotEmpty) {
|
if (twoFASessionID.isNotEmpty) {
|
||||||
|
|
||||||
page = TwoFactorAuthenticationPage(twoFASessionID);
|
page = TwoFactorAuthenticationPage(twoFASessionID);
|
||||||
} else {
|
} else {
|
||||||
await _saveConfiguration(response);
|
await _saveConfiguration(response);
|
||||||
if (Configuration.instance.getEncryptedToken() != null) {
|
if (Configuration.instance.getEncryptedToken() != null) {
|
||||||
page = const PasswordReentryPage();
|
await Configuration.instance.decryptSecretsAndGetKeyEncKey(
|
||||||
|
userPassword,
|
||||||
|
Configuration.instance.getKeyAttributes()!,
|
||||||
|
keyEncryptionKey: keyEncryptionKey,
|
||||||
|
);
|
||||||
|
page = const HomePage();
|
||||||
} else {
|
} else {
|
||||||
throw Exception("unexpected response during email verification");
|
throw Exception("unexpected response during email verification");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue