Skip to content

Commit 4f5b853

Browse files
authored
fix: Weak password throws AuthWeakPasswordException. (#897)
fix: week password throws the correct exception
1 parent c4e73c7 commit 4f5b853

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

packages/gotrue/lib/src/fetch.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ class GotrueFetch {
5858
throw AuthWeakPasswordException(
5959
message: _getErrorMessage(data),
6060
statusCode: error.statusCode.toString(),
61-
reasons: data['weak_password']['reasons'],
61+
reasons: List<String>.from(data['weak_password']['reasons']),
6262
);
6363
}
6464

packages/gotrue/test/client_test.dart

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,15 @@ void main() {
102102
expect(data?.user.id, isA<String>());
103103
expect(data?.user.userMetadata!['Hello'], 'World');
104104
});
105+
test('signUp() with week password throws AuthWeakPasswordException',
106+
() async {
107+
try {
108+
await client.signUp(email: newEmail, password: '123');
109+
fail('signUp with week password should throw exception');
110+
} catch (error) {
111+
expect(error, isA<AuthWeakPasswordException>());
112+
}
113+
});
105114

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

0 commit comments

Comments
 (0)