Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Location switch bug fix #532

Merged
merged 4 commits into from Oct 22, 2020

Conversation

ryanmitchell
Copy link
Member

Came across this random bug where the location change wouldn't stick in Chrome... the fix ended up being to clear the session before adding to it.

Came across this random bug where the location change wouldn't stick in Chrome... the fix ended up being to clear the session before adding to it.
@ryanmitchell
Copy link
Member Author

In fact, this only works if you're a superadmin. If youre not, then it still fails to let you switch. The right session var is setup, but on page reload it resets back. Any guidance gratefully received!

@ryanmitchell
Copy link
Member Author

Ok, want to ask before I commit changes...

return $this->getAuth()->locations()->contains(function ($model) use ($id) {

Should this not be

return !$this->getAuth()->locations()->contains(function ($model) use ($id) {
            return $model->location_id === $id;
        });

return $this->getAuth()->locations()->isNotEmpty();

Should this not be isEmpty()

Feels like the functions do the reverse of what their name suggests?

@ryanmitchell
Copy link
Member Author

Hmm actually, thats not right either.

I think this:

if ((!$id AND $this->hasRestriction()) OR $this->isNotAttachedToAuth($id))

needs to become:
if ((!$id AND $this->hasRestriction()) OR !$this->hasAccess($id))

@sampoyigi
Copy link
Member

Yea the last one works but then breaks as hasLocationAccess expects a model, so maybe rename isNotAttachedToAuth to isAttachedToAuth and add

if ($this->getAuth()->isSuperUser())
     return TRUE;

so we end up with if ((!$id AND $this->hasRestriction()) OR !$this->isAttachedToAuth($id))

the changes to the Menu widgets won't be needed.

@ryanmitchell
Copy link
Member Author

Yep thats perfect. Updated.

@sampoyigi sampoyigi merged commit 497bc53 into tastyigniter:develop Oct 22, 2020
@ryanmitchell ryanmitchell deleted the fix-location-switch-bug branch October 29, 2020 21:09
llaramtz pushed a commit to llaramtz/TastyIgniter-1 that referenced this pull request Nov 17, 2020
* Location switch bug fix

Came across this random bug where the location change wouldn't stick in Chrome... the fix ended up being to clear the session before adding to it.

* Revert "Location switch bug fix"

This reverts commit 35ad407.

* Change of approach

Co-authored-by: Sam Poyigi <sam@sampoyigi.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants