fix(jwt): simplify binary_to_number function
This commit is contained in:
parent
c999b43144
commit
ddc25fc5c2
|
@ -90,22 +90,16 @@ is_expired(Exp) ->
|
||||||
description() -> "Authentication with JWT".
|
description() -> "Authentication with JWT".
|
||||||
|
|
||||||
binary_to_number(Bin) ->
|
binary_to_number(Bin) ->
|
||||||
Checker = fun([], _) ->
|
try
|
||||||
false;
|
{ok, erlang:binary_to_integer(Bin)}
|
||||||
([H | T], Self) ->
|
catch _:_ ->
|
||||||
try
|
try
|
||||||
{ok, H(Bin)}
|
Val = erlang:binary_to_float(Bin),
|
||||||
catch _:_ ->
|
{ok, erlang:round(Val)}
|
||||||
Self(T, Self)
|
catch _:_ ->
|
||||||
end
|
false
|
||||||
end,
|
end
|
||||||
|
end.
|
||||||
Checker([fun erlang:binary_to_integer/1,
|
|
||||||
fun(In) ->
|
|
||||||
Val = erlang:binary_to_float(In),
|
|
||||||
erlang:round(Val)
|
|
||||||
end],
|
|
||||||
Checker).
|
|
||||||
|
|
||||||
%%------------------------------------------------------------------------------
|
%%------------------------------------------------------------------------------
|
||||||
%% Verify Claims
|
%% Verify Claims
|
||||||
|
|
Loading…
Reference in New Issue