Skip to content

Commit

Permalink
fix: silent email address trim
Browse files Browse the repository at this point in the history
  • Loading branch information
steve-lebleu committed Nov 14, 2024
1 parent 316e491 commit 3d7cc23
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 3 deletions.
1 change: 1 addition & 0 deletions config/graphql/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ scalar UUID
scalar Generic
scalar BigInt
scalar OpaqueID
scalar TrimmedString
type Query
type Mutation
11 changes: 10 additions & 1 deletion config/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

uuid_scalar = ScalarType("UUID")
opaque_id_scalar = ScalarType("OpaqueID")

trimmed_string_scalar = ScalarType("TrimmedString")

@uuid_scalar.value_parser
def parse_uuid_value(value):
Expand Down Expand Up @@ -69,6 +69,14 @@ def serialize_opaque_id(value):
return base64.b64encode(value.encode("utf-8")).decode("utf-8")


@trimmed_string_scalar.value_parser
def parse_trimmed_string(value):
try:
return value.strip()
except (ValueError, TypeError):
raise ValueError(f'"{value}" is not a valid string')


type_defs = load_schema_from_path(
f"{pathlib.Path(__file__).parent.resolve()}/graphql/schema.graphql"
)
Expand All @@ -94,6 +102,7 @@ def serialize_opaque_id(value):
[
uuid_scalar,
opaque_id_scalar,
trimmed_string_scalar,
*pipelines_bindables,
*identity_bindables,
*tags_bindables,
Expand Down
2 changes: 1 addition & 1 deletion hexa/user_management/graphql/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ input LoginInput {
"""
The email address of the user.
"""
email: String!
email: TrimmedString

"""
The password of the user.
Expand Down
1 change: 0 additions & 1 deletion hexa/user_management/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,6 @@ def resolve_delete_team(_, info, **kwargs):
def resolve_login(_, info, **kwargs):
request: HttpRequest = info.context["request"]
mutation_input = kwargs["input"]

user_candidate = authenticate(
request, email=mutation_input["email"], password=mutation_input["password"]
)
Expand Down

0 comments on commit 3d7cc23

Please sign in to comment.