diff --git a/app/src/main/java/ru/kirillius/pf/sdn/web/RPC/Auth.java b/app/src/main/java/ru/kirillius/pf/sdn/web/RPC/Auth.java index 21b716f..99878a1 100644 --- a/app/src/main/java/ru/kirillius/pf/sdn/web/RPC/Auth.java +++ b/app/src/main/java/ru/kirillius/pf/sdn/web/RPC/Auth.java @@ -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(); }