fix(mongo): avoid function_caluse while query returned other types
This commit is contained in:
parent
27d6b73c37
commit
1be1757bbd
|
@ -85,10 +85,16 @@ description() -> "Authentication with MongoDB".
|
||||||
is_superuser(_Pool, undefined, _ClientInfo) ->
|
is_superuser(_Pool, undefined, _ClientInfo) ->
|
||||||
false;
|
false;
|
||||||
is_superuser(Pool, #superquery{collection = Coll, field = Field, selector = Selector}, ClientInfo) ->
|
is_superuser(Pool, #superquery{collection = Coll, field = Field, selector = Selector}, ClientInfo) ->
|
||||||
Row = query(Pool, Coll, maps:from_list(replvars(Selector, ClientInfo))),
|
case query(Pool, Coll, maps:from_list(replvars(Selector, ClientInfo))) of
|
||||||
case maps:get(Field, Row, false) of
|
undefined -> false;
|
||||||
true -> true;
|
{error, Reason} ->
|
||||||
_False -> false
|
?LOG(error, "[MongoDB] Can't connect to MongoDB server: ~0p", [Reason]),
|
||||||
|
false;
|
||||||
|
Row ->
|
||||||
|
case maps:get(Field, Row, false) of
|
||||||
|
true -> true;
|
||||||
|
_False -> false
|
||||||
|
end
|
||||||
end.
|
end.
|
||||||
|
|
||||||
replvars(VarList, ClientInfo) ->
|
replvars(VarList, ClientInfo) ->
|
||||||
|
|
Loading…
Reference in New Issue