zf

zenflows testing
git clone https://s.sonu.ch/~srfsh/zf.git
Log | Files | Refs | Submodules | README | LICENSE

commit 9ede7d19797918e07561332975926d1a749c62c0
parent 7c421718bb5178aae119949362a6541300d88e1b
Author: srfsh <dev@srf.sh>
Date:   Thu, 15 Sep 2022 13:08:45 +0300

Zenflows.GQL.MW.Sign: improve restroom error message

Requested by Jaromil.

Diffstat:
Msrc/zenflows/gql/mw/sign.ex | 17++++++++++++++++-
1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/src/zenflows/gql/mw/sign.ex b/src/zenflows/gql/mw/sign.ex @@ -30,7 +30,7 @@ def call(res, _opts) do if res.context.authenticate_calls? do with {:ok, username, sign, body} <- fetch_ctx(res), {:ok, per} <- fetch_user(username), - :ok <- Restroom.verify_graphql(body, sign, per.eddsa_public_key) do + :ok <- verify_gql(body, sign, per) do put_in(res.context[:req_user], per) else x -> Absinthe.Resolution.put_result(res, x) @@ -54,4 +54,19 @@ defp fetch_user(username) do _ -> {:error, "user not found"} end end + +defp verify_gql(body, sign, per) do + case Restroom.verify_graphql(body, sign, per.eddsa_public_key) do + :ok -> :ok + {:error, reason} -> + {:error, + """ + authentication error. + + details: + + #{reason} + """} + end +end end