Skip to content

Commit

Permalink
Merge pull request #199 from AvielCo/dev
Browse files Browse the repository at this point in the history
Fixed an issue that user can insert any whitespace (tab or space) in email and password fields.
  • Loading branch information
guyluz11 authored Jun 9, 2021
2 parents ae9d7b3 + a5b0c30 commit 48ecab2
Show file tree
Hide file tree
Showing 7 changed files with 384 additions and 44 deletions.
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

0 comments on commit 48ecab2

Please sign in to comment.