Roles for pages

I am new to Userfrosting. I installed the homestead version und started to develop my first sprinkle.

I already created three pages a, b and c. I added the three pages to the main menu in my sprinkle and it worked. After that I added the guard-option, I have to login before I can see the pages like it should.

Now I want to do that: Page a should only view to role 1, page b only to view for role 2 and page c only for role 3. I do not know how I can do this.

I already add a couple of new useres with userfrosting, created roles and add the roles to the users. I do not know how I can tell the page, that it only should be view by a special role (or for two different roles).

Two minor problems: In homestead I did not install an SMTP server. So I could not add users with the front end, because of mail problems. Can I turn off the complete mail verification? [In the moment I add the users directly to the database.]

I tried to configure the AdminLTE. I added new photos to the slides. My fotos are smaller than the original version. So my photos are aligned left and on the right hand side is a big area of grey. How can I make the width of the slides smaller and/or center the photos to the slide?

Thank you for your support and a merry christmas!

Welcome to UserFrosting!

So, first thing - just to introduce some vocabulary:

Now I want to do that: Page a should only view to role 1, page b only to view for role 2 and page c only for role 3. I do not know how I can do this.

This is called authorization. In UserFrosting, authorization is not performed directly on roles. Rather, it is performed on permissions, which are then associated with roles. See this guide. Basically, for maximum flexibility, you’ll create a separate permission for each page and then associate these permissions with the roles you wish to have these permissions.

Homestead does not install a mail server (actually, running your own mail server is a very complicated thing). At the moment you can’t turn off the mail requirement for adding new users through the admin interface, but there is an open pull request that will be added in UF 4.2.

As for the styling issues, I’m terrible with CSS. Maybe someone else can help here?

Thank you. I did not associate the permission to the role. I did work with the tutorial again and it works now.

Just one problem: When the users does not have the permission to the page I do this code:
throw new ForbiddenException();

But I get an run time error in this case: “UserFrosting\Support\Exception\ForbiddenException No message”.

I did add the line
use UserFrosting\Support\Exception\ForbiddenException;
but the message is still there.

Thanks

It sounds like it’s functioning normally. If you have debugging mode turned on, when access is denied you’ll see the raw Exception rather than a user-friendly error page. See https://learn.userfrosting.com/troubleshooting/debugging#runtime-errors. Set settings.displayErrorDetails to false in your config to see this in dev mode.

Thank you. It works.

No problem. By the way, I’ve updated our mail docs to give you some more options for a mail services provider.