internetguru / laravel-user
Interent Guru Laravel User
Requires
- php: ^8.4
- internetguru/laravel-common: ^5
- internetguru/laravel-model-browser: ^5
- laravel/framework: ^9.0 || ^10.0 || ^11.0 || ^12.0 || ^13.0
- laravel/socialite: ^5.16
- livewire/livewire: ^3.0 || ^4.0
- socialiteproviders/manager: ^4.6
Requires (Dev)
- internetguru/laravel-common: ^5
- laravel/pint: ^1.17
- laravel/socialite: ^5.16
- livewire/livewire: ^3.5 || ^4.0
- orchestra/testbench: ^9.5
- phpunit/php-code-coverage: ^11.0
- socialiteproviders/manager: ^4.6
- dev-main
- v7.0.1
- v7.0.0
- v6.7.2
- v6.7.1
- v6.7.0
- v6.6.3
- v6.6.2
- v6.6.1
- v6.6.0
- v6.5.0
- v6.4.7
- v6.4.6
- v6.4.5
- v6.4.4
- v6.4.3
- v6.4.2
- v6.4.1
- v6.4.0
- v6.3.0
- v6.2.6
- v6.2.5
- v6.2.4
- v6.2.3
- v6.2.2
- v6.2.1
- v6.2.0
- v6.1.4
- v6.1.3
- v6.1.2
- v6.1.1
- v6.1.0
- v6.0.1
- v6.0.0
- v5.3.1
- v5.3.0
- v5.2.1
- v5.2.0
- v5.1.2
- v5.1.1
- v5.1.0
- v5.0.0
- v4.2.12
- v4.2.11
- v4.2.10
- v4.2.9
- v4.2.8
- v4.2.7
- v4.2.6
- v4.2.5
- v4.2.4
- v4.2.3
- v4.2.2
- v4.2.1
- v4.2.0
- v4.1.8
- v4.1.7
- v4.1.6
- v4.1.5
- v4.1.4
- v4.1.3
- v4.1.2
- v4.1.1
- v4.1.0
- v4.0.0
- v3.0.0
- v2.9.6
- v2.9.5
- v2.9.4
- v2.9.3
- v2.9.2
- v2.9.1
- v2.9.0
- v2.8.1
- v2.8.0
- v2.7.0
- v2.6.0
- v2.5.10
- v2.5.9
- v2.5.8
- v2.5.7
- v2.5.6
- v2.5.5
- v2.5.4
- v2.5.3
- v2.5.2
- v2.5.1
- v2.5.0
- v2.4.5
- v2.4.4
- v2.4.3
- v2.4.2
- v2.4.1
- v2.4.0
- v2.3.4
- v2.3.3
- v2.3.2
- v2.3.1
- v2.3.0
- v2.2.5
- v2.2.4
- v2.2.3
- v2.2.2
- v2.2.1
- v2.2.0
- v2.1.1
- v2.1.0
- v2.0.6
- v2.0.5
- v2.0.4
- v2.0.3
- v2.0.2
- v2.0.1
- v2.0.0
- v1.0.0
- v0.16.1
- v0.16.0
- v0.15.1
- v0.15.0
- v0.14.1
- v0.14.0
- v0.13.0
- v0.12.3
- v0.12.2
- v0.12.1
- v0.12.0
- v0.11.0
- v0.10.6
- v0.10.5
- v0.10.4
- v0.10.3
- v0.10.2
- v0.10.1
- v0.10.0
- v0.9.1
- v0.9.0
- v0.8.0
- v0.7.0
- v0.6.0
- v0.5.0
- v0.4.5
- v0.4.4
- v0.4.3
- v0.4.2
- v0.4.1
- v0.4.0
- v0.3.0
- v0.2.5
- v0.2.4
- v0.2.3
- v0.2.2
- v0.2.1
- v0.2.0
- v0.1.2
- v0.1.1
- v0.1.0
- dev-dev
- dev-main-7
- dev-staging
- dev-hotfix-petrzpav
- dev-main-6
- dev-main-4
- dev-main-5
- dev-main-3
- dev-main-2
- dev-main-1
- dev-main-0
This package is auto-updated.
Last update: 2026-06-03 04:36:55 UTC
README
Internet Guru Laravel User is a library that provides seamless integration with various social authentication providers. It stores the user's social identity in the database and allows the user to link multiple social identities to a single account. It also provides PIN-based login via email and a full user management UI.
| Branch | Status | Code Coverage |
|---|---|---|
| Main | ||
| Staging | ||
| Dev |
Table of Contents
- Features and Terminology
- Installation
- Configuration
- Roles
- Socialite Providers
- Demo Mode
- PIN Login
- Language and Locale
- User Management
- Blade Components
- User Preferences
- Association History
- User Policy
- IgUserSeeder
- Publishing
- E2E Tests
- License & Commercial Terms
Features and Terminology
- Account – application user account.
- Identity – provider & provider_user_id.
- Register – create a new account with a new identity linked to it.
- Connect – link a new identity to the current account.
- Disconnect – unlink an existing identity from the current account.
- Transfer – unlink an existing identity from one account and link it to the current one.
- Automatic account – an account created programmatically, e.g. during data import, that has never been logged into;
created_byequals its ownidandlogged_atisnull.
Installation
-
Install the package via Composer:
composer require internetguru/laravel-user
-
Publish and run the migration files:
php artisan vendor:publish --provider="InternetGuru\LaravelUser\LaravelUserServiceProvider" --tag="ig-user:migrations" php artisan migrate
-
Set required session configuration in
config/session.php:'expire_on_close' => true, 'lifetime' => 120,
The service provider throws an exception in debug mode or logs a warning in production if these values are not set correctly.
Configuration
Environment Variables
| Variable | Default | Description |
|---|---|---|
GOOGLE_CLIENT_ID |
— | Google OAuth client ID |
GOOGLE_CLIENT_SECRET |
— | Google OAuth client secret |
GOOGLE_REDIRECT_URI |
— | Google OAuth redirect URI |
SEZNAM_CLIENT_ID |
— | Seznam OAuth client ID |
SEZNAM_CLIENT_SECRET |
— | Seznam OAuth client secret |
SEZNAM_REDIRECT_URI |
— | Seznam OAuth redirect URI |
AUTH_DEMO |
false |
Enable demo login — no password, user selected from list |
LANG_DOMAINS |
"" |
Comma-separated lang:domain pairs, e.g. cs:example.cz,da:example.dk |
Disabling a Provider
Set enabled to false in config/services.php for any provider to hide it from all login/connect buttons:
'google' => [ 'enabled' => false, ... ],
Roles
The package ships with a five-level Role enum. Applications can override User::roles() to return a custom enum.
| Role | Level | Icon |
|---|---|---|
CUSTOMER |
10 | fa-user |
OPERATOR |
20 | fa-user-nurse |
AUDITOR |
30 | fa-user-shield |
MANAGER |
40 | fa-user-tie |
ADMIN |
50 | fa-user-gear |
Each case exposes level(), icon(), and translation() methods.
Dynamic Role Checks
The User model provides magic is{Role}() and is{Role}Plus() methods based on the configured roles enum:
$user->isAdmin(); // true if role === ADMIN $user->isManagerPlus(); // true if role level >= MANAGER level $user->isOperatorPlus(); // true if role level >= OPERATOR level
Role Helpers
User::roles()::cases(); // all Role cases User::publicRolesArray(); // all cases except ADMIN User::roleOptions(); // [['id' => 'manager', 'name' => 'Manager'], ...]
Socialite Providers
Built-in providers: Google and Seznam. Any other Socialite-compatible provider can be added by the application.
The socialite.action route accepts a provider and an action: login, loginAndConnect, register, connect, or disconnect. Use socialite.callback for the OAuth return URL.
Routes
| Route name | URI | Description |
|---|---|---|
login |
GET /login |
Unified login page |
logout |
GET /logout |
Log out |
pin-login.form |
POST /pin-login/send |
Send PIN email |
pin-login.verify |
GET /pin-login/verify |
Show PIN entry form |
pin-login.verify.submit |
POST /pin-login/verify |
Verify PIN — throttled: 5 per 10 minutes |
socialite.action |
GET /socialite/{provider}/{action} |
Redirect to provider |
socialite.callback |
GET /socialite/{provider}/{action}/callback |
Handle provider callback |
users.index |
GET /users |
User list — managers and above |
users.show |
GET /users/{user} |
User detail |
users.update |
POST /users/{user} |
Update name, email, phone, or role |
Usage Examples
{{-- Socialite login/register/connect buttons --}} <x-ig-user::buttons action="login" :showRemember="true" /> <x-ig-user::buttons action="login" :showRemember="false" /> <x-ig-user::buttons action="register" /> <x-ig-user::buttons action="connect" /> {{-- Direct disconnect link --}} <a href="{{ route('socialite.action', [ 'provider' => InternetGuru\LaravelUser\Enums\Provider::GOOGLE, 'action' => InternetGuru\LaravelUser\Enums\ProviderAction::DISCONNECT, ]) }}">Disconnect Google</a>
Demo Mode
Set AUTH_DEMO=true to enable demo login. The login page switches to login-demo view, which lists all non-automatic users sorted by role from highest to lowest for one-click login — no password required. Useful for staging environments.
AUTH_DEMO=true
The list is provided by User::getDemoUsers(), which returns all non-automatic users sorted by role level descending.
PIN Login
PIN login allows users to authenticate with a 6-digit PIN sent to their email address. The PIN is prefixed with IG- in the UI, for example IG-123456.
Flow
- User submits their email on the unified
/loginpage. - The server sends a PIN email and redirects to
/pin-login/verify. - User enters the PIN in the 6-box input; a hidden field assembles the full value.
- On success, the user is logged in and redirected.
Settings
| Setting | Value |
|---|---|
| PIN lifetime | 10 minutes |
| Resend throttle | 1 minute |
| Verify throttle | 5 attempts per 10 minutes |
| PIN format | IG- prefix + 6-digit numeric code |
Send Form Options
- Remember me – persists the session beyond the browser close.
- Create account if not found – when checked, a new account is created for unknown emails.
reCAPTCHA
The PIN send form is protected by reCAPTCHA v3. Ensure laravel-common reCAPTCHA is configured.
Language and Locale
The SetAppLocale middleware, registered automatically in the web group, handles language detection and persistence.
Priority Order
- Explicit
?lang=query parameter. - Authenticated user's
langcolumn. - Session-stored locale.
- Browser
Accept-Languageheader — Slovak falls back to Czech if Czech is configured. app.localeconfig default.
Lang Domains
Map languages to dedicated domains via LANG_DOMAINS:
LANG_DOMAINS=cs:example.cz,da:example.dk
- Requests on a lang domain always enforce that domain's language.
- When a user switches to a language that has a dedicated domain, they are redirected there.
- When a user switches to a language without a dedicated domain while on a lang domain, they are redirected to
app.www.
Language is saved to the authenticated user's lang column on every explicit change.
User Management
The package provides a user list at /users and a user detail page at /users/{user}, built on laravel-model-browser. Access is controlled by UserPolicy.
Users can update their own name, email, phone, and role via POST to /users/{user}. Role changes are subject to the setRole policy.
Automatic Accounts
An account is considered automatic when created_by === id and logged_at IS NULL. These accounts are hidden from User::summary() and getDemoUsers(). When a user registers via PIN login with the "create account" option, reusing an existing automatic account converts it to a regular account.
Blade Components
<x-ig-user::buttons>
Renders socialite provider buttons for a given action.
| Prop | Default | Description |
|---|---|---|
providers |
User::providers()::enabledCases() |
List of enabled providers |
action |
ProviderAction::LOGIN |
Action: login, register, connect |
prev_url |
User::getPreviousUrl() |
URL to redirect to after auth |
showRemember |
false |
Show "Remember me" checkbox |
disabled |
false |
Disable all buttons |
<x-ig-user::user-menu>
Dropdown menu for authenticated users showing name, role icon, link to user detail, and logout. Shows a login link for guests.
<x-ig-user::pin-input>
Alpine.js-powered 6-box PIN input with paste, backspace, and arrow key support.
| Prop | Default | Description |
|---|---|---|
name |
'pin' |
Hidden input field name |
length |
6 |
Number of digit boxes |
prefix |
'IG-' |
Visual prefix label |
User Preferences
The user_preferences table provides a simple key-value store per user.
$user->setPreference('theme', 'dark'); $theme = $user->getPreference('theme', 'light'); // 'dark'
Association History
The User model uses the AssociationHistory trait from laravel-common. Changes to the following fields are tracked automatically:
name, email, phone, role, lang, socialite
The history is displayed on the user detail page, visible to managers and above.
User Policy
| Gate | Description |
|---|---|
crud |
User can edit themselves; admins can edit all; managers can edit users with lower/equal roles |
viewAny |
Managers and above can view the user list |
administrate |
Managers and above |
setRole |
Admins can set any role; managers can set roles up to their own level |
Publish the default policy to customise it:
php artisan vendor:publish --provider="InternetGuru\LaravelUser\LaravelUserServiceProvider" --tag="ig-user:policies"
IgUserSeeder
The package ships with IgUserSeeder for seeding the Internet Guru team accounts with Google/Seznam socialites and ADMIN role. Use it in your DatabaseSeeder:
$this->call(\InternetGuru\LaravelUser\Database\Seeders\IgUserSeeder::class);
Publishing
| Tag | Destination | Description |
|---|---|---|
ig-user:migrations |
database/migrations/ |
Database migrations |
ig-user:translations |
lang/vendor/ig-user/ |
Language files — cs, en, da |
ig-user:views |
resources/views/vendor/ig-user/ |
Blade views |
ig-user:policies |
app/Policies/ |
UserPolicy |
php artisan vendor:publish --provider="InternetGuru\LaravelUser\LaravelUserServiceProvider" --tag="ig-user:translations" php artisan vendor:publish --provider="InternetGuru\LaravelUser\LaravelUserServiceProvider" --tag="ig-user:views"
E2E Tests
The package includes Playwright E2E tests via laravel-common test helpers. Register them in your Playwright config:
import { registerUserTests } from 'path/to/laravel-user/e2e'; registerUserTests(test, { languages: ['en', 'cs'], demo: true });
Options
| Option | Type | Description |
|---|---|---|
languages |
string[] |
Languages to test — login/logout per language |
demo |
boolean |
Include demo login flow tests |
License & Commercial Terms
License
Copyright © 2026 Internet Guru
This software is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0) license.
Disclaimer: This software is provided "as is", without warranty of any kind, express or implied. In no event shall the authors or copyright holders be liable for any claim, damages or other liability.
Commercial Use
The standard CC BY-NC-SA license prohibits commercial use. If you wish to use this software in a commercial environment or product, we offer flexible commercial licenses tailored to:
- Your company size.
- The nature of your project.
- Your specific integration needs.
Note: In many instances, especially for startups or small-scale tools, this may result in no fees being charged at all. Please contact us to obtain written permission or a commercial agreement.
Contact for Licensing: info@internetguru.io
Professional Services
Are you looking to get the most out of this project? We are available for:
- Custom Development: Tailoring the software to your specific requirements.
- Integration & Support: Helping your team implement and maintain the solution.
- Training & Workshops: Seminars and hands-on workshops for your developers.
Reach out to us at info@internetguru.io — we are more than happy to assist you!