fix(auth mnesia api): fix put file type error
This commit is contained in:
parent
3be6374f91
commit
0813a81517
|
@ -198,6 +198,7 @@ post_config_update({{replace_once, Type}, #{type := Type} = Source}, _NewSources
|
||||||
{Index, OldSource} = find_source_by_type(Type, OldInitedSources),
|
{Index, OldSource} = find_source_by_type(Type, OldInitedSources),
|
||||||
case maps:get(type, OldSource, undefined) of
|
case maps:get(type, OldSource, undefined) of
|
||||||
undefined -> ok;
|
undefined -> ok;
|
||||||
|
file -> ok;
|
||||||
_ ->
|
_ ->
|
||||||
#{annotations := #{id := Id}} = OldSource,
|
#{annotations := #{id := Id}} = OldSource,
|
||||||
ok = emqx_resource:remove(Id)
|
ok = emqx_resource:remove(Id)
|
||||||
|
|
|
@ -304,7 +304,7 @@ sources(get, _) ->
|
||||||
{ok, Rules} = file:consult(Path),
|
{ok, Rules} = file:consult(Path),
|
||||||
lists:append(AccIn, [#{type => file,
|
lists:append(AccIn, [#{type => file,
|
||||||
enable => true,
|
enable => true,
|
||||||
rules => [ iolist_to_binary(io_lib:format("~p", [R])) || R <- Rules],
|
rules => [ iolist_to_binary(io_lib:format("~p.", [R])) || R <- Rules],
|
||||||
annotations => #{status => healthy}
|
annotations => #{status => healthy}
|
||||||
}]);
|
}]);
|
||||||
(#{type := _Type, annotations := #{id := Id}} = Source, AccIn) ->
|
(#{type := _Type, annotations := #{id := Id}} = Source, AccIn) ->
|
||||||
|
@ -372,7 +372,7 @@ source(get, #{bindings := #{type := Type}}) ->
|
||||||
{ok, Rules} = file:consult(Path),
|
{ok, Rules} = file:consult(Path),
|
||||||
{200, #{type => file,
|
{200, #{type => file,
|
||||||
enable => true,
|
enable => true,
|
||||||
rules => [ iolist_to_binary(io_lib:format("~p", [R])) || R <- Rules],
|
rules => [ iolist_to_binary(io_lib:format("~p.", [R])) || R <- Rules],
|
||||||
annotations => #{status => healthy}
|
annotations => #{status => healthy}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -395,7 +395,7 @@ source(get, #{bindings := #{type := Type}}) ->
|
||||||
end,
|
end,
|
||||||
{200, read_cert(NSource2)}
|
{200, read_cert(NSource2)}
|
||||||
end;
|
end;
|
||||||
source(put, #{bindings := #{type := file}, body := #{<<"type">> := <<"file">>, <<"rules">> := Rules, <<"enable">> := Enable}}) ->
|
source(put, #{bindings := #{type := <<"file">>}, body := #{<<"type">> := <<"file">>, <<"rules">> := Rules, <<"enable">> := Enable}}) ->
|
||||||
{ok, Filename} = write_file(maps:get(path, emqx_authz:lookup(file), ""),
|
{ok, Filename} = write_file(maps:get(path, emqx_authz:lookup(file), ""),
|
||||||
erlang:list_to_bitstring([<<Rule/binary, "\n">> || Rule <- Rules])
|
erlang:list_to_bitstring([<<Rule/binary, "\n">> || Rule <- Rules])
|
||||||
),
|
),
|
||||||
|
|
Loading…
Reference in New Issue