Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Nov 8, 2022. It is now read-only.

Commitb32687c

Browse files
committed
add error check to prevent middleware "cut though"
1 parent0ab95c3 commitb32687c

File tree

6 files changed

+16
-8
lines changed

6 files changed

+16
-8
lines changed

‎lib/mastani_server_web/middleware/covert_to_int.ex‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ defmodule MastaniServerWeb.Middleware.ConvertToInt do
66
@behaviourAbsinthe.Middleware
77
# google: must appear in the GROUP BY clause or be used in an aggregate function
88

9+
defcall(%{errors:errors}=resolution,_)whenlength(errors)>0,do:resolution
10+
911
defcall(%{value:[value]}=resolution,_)do
1012
%{resolution|value:value}
1113
end

‎lib/mastani_server_web/middleware/format_pagination.ex‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
defmoduleMastaniServerWeb.Middleware.FormatPaginationdo
66
@behaviourAbsinthe.Middleware
77

8+
defcall(%{errors:errors}=resolution,_)whenlength(errors)>0,do:resolution
9+
810
defcall(%{errors:[errors],value:nil}=resolution,_)do
911
%{resolution|value:[],errors:[errors]}
1012
end

‎lib/mastani_server_web/middleware/put_current_user.ex‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,9 @@ defmodule MastaniServerWeb.Middleware.PutCurrentUser do
1111
%{resolution|arguments:arguments}
1212
end
1313

14-
defcall(resolution,_),do:resolution
14+
defcall(%{errors:errors}=resolution,_)whenlength(errors)>0,do:resolution
15+
16+
defcall(resolution,_)do
17+
resolution
18+
end
1519
end

‎lib/mastani_server_web/middleware/size_checker.ex‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ defmodule MastaniServerWeb.Middleware.SizeChecker do
1212
# 2. if not has filter: marge to default first: 5
1313
# 3. large size should trigger error
1414

15+
defcall(%{errors:errors}=resolution,_)whenlength(errors)>0,do:resolution
16+
1517
defcall(resolution,_)do
1618
casevalid_size(resolution.arguments)do
1719
{:error,msg}->

‎lib/mastani_server_web/middleware/statistics/make_contribute.ex‎

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,11 @@ defmodule MastaniServerWeb.Middleware.Statistics.MakeContribute do
88
aliasMastaniServer.Statistics
99
aliasMastaniServer.Accounts.User
1010

11-
defcall(%{value:nil}=resolution,_)do
12-
IO.inspect("MakeContribute nil")
13-
resolution
14-
end
11+
defcall(%{errors:errors}=resolution,_)whenlength(errors)>0,do:resolution
12+
13+
defcall(%{value:nil,errors:_}=resolution,_),do:resolution
1514

1615
defcall(%{value:_,context:%{current_user:current_user}}=resolution,_)do
17-
# IO.inspect value, label: "MakeContribute"
18-
# IO.inspect current_user.id, label: "current_user"
1916
Statistics.make_contribute(%User{id:current_user.id})
2017
resolution
2118
end

‎lib/mastani_server_web/schema/cms/cms_mutations.ex‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ defmodule MastaniServerWeb.Schema.CMS.Mutations do
1818
resolve(&Resolvers.CMS.create_post/3)
1919
end
2020

21-
@desc"create a tag by part"
21+
@desc"create a tag by part [:login required]"
2222
field:create_tag,:tagdo
2323
arg(:title,non_null(:string))
2424
arg(:color,non_null(:rainbow_color_enum))
@@ -29,6 +29,7 @@ defmodule MastaniServerWeb.Schema.CMS.Mutations do
2929
resolve(&Resolvers.CMS.create_tag/3)
3030
end
3131

32+
@desc"delete a tag by part [:login required]"
3233
field:delete_tag,:tagdo
3334
arg(:id,non_null(:id))
3435

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp