jooservices/laravel-identity

Backend identity lifecycle for Laravel: session authentication, registration, activation, and password reset. No UI.

Maintainers

Package info

github.com/jooservices/laravel-identity

pkg:composer/jooservices/laravel-identity

Transparency log

Statistics

Installs: 1

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v1.0.0 2026-07-21 02:42 UTC

This package is auto-updated.

Last update: 2026-07-21 02:45:57 UTC


README

PHP Version License: MIT

Backend identity lifecycle for Laravel applications: session login/logout, registration, activation, password reset, and profile updates.

Package name: jooservices/laravel-identity

No UI. Controllers, Inertia/Blade pages, and SPA assets stay in the host app. Different products may present identity flows differently; this package only provides services, contracts, events, and Artisan commands.

Principles

  • SOLID, DRY, KISS, YAGNI
  • Patterns only when justified (Service Layer, Repository, DTO, events)
  • Laravel flow: Controller → FormRequest → Service → Repository → Model
  • Jobs/Commands orchestrate through Services
  • Events dispatch from Services after successful persistence

Install

composer require jooservices/laravel-identity

Publish config (optional):

php artisan vendor:publish --tag=laravel-identity-config

Optional starter migrations (skip if the host already has users / password_reset_tokens):

php artisan vendor:publish --tag=laravel-identity-migrations

Host setup

  1. Point laravel-identity.user_model at your Authenticatable model.
  2. Prefer implementing IdentityUser (or use HasIdentityActivation) for is_active.
  3. Optionally bind a custom PasswordPolicyInterface (default is a no-op).
  4. Optionally replace repository bindings.
// config/laravel-identity.php (or env)
'user_model' => App\Models\User::class,
'require_activation' => true,
use Jooservices\LaravelIdentity\Concerns\HasIdentityActivation;
use Jooservices\LaravelIdentity\Contracts\IdentityUser;

class User extends Authenticatable implements IdentityUser
{
    use HasIdentityActivation;
    // ...
}

Usage (host controller / command)

use Jooservices\LaravelIdentity\Dto\LoginDto;
use Jooservices\LaravelIdentity\Services\AuthenticationService;

public function store(LoginRequest $request, AuthenticationService $auth): RedirectResponse
{
    $auth->login(
        new LoginDto(
            email: $request->email(),
            password: $request->password(),
            remember: $request->boolean('remember'),
            ip: (string) $request->ip(),
        ),
        $request,
    );

    return redirect()->intended('/dashboard');
}
use Jooservices\LaravelIdentity\Dto\RegisterUserDto;
use Jooservices\LaravelIdentity\Services\UserLifecycleService;

$users->register(new RegisterUserDto($name, $email, $password, $ip));
$users->activateUser($email);
$users->requestPasswordReset(new RequestPasswordResetDto($email, $ip));

Artisan

php artisan identity:activate-user user@example.com
php artisan identity:reset-password user@example.com --password=secret

Host apps may keep product-prefixed wrappers (e.g. xflickr:auth:*) that call the same services.

Events

Event When
UserRegistered After register
UserActivated After activate (when previously inactive)
PasswordResetRequested After reset token created (email, plainToken, resetUrl) — host may send email; do not log the token
PasswordChanged After password update

What is out of scope

  • UI / Inertia / Blade / React
  • RBAC / policies / teams
  • Social OAuth
  • Forced email delivery (listen to PasswordResetRequested instead)

Quality

composer test
composer lint
composer check

Standards

Aligned with JOOservices dto package architecture guidance and Laravel best practices (thin controllers, FormRequest validation, service-owned business logic, repository persistence).