hotfix API token saving
This commit is contained in:
parent
9d954c7213
commit
7337ab7021
|
|
@ -12,6 +12,7 @@ import ru.kirillius.pf.sdn.core.Auth.TokenService;
|
||||||
import ru.kirillius.pf.sdn.core.Context;
|
import ru.kirillius.pf.sdn.core.Context;
|
||||||
import ru.kirillius.pf.sdn.web.ProtectedMethod;
|
import ru.kirillius.pf.sdn.web.ProtectedMethod;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -47,8 +48,10 @@ public class Auth implements RPC {
|
||||||
*/
|
*/
|
||||||
@ProtectedMethod
|
@ProtectedMethod
|
||||||
@JRPCMethod
|
@JRPCMethod
|
||||||
public void removeToken(@JRPCArgument(name = "token") String token) {
|
public void removeToken(@JRPCArgument(name = "token") String token) throws IOException {
|
||||||
context.getServiceManager().getService(TokenService.class).remove(new AuthToken(token));
|
var service = context.getServiceManager().getService(TokenService.class);
|
||||||
|
service.remove(new AuthToken(token));
|
||||||
|
service.store();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -56,10 +59,12 @@ public class Auth implements RPC {
|
||||||
*/
|
*/
|
||||||
@ProtectedMethod
|
@ProtectedMethod
|
||||||
@JRPCMethod
|
@JRPCMethod
|
||||||
public String createAPIToken(@JRPCArgument(name = "description") String description) {
|
public String createAPIToken(@JRPCArgument(name = "description") String description) throws IOException {
|
||||||
|
var service = context.getServiceManager().getService(TokenService.class);
|
||||||
var token = new AuthToken();
|
var token = new AuthToken();
|
||||||
token.setDescription(description);
|
token.setDescription(description);
|
||||||
context.getServiceManager().getService(TokenService.class).add(token);
|
service.add(token);
|
||||||
|
service.store();
|
||||||
return token.getToken();
|
return token.getToken();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue