package com.backend.auth;

import com.backend.domain.Role;
import com.backend.domain.UserEntity;

/**
 * Request scoped holder for currently authenticated user
 */
public class CallContext {

    private UserEntity loggedUser;

    public UserEntity getLoggedUser() {
        return loggedUser;
    }

    public Long getLoggedUserId() {
        if (logged()) {
            return loggedUser.getId();
        } else {
            return null;
        }
    }

    public void setLoggedUser(UserEntity loggedUser) {
        this.loggedUser = loggedUser;
    }

    public boolean logged() {
        return loggedUser != null && loggedUser.getId() != null;
    }

    public Role getCurrentRole() {
        if (loggedUser == null || loggedUser.getRole() == null) {
            return Role.ANONYMOUS;
        } else {
            return loggedUser.getRole();
        }
    }
}

@@ -89,16 +89,64 @@
 rEntity;
+%0Aimport com.google.inject.servlet.RequestScoped;
 %0A%0A/**%0A *
@@ -205,16 +205,31 @@
 ser%0A */%0A
+@RequestScoped%0A
 public c

FIX CallContext must be @RequestScoped