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.web.ProtectedMethod;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
|
|
@ -47,8 +48,10 @@ public class Auth implements RPC {
|
|||
*/
|
||||
@ProtectedMethod
|
||||
@JRPCMethod
|
||||
public void removeToken(@JRPCArgument(name = "token") String token) {
|
||||
context.getServiceManager().getService(TokenService.class).remove(new AuthToken(token));
|
||||
public void removeToken(@JRPCArgument(name = "token") String token) throws IOException {
|
||||
var service = context.getServiceManager().getService(TokenService.class);
|
||||
service.remove(new AuthToken(token));
|
||||
service.store();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -56,10 +59,12 @@ public class Auth implements RPC {
|
|||
*/
|
||||
@ProtectedMethod
|
||||
@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();
|
||||
token.setDescription(description);
|
||||
context.getServiceManager().getService(TokenService.class).add(token);
|
||||
service.add(token);
|
||||
service.store();
|
||||
return token.getToken();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue