Developing more than one user accounts in laravel 5.2 - php

Note: There is no code to show or prove it, we just need a methodology to solve the problem before implementing the code to our code base.
We have more than one user for our fashion web (laravel app)
Guest (does not matter to this issue)
User (Fashion lovers/Customers/Clients)
Tailors (Fashion designers new/existing accounts in the platform)
The users(customers) can login and register to their application without no problem but our problem is how can we filter the two users(customers/tailors) such that when a user (tailor) logins to www.app.dev/tailor#dashboard (without access) it redirects to (www.app.dev/login) and when the user is a tailor it takes the user to tailors login page instead the user (customers) login, Do you understand me??

check for following stackoverflow questions
Can anyone explain Laravel 5.2 Multi Auth with example
How to use multi Auth in laravel 5.2
Multiple auth user types in Laravel 5

Related

How do you setup permission/views/routes for different user roles?

I am building a eCommerce platform. Where I have to make several user roles and specific permission for them. I have successfully created admin and default user roles and permission.
But I am getting so much trouble to show the views and menu items based on other user roles like Editor/Manager/CS Team.
I tried to do using different middleware for every one of them. But It's not working efficiently and even at all.
For the Admin role, I created a Admin Middleware where I am checking user role type and giving access. I defined the admin middleware on Route gruop.
Can you suggest me? - how to setup permission/views/menu items efficiently for different user roles?
Thanks in Advance.
Note: I am trying to do it without any package.
Yes you can make your own custom build library by setting roles,permission table in database and as soon as the user log's in you put all that information in session or cache. But doing so might get you in trouble in future coz lack of testing it's all feature, You have to be sure what exactly you are doing to manage it by yourself or else you can use already tested many time library like
laravel-permission
Using a well known and trusted library ensures that it will solve your problem, but take your time to read it's documentation and analyse if it contains all features that you want in your application.
You need to define policy.
Policies are a great way to protect actions on your Eloquent Model. Laravel Policies are the part of Laravel Authorization that helps you to protect resources from unauthorized access.
Please refer this documentation to how to register policy and how it works in views file:
https://www.larashout.com/laravel-policies-controlling-authorization-in-laravel

Instead of using Laravel local user data, how to login to Laravel using Prestashop customers data

i want to ask a question regarding the login to Laravel using Prestashop customers data.
Recently, I'm doing a new project whereby in Laravel user login, I want to use Prestashop users (customers) data. That is we will not using Laravel own local user data, but we will use prestashop customers data.
How do I integrate Laravel with Prestashop in user login? Create custome authentication?
And how do I modified the AuthenticateUser in Laravel? I have been searching online in this matter, but I can't find any related.
You may find some libraries that may or may not facilitate this, however, when I needed a similar feature, I simply developed it myself. In brief:
1) In Laravel create a service to authenticate the user through the PrestaShop API.
2) Depending on the response from PrestaShop, you can create a USER in Laravel and instead of a password, save an access token. Same as you would do with say FB login but obviously cannot use Socialite direct - albeit you can extend it or copy its code.
3) You can if wish copy the PrestaShop credentials and allow the user to login directly through Laravel in the future.
There are other methods you can use instead of my suggestion, such as continuously update the Laravel's users' tables from PrestaShop but this is not very consistent and secure.

Pass data from Laravel website to Joomla and vice-versa

I'm trying to find a way to use the Joomla extension Hikashop in parallel with another external website built with Laravel.
I'm using :
Laravel 5.5
Joomla 3.8.x
Here is how the setup looks (extremely simplified) :
___________________________ ________________
|Joomla server with Hikashop| <---- API calls ----> | Laravel server |
⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻ ⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻⎻
To get products, prices, purchases etc. all is done through API request to the Joomla website using the com_api component and a custom plugin that returns everything I need.
For user consistency, whenever a user is created, modified or deleted on Laravel, the user is created, modified or deleted on Joomla.
Note 1 : The user cannot edit his profile on Joomla so the sync is only one way.
Note 2 : The login should only be on the Laravel website
Here is the problem i can't get around : on the Laravel website, when the user wants to buy a product, he is redirected to the Joomla website to access the Hikashop interface and pay for the product. This creates multiple questions :
Question 1 : Since the user is on Laravel, he has not session yet on Joomla. How do you pre-create the Joomla session using an API so that when the user arrives on Joomla he is already logged in ?
Question 2 : Once the payment is made, how do you redirect the user the the previous page on Laravel ? (The trigger is good, the only issue is passing the "origin" URL around)
I've tried looking into SSO (Single Sign On) but i would like to keep the two systems separated.
Thank you in advance if you have any ideas or ways to pass session + data from one website to another !
In my own understanding this is , how I will do it.
First if you are form laravel, you needed to be authenticated.
You assign the user from laravel with the equivalent user_id in joomla if you have same user in joomla. If not never mind.
just make the user authenticated either laravel and joomla. Make a token after signed private token not jwt or oauth2. Just to make sure that when you successfully login in both laravel and joomla. there is a similar token related for both of them.
Then you are good to do now.

Multiple Authentication Laravel - Socialite Plugin

I've implemented multiple authentication in my Laravel application and I have two different tables to accomplish this task (users and clients).
Everything works fine, the the only issue I've met is related to social authentication. I've followed all the configuration about Socialite-plugin but I don't know how to set up the redirect URL depending on wich type of user (users or clients) is trying to log in.
Any suggestions?
How you check if user is user or client?
You can add extra parameter to redirect route
Route::get('auth/{type}/{provider}', 'SocialAuthController#redirect')
(where {type} is user type)

Single Sign On between Yii and Moodle two php application

I have implement SOS concept between two php application. it application it available different domain like one is www.example.com and another is www.test.com.
My required following condition.
1.When user is login any appplication to login this user with check user name and password into mysql database table
2.After login any application username and password is not required/reenter user can directly login this application similar to Google.
3.When user logout at time both application can be logout.
-->my first application can be created Yii framework and another is moodle
please give idea to implement this concept in my both application

Categories