commit 5101c2d6bae4a82ffcaef20d669d7638ad285c5d
parent 27863bb40541969b5b430f3f7f290ed2de84c756
Author: srfsh <dev@srf.sh>
Date: Thu, 21 Jul 2022 20:08:31 +0300
gql/mw/sign: simplify
Diffstat:
1 file changed, 5 insertions(+), 12 deletions(-)
diff --git a/src/zenflows/gql/mw/sign.ex b/src/zenflows/gql/mw/sign.ex
@@ -27,19 +27,12 @@ alias Zenflows.VF.Person
@impl true
def call(res, _opts) do
- # if this is admin-related call (such as createPerson and importRepos mutations),
- # skip it (since the `middleware/3` callback in # `Zenflows.GQL.Schema` is
- # called over and over.
- if match?(%{gql_admin: _}, res.context) do
+ with %{gql_user: user, gql_sign: sign, gql_body: body} <- res.context,
+ per when not is_nil(per) <- Person.Domain.by_user(user),
+ true <- Restroom.verify_graphql?(body, sign, per.eddsa_public_key) do
res
- else
- with %{gql_user: user, gql_sign: sign, gql_body: body} <- res.context,
- per when not is_nil(per) <- Person.Domain.by_user(user),
- true <- Restroom.verify_graphql?(body, sign, per.eddsa_public_key) do
- res
- else _ ->
- Absinthe.Resolution.put_result(res, {:error, "you are not authenticated"})
- end
+ else _ ->
+ Absinthe.Resolution.put_result(res, {:error, "you are not authenticated"})
end
end
end