Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7669935
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T15:42:29+00:00 2026-05-31T15:42:29+00:00

Need to know if I’m missing something… I’m using sfGuardPlugin and trying to get

  • 0

Need to know if I’m missing something… I’m using sfGuardPlugin and trying to get a complex credential to work… and it’s not even that complex. I just can’t get either AND or OR to work.

“user_a” is set up to have permission “A” in both permissions and group “A” which also has permission “A” assigned to it.

I also have a Permission “B” and a group “B” set up in the same fashion as above… however, I did not assign user_a to these permissions. To be clear: user_a only has A permissions.

Now in security I have the following (where the user needs to either have credential A or B):

dashboard:
  credentials: [[A, B]]

Now when I try to have user_a access the dashboard, it fails and redirects to the credentials required page. I tried the same thing with an AND statement and set up user_a with both, using:

dashboard:
  credentials: [A, B]

…again, it failed.

Now, when I remove the brackets, and just use one credential, it all works perfectly. It’s just when I use them in combination, in any form, that I run into problems.

Furthermore, I have checked if the user has a single credential, using:

echo $user->hasCredential('A');

And it responds as expected: True

But if I assign the user to both A and B and then try either:

echo $user->hasCredential(array('A', 'B'), false);

or

echo $user->hasCredential(array('A', 'B'));

It responds with False.

I’m stumped. What am I missing? I MUST have at least the [[OR]] working. Has anyone else experienced this? Is there a work-around?

EDIT: code snippet in myUser.class:

public function hasCredential($permission_name)
    {
    //this overrides the default action (hasCredential) and instead of checking
    //the user's session, it now checks the database directly.  
    if (!$this->isAuthenticated()) {
      return false;
    }
    $gu = $this->getGuardUser();
    $groups = $gu->getGroups();
    $permissions = $gu->getPermissions();

    $permission_names = array();
    foreach($permissions as $permission) {
      $permission_names[] = $permission->getName();
    }
    foreach($groups as $group) {
      $group_permissions = $group->getPermissions();
      foreach($group_permissions as $group_permission) {
        $permission_names = array_merge($permission_names, array($group_permission->getName()));
      }
    }
    $permission_names = array_unique($permission_names);
    return (in_array($permission_name, $permission_names)) ? true : false;
  }

EDIT:

The above code snippet is indeed the problem. I tested it without the code snippet and it works as expected. So my next question, is how to tweak the snippet to accommodate instances with AND or OR? Suggestions?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T15:42:30+00:00Added an answer on May 31, 2026 at 3:42 pm

    I’m going to close this question, because I have found the problem and I will open a new question as a result of the issue I’m having with the code snippet (which becomes a new question).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to know how I get the stream of the headers and footers
I need know what elements are in current mouse position and I'm using jQuery.
Need to know if I need to worry about people using this on my
I need know how can get a parameter from the URL. I mean if
Need to know how to get YQL to return only data that's newer than
Need to know this so that i could send DTMF and that is going
I need to know about Epoll On linux System. Could you recommend manual or
I need to know how the performance of different XML tools (parsers, validators, XPath
I need to know how much space occupies all the databases inside an SQL
I need to know how to turn on Code Coverage when running TFS builds

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.