Skip to content

Commit

Permalink
fix: Weak password throws AuthWeakPasswordException. (#897)
Browse files Browse the repository at this point in the history
fix: week password throws the correct exception
  • Loading branch information
dshukertjr authored Apr 23, 2024
1 parent c4e73c7 commit 4f5b853
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/gotrue/lib/src/fetch.dart
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class GotrueFetch {
throw AuthWeakPasswordException(
message: _getErrorMessage(data),
statusCode: error.statusCode.toString(),
reasons: data['weak_password']['reasons'],
reasons: List<String>.from(data['weak_password']['reasons']),
);
}

Expand Down
9 changes: 9 additions & 0 deletions packages/gotrue/test/client_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,15 @@ void main() {
expect(data?.user.id, isA<String>());
expect(data?.user.userMetadata!['Hello'], 'World');
});
test('signUp() with week password throws AuthWeakPasswordException',
() async {
try {
await client.signUp(email: newEmail, password: '123');
fail('signUp with week password should throw exception');
} catch (error) {
expect(error, isA<AuthWeakPasswordException>());
}
});

test('Parsing invalid URL should throw', () async {
const expiresIn = 12345;
Expand Down

0 comments on commit 4f5b853

Please sign in to comment.