Display Sidebar and Pages based on the User Role in Laravel 5.1 - authentication

I am Using the Same Login Box and i am Differentiating the Users after Login using Auth::attempt() function. In my project i have only one Sidebar which Contains all the Menus that are required for my project.
I have Four Login roles namely Admin / Teaching Staff / Non-teaching Staff / Parent.
My doubt is that i need to display only some menus and related Blade(Views) that are inside that Sidebar Menu for different login users.
Screenshot Attachment:
Click Here
I dont need to Redirect the Page based on the Login Users i need to alter my display based on Login Attempts.
I have not used any Packages for Authentication i am using only Auth::Login and Auth::attempt() functions.
Can you please provide me with a Solution of how to Get rid of This Error for Me.

How i would do it is Auth::check() and then i would do if statement with elseif
So it would look like this
#if($User->Role == 1 )
Nav Items for Admin
#elseif($User->Role == 2)
Nav items for Teaching Staff
#elseif($User->Role == 3)
Nav Items for Non-teaching Staff
#elseif($User->Role == 4)
Nav Items for Parent
#endif

Related

How to open new tab group in ionic framework (Vue.js) after the user logs into the application

At first, I want to display the login and register tab pages but after the user logs in or register I want to show a new group tab.
I tried some solutions but it didn+t work for me

Django - How to redirect to particular page after login using Django Panel Login functionality

I am using Class Based View, and in this particular form (based on FormView) I want restrict access to Logged Users only. It somehow works, but I want after user give login / password go back, redirect to particular site - for example named "my_form" or other (could be home page), but in this case, after login Django Admin shows. I need its functionality only for login and I want go back to desired location, 'my_form' page.
How can I achieve this? Don't want decorators here, as I want to use this special Mixin.
class EmployeeLocationFormView(LoginRequiredMixin, FormView):
login_url = 'admin:login'
redirect_field_name = 'my_form'

Login screen for a Ext JS 4.0.7 application

I've developed an Ext JS 4.0.7 app for my company. It has various modules for different team's needs. Now, the company want to make sure only relevant people have access to relevant modules in an app. It's an ERP application which has CRM, MRP, Engineering, HR and Finance modules. Now, respective team members should have access to respective menus and pages and super admin will have access to everything.
I know how to control the menus based on user login. But not sure how to integrate user login screen into my app. I know basics of Ext JS and able to design a Login screen using form panel ...... but not sure how to make it as my app's first screen and upon successful login, let the user in and able to logout from there.
If anyone already developed such functionality, i request to share the solution here. Any pointers or code snippets will be a great help.
Thanks very much in advance.
My application has a header (company logo and app title - horizontal on north) and left menu and content panel.
So, here is how login/logout screen implemented.
When app is loaded, when viewport is loaded, on render, I load menu store and load 'Login' and 'Change Password' menu items in them.
When user enters login/pwd, via ajax call , will call servlet and process login data. Upon login successful, based on user role, respective menu json built in server side and menu store is loaded with this json. This json has 'Logout' menu by default. So, when user logs out, will load Login screen in content panel.
Not sure whether any other best ways to implement the same. But this is working well.

Broadleaf commerce display some product to logged in users only

I am developing an e-commerce application using broad-leaf commerce.
My requirement is I have to add an product from login panel and display that product to only logged in users. Here few product products will be visible to all users (guest too) and few will be visible to only logged in users.
is there any way to do this?
Thanx soulfly1983 fou your try,but I found another alternative to do this without any customization. here is the full procedure..
Add a new category from admin panel.
Add a new page from admin panel (under content tab) and note the URL should be the same of category and page.
3 In the page click on rule tab.
4 Check the yes button in "Restrict to certain customers?"
Click +rule button and the select "match all" and select customer registered is equal to false
So this page will be visible to only guest users.
In the HTML body section of the rule (in general tab) write a message "you need to log in to view this stuff"
When user will log in successfully the user will not be able to the page , because we applied a rule that only logged out users can see the page so this time user will see the category and products added to that category.
am I doing right? any regarding this suggestion?
You can either extend the Product entity and add a field that will indicate whether that product will be visible to all users, or alternatively you could simply add an attribute for each product via the admin interface. Either way you will need to modify the UI logic so that it will take this additional field (or attribute) into consideration.

Sitecore - Prevent access to a page, but still show it in the navigation

In Sitecore I have denied access to a particular page for the anonymous user.
This works correctly, but it also means that the page does not appear in the navigation menus and sitemap (both XSLT).
What I would like is for the user to be able to see the link, but be redirected to a Register/Login page when they click on it.
You'd need to allow anonymous users to view the page for it to be visible in the menu and sitemap.
What you could do though is override the Sitecore.Pipelines.HttpRequest.HttpRequestProcessor to check if the page requires a login (by adding a RequiresLogin True/False to the template for example), then check if the user is logged in if not redirect to your login page.
Theres an example of overriding the HttpRequestProcessor here
You could wrap the rendering logic in the menus in a SecurityDisabler, so it would render all item links, even if the user "cant see" them.
using (SecurityDisabler disabler = new SecurityDisabler())
{
foreach (Item item in Sitecore.Context.Item.Children)
{
... render the link ...
}
}