Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

toneee's avatar

Best method for Multi Auth in Spark?

Hi All,

I am currently writing an app in Laravel 5.2 and have configured multi auth so that users and customers have two different tables etc.

I am thinking about moving over to spark as it has 100% of the features I have been writing in laravel already built. I am only about 50% of the way though building those features at the moment.

My question is around multi auth for these two distinct user types/groups. Is it better to stick with single auth but then separate into different roles and then have another table for customer and users with a user_id foreign key and just join them or recreate the multi auth setup I currently have?

Any thoughts on both solutions?

Thanks!

0 likes
2 replies
martinbean's avatar

@toneee My thought it you shouldn’t have split users into separate tables. That means you need separate controllers, views, and—as you’ve found out—authentication strategies.

Also, what happens if you need to introduce another user type (say a moderator)? Or account managers? Are you just going to create database tables and authentication strategies for these? Customers are users. Administrators are users. Moderators are users. There’s no need to store them in separate tables. What happens if one user is a customer of one entity, but a moderator of another?

Instead, simplify your life by having all your application’s users in one table. You can use either a column or a pivot table to define what ‘type’ of user they are, and then have middleware to restrict parts of your application to users with the required roles.

1 like
toneee's avatar

@martinbean , Thanks for your thoughts and its pretty much the same thought process I have gone through. So it would be acceptable to have something like

User tables

userid - User ID
username
password

Seller profile table

sellerid - profile ID
userid - foreign key to users table
address
custom seller profile info...

Buyer profile table

buyerid - profile ID
userid - foreign key to users table
address
custom buyer profile info...

Then use a join to link the user to their profile.

Please or to participate in this conversation.