Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed an issue that user can insert any whitespace (tab or space) in email and password fields. #199

Merged
merged 5 commits into from
Jun 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions lib/domain/auth/value_objects.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ class EmailAddress extends ValueObject<String> {
factory EmailAddress(String input) {
assert(input != null);
return EmailAddress._(
validateEmailAddress(input),
validateEmailAddress(input)
.flatMap((result) => validateEmailWithoutSpace(result)),
);
}

Expand All @@ -20,9 +21,8 @@ class EmailAddress extends ValueObject<String> {
class Password extends ValueObject<String> {
factory Password(String input) {
assert(input != null);
return Password._(
validatePassword(input),
);
return Password._(validatePasswordLength(input)
.flatMap((result) => validatePasswordWithoutSpace(result)));
}

const Password._(this.value);
Expand Down
8 changes: 8 additions & 0 deletions lib/domain/core/failures.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,16 @@ class AuthValueFailure<T> with _$AuthValueFailure<T> {

const factory AuthValueFailure.invalidPassword({
required String failedValue,
}) = InvalidPassword<T>;

const factory AuthValueFailure.shortPassword({
required String failedValue,
}) = ShortPassword<T>;

const factory AuthValueFailure.containsSpace({
required String failedValue,
}) = ContainsSpace<T>;

const factory AuthValueFailure.empty({
required String failedValue,
}) = Empty<T>;
Expand Down
Loading