Allow a new API key to be generated if the existing apikey.txt file has been deleted

This commit is contained in:
CalDescent 2022-01-08 12:27:24 +00:00
parent b6db5aa2d3
commit db8e35cc13
3 changed files with 6 additions and 2 deletions

2
.gitignore vendored
View File

@ -30,4 +30,4 @@
/tmp
/data*
/src/test/resources/arbitrary/*/.qortal/cache
apikey
apikey.txt

View File

@ -86,6 +86,10 @@ public class ApiKey {
return (this.apiKey != null);
}
public boolean exists() {
return this.getFilePath().toFile().exists();
}
@Override
public String toString() {
return this.apiKey;

View File

@ -735,7 +735,7 @@ public class AdminResource {
ApiKey apiKey = Security.getApiKey(request);
// If the API key is already generated, we need to authenticate this request
if (apiKey.generated()) {
if (apiKey.generated() && apiKey.exists()) {
Security.checkApiCallAllowed(request);
}