fix add key

This commit is contained in:
Mikaël Cluseau 2024-01-07 11:18:50 +01:00
parent f59eca6724
commit 8ed0f12fb4

View File

@ -29,9 +29,6 @@ func wsStoreAddKey(req *restful.Request, resp *restful.Response) {
return
}
secStore.AddKey(np.Name, np.Passphrase)
defer updateState()
for _, k := range secStore.Keys {
if k.Name == np.Name {
wsBadRequest(resp, "there's already a passphrase named "+strconv.Quote(np.Name))
@ -39,6 +36,9 @@ func wsStoreAddKey(req *restful.Request, resp *restful.Response) {
}
}
secStore.AddKey(np.Name, np.Passphrase)
defer updateState()
err = secStore.SaveTo(secKeysStorePath())
if err != nil {
wsError(resp, err)