Skip to content

Commit

Permalink
[auth] Improve recovery input validation (#2735)
Browse files Browse the repository at this point in the history
## Description

## Tests
  • Loading branch information
ua741 authored Aug 17, 2024
2 parents 191e324 + 3676151 commit 78a727c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
15 changes: 13 additions & 2 deletions auth/lib/core/configuration.dart
Original file line number Diff line number Diff line change
Expand Up @@ -285,9 +285,20 @@ class Configuration {
Future<void> recover(String recoveryKey) async {
// check if user has entered mnemonic code
if (recoveryKey.contains(' ')) {
if (recoveryKey.split(' ').length != mnemonicKeyWordCount) {
final split = recoveryKey.split(' ');
if (split.length != mnemonicKeyWordCount) {
String wordThatIsFollowedByEmptySpaceInSplit = '';
for (int i = 0; i < split.length; i++) {
String word = split[i];
if (word.isEmpty) {
wordThatIsFollowedByEmptySpaceInSplit =
'\n\nExtra space after word at position $i';
break;
}
}
throw AssertionError(
'recovery code should have $mnemonicKeyWordCount words',
'\nRecovery code should have $mnemonicKeyWordCount words, '
'found ${split.length} words instead.$wordThatIsFollowedByEmptySpaceInSplit',
);
}
recoveryKey = bip39.mnemonicToEntropy(recoveryKey);
Expand Down
2 changes: 1 addition & 1 deletion auth/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: ente_auth
description: ente two-factor authenticator
version: 3.1.1+321
version: 3.1.2+322
publish_to: none

environment:
Expand Down

0 comments on commit 78a727c

Please sign in to comment.