00:02
The last thing that we need to do here is add our authorization checks to what's actually displayed visually to the user inside of our application.
00:12
So for example, this user doesn't have the ability to edit or delete an organization. So they should not see the edit nor delete action here within the organization dropdown.
00:21
And then the exact same thing here inside of our organization settings. If we can't edit it, then we probably shouldn't see this entire card.
00:28
Likewise, if we can't remove users who aren't us, we should not see the remove button for users who aren't us specifically.
00:36
And then the exact same thing with the pending organization invitations down here. We should not see this form altogether nor the cancel invite button. So let's go into our text editor here and make those changes.
00:46
First, we can start with our organization select. So we'll dive into that component. Off the bat, it seems like we have a use form import that's not used, so we can go ahead and get rid of that.
00:54
We're gonna want to accept into our props, our can variable, which will come from our page or layout, depending on how we're making use of it.
01:02
So this will be of type abilities, which we're extracting out of our get abilities action.
01:07
And we can now scroll on down to those two dropdown menu items and wrap them in VIFs.
01:14
So for the edit, we can do VIF, can, organization, edit, so that this dropdown menu button only displays if the authenticated user has the ability to edit the organization.
01:26
The exact same thing here with our delete. VIF, can, organization, destroy.
01:32
Now, before we test this out, we need to actually go through and cascade this can variable down into our organization select component. So this is rendered by our navigation component.
01:42
So if we dive into our navigation component, we want to scroll up to the props here and into here, which will be of type abilities again.
01:49
Then our can prop from our navigation will automatically cascade through to our organization select props because we're binding all of our navigation props directly into our organization select.
01:59
So we're good to move on now to our app layout, which is rendering our navigation component.
02:05
So just going up another level here and our navigation components doing the exact same thing as our organization select, taking in all of the app layout props as its own props there.
02:15
So all we need to do is add our can of type abilities to our app layout props. And with that set, we're now good to go ahead and jump into our browser, open up our organization select.
02:25
And we can see that they are now hidden outside of here, but we do have an extra horizontal rule or separator going on there. So let's go ahead and dive back into our organization select.
02:34
And all right, we could have one before and one below.
02:38
So we just need to do a VIF can organization edit or an organization destroy to only show this additional separator if we have one of these two actions available to our user.
02:51
So save that, jump back into here. And now that extra rule is gone.
02:55
All right, next, let's go ahead and hide our update organization card, which if we bring out our Explorer, scroll on down, we should be able to do this directly inside of our settings organization page.
03:05
Just hide the card altogether.
03:07
So since this is a page, we can take our can abilities directly in here, and then just wrap the edit card altogether in a VIF can organization edit.
03:18
Give that a save, jump back into our browser, give that a refresh.
03:21
And there we go, that card is now altogether gone, which now leaves us with our remove buttons for our users and invitations. So let's dive back into our text editor.
03:31
Before we dive into either one of those components though, we first wanna cascade our can through to them so that they have them to work with.
03:37
So we'll add our can onto the props there, as well as for our users invite.
03:42
And then we can go ahead and dive into our user card for our organization, and let's add that into our props. So go and drop these down into new lines.
03:50
All right, and let's add in our can type abilities, and then scroll on down because it is the remove button that we want to hide if the user does not have the ability to remove the current member that we're looping over here.
04:03
So similar to how we're tacking that U on right there, we want to be if can organization manage users or member.id equals user.id.
04:15
So if the authenticated user has the ability to manage users, then they can go ahead and delete whoever they want.
04:21
Otherwise, if they are the current user that we're looping over, then we'll allow them to remove themselves.
04:26
So with that, we should be able to save this, jump back into our browser, and of our three organization members, we should only see the remove button on ourselves, which is what we're seeing exactly.
04:37
And then for our pending organization invites, we just want to hide it based off of the user's ability to manage users.
04:43
So user invite card, right where we have the cancel invites, we first want to jump up to our props, grab our can of type abilities, scroll back down, and let's tack on a VIF can organization manage users.
04:59
And that's all that we want to do here. So we'll give that a save, jump back into our browser. And now that is gone altogether.
05:06
If you wanted to, you could wrap the entire table cell here in that instead.
05:11
So let's move that VIF actually up to the table cell and add it onto the table head there too, to just remove that column altogether if the user does not have that ability.
05:21
So with that set, a minuscule difference, but just things are taking up a little bit more width here between our email and role columns.
05:28
And then lastly, we want to hide this invite form if the user does not have the ability to manage users. So we have our entire div right here.
05:36
We'll just wrap that in the same VIF can organization manage users, give that a save, jump back into our browser, and there we go.
05:44
Now we have a simplified pending organization invitations for our member user. And then we can go ahead and jump back over into our administrator.
05:52
So testuser1@test.com, type in our password, jump back over into our organization settings where we still see the update organization, where we can still edit it, update it, just get rid of that again, and remove any user that we want, cancel any pending invitations, as well as invite new members.
06:12
And then we can check out our organization selects, and we still have the ability to edit here and delete there as well.