Dear
I’m trying to convert the following Play 2.5 code into Play 2.8:
public class Perms extends Action.Simple {
@Inject
private UsersRepository users;
@Override
public CompletionStage<Result> call(Http.Context ctx) {
Users user = users.findById(session("id"));
List<Permissions> perms = user.getPermissions();
ctx.args.put("perms", perms);
return delegate.call(ctx);
}
public static List<Permissions> current() {
return (List<Permissions>) Http.Context.current().args.get("perms");
}
The following code seems to have errors because IntelliJ gives me the message that the put() method wants a TypedKey key.
public class Perms extends Action.Simple {
@Inject
private UserRepository userRepository;
@Override
public CompletionStage<Result> call(Http.Request request) {
User user = userRepository.findByUserId(request.session().get("id").orElse(null));
List<Permissions> perms = user.getPermissions();
request.attrs().put("perms", perms);
return delegate.call(request);
}
public static List<Permissions> current(Http.Request request) {
return (List<Permissions>) request.attrs().get("perms");
}
}
How can I solve it?
Thanks
}