fix(authn): add the case when the instance does not exist
This commit is contained in:
parent
2b282b9666
commit
5aa8ba45d3
|
@ -121,8 +121,12 @@ do_post_config_update({delete_authenticator, ChainName, AuthenticatorID}, _NewCo
|
||||||
{error, Reason}
|
{error, Reason}
|
||||||
end;
|
end;
|
||||||
do_post_config_update({update_authenticator, ChainName, AuthenticatorID, Config}, NewConfig, _OldConfig, _AppEnvs) ->
|
do_post_config_update({update_authenticator, ChainName, AuthenticatorID, Config}, NewConfig, _OldConfig, _AppEnvs) ->
|
||||||
NConfig = get_authenticator_config(authenticator_id(Config), NewConfig),
|
case get_authenticator_config(authenticator_id(Config), NewConfig) of
|
||||||
emqx_authentication:update_authenticator(ChainName, AuthenticatorID, NConfig);
|
{error, not_found} ->
|
||||||
|
{error, {not_found, {authenticator, AuthenticatorID}}};
|
||||||
|
NConfig ->
|
||||||
|
emqx_authentication:update_authenticator(ChainName, AuthenticatorID, NConfig)
|
||||||
|
end;
|
||||||
do_post_config_update({move_authenticator, ChainName, AuthenticatorID, Position}, _NewConfig, _OldConfig, _AppEnvs) ->
|
do_post_config_update({move_authenticator, ChainName, AuthenticatorID, Position}, _NewConfig, _OldConfig, _AppEnvs) ->
|
||||||
emqx_authentication:move_authenticator(ChainName, AuthenticatorID, Position).
|
emqx_authentication:move_authenticator(ChainName, AuthenticatorID, Position).
|
||||||
|
|
||||||
|
@ -205,8 +209,10 @@ clear_certs(CertsDir, Config) ->
|
||||||
ok = emqx_tls_lib:delete_ssl_files(CertsDir, undefined, OldSSL).
|
ok = emqx_tls_lib:delete_ssl_files(CertsDir, undefined, OldSSL).
|
||||||
|
|
||||||
get_authenticator_config(AuthenticatorID, AuthenticatorsConfig) ->
|
get_authenticator_config(AuthenticatorID, AuthenticatorsConfig) ->
|
||||||
[C] = [C0 || C0 <- AuthenticatorsConfig, AuthenticatorID == authenticator_id(C0)],
|
case [C0 || C0 <- AuthenticatorsConfig, AuthenticatorID == authenticator_id(C0)] of
|
||||||
C.
|
[C | _] -> C;
|
||||||
|
[] -> {error, not_found}
|
||||||
|
end.
|
||||||
|
|
||||||
split_by_id(ID, AuthenticatorsConfig) ->
|
split_by_id(ID, AuthenticatorsConfig) ->
|
||||||
case lists:foldl(
|
case lists:foldl(
|
||||||
|
|
Loading…
Reference in New Issue