Created
February 14, 2012 21:24
-
-
Save danielberndt/1830585 to your computer and use it in GitHub Desktop.
Bug with play2.0 action composition
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Auth extends Controller { | |
@With(RolesAction.class) | |
@Target({ElementType.TYPE, ElementType.METHOD}) | |
@Retention(RetentionPolicy.RUNTIME) | |
public @interface MinRole { | |
Role value() default Role.Admin; | |
} | |
public static class RolesAction extends Action<MinRole> { | |
public Result call(Http.Context ctx) throws Throwable { | |
User user = User.find.ref(1L);// <--- problem arises here | |
if (user==null || !user.role.greaterEqual(configuration.value())) { | |
return unauthorized("no access for you!"); | |
} | |
return delegate.call(ctx); | |
} | |
} | |
@MinRole(Role.Admin) | |
public static Result adminOnly() { | |
return ok(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment