Esempio n. 1
0
 @Override
 public boolean beforePermissionError(
     String permission, WebContext ctx, Controller controller, Method method) throws Exception {
   if (UserContext.getCurrentScope() != ScopeInfo.DEFAULT_SCOPE) {
     return false;
   }
   if (UserInfo.PERMISSION_LOGGED_IN.equals(permission)) {
     if (ctx.getSessionValue("otp-user").isFilled()) {
       // TODO
       ctx.respondWith().template("view/wondergem/otp.html", ctx.getRequest().getUri());
     } else {
       ctx.respondWith().template("view/wondergem/login.html", ctx.getRequest().getUri());
     }
   } else {
     // TODO
     ctx.respondWith()
         .template("view/wondergem/permission-error.html", ctx.getRequest().getUri(), permission);
   }
   return true;
 }
Esempio n. 2
0
 /**
  * Tries to resolve a template or content-file into a {@link Resource}
  *
  * @param uri the local name of the uri to load
  * @return a {@link Resource} (wrapped as resource) pointing to the requested content or an empty
  *     optional if no resource was found
  */
 @Nonnull
 public Optional<Resource> resolve(@Nonnull String uri) {
   return resolve(UserContext.getCurrentScope().getScopeId(), uri);
 }