Ejemplo n.º 1
0
  public static void signIn(String url, String email, String password) {
    if (url == null || url.isEmpty()) {
      url = Router.reverse("Application.app").url;
    }

    if (email != null && !email.isEmpty() && password != null && !password.isEmpty()) {
      SecurityModel securityModel = securityManager.signIn(email, password);
      if (securityModel != null) {
        currentUser = securityModel.user;
        session.put("api_key", securityModel.securityKey);
        redirect(url);
      }
    }

    home();
  }
Ejemplo n.º 2
0
  @Before
  public static void checkAuth() {
    if (request.url.startsWith(Router.reverse("GuiController.signIn").url)
        || request.url.startsWith(Router.reverse("GuiController.signUp").url)
        || request.url.startsWith(Router.reverse("GuiController.home").url)) {
      renderArgs.put("menu", MenuManager.hardCode(User.GUEST));
      return;
    }
    apiKey = session.get("api_key");
    //        apiKey = params.get( "api_key" );
    currentUser = securityManager.getUser(apiKey);

    renderArgs.put("menu", MenuManager.hardCode(currentUser));

    if (currentUser != null && !currentUser.isGuest()) {
      Logger.info(currentUser + "[" + request.domain + "] " + request.url);
      renderArgs.put("currentUser", currentUser);
      renderArgs.put("api_key", apiKey);
      return;
    }

    Logger.debug("An unauthorized user tried to access " + request.url);
    home();
  }
Ejemplo n.º 3
0
 public static void signOut() {
   securityManager.signOut(apiKey);
   home();
 }