tastyigniter/ti-ext-user
Core TastyIgniter extension for user management: administer customers and staff, authentication and registration (optional email verification), password resets, and admin impersonation. Includes automation events for customer registration and attribute conditions.
Installation:
composer require tastyigniter/ti-ext-user
php artisan igniter:up
Run migrations to set up the required tables (users, customers, user_roles, etc.).
Publish Config:
php artisan vendor:publish --provider="TastyIgniter\TiExtUser\Providers\TiExtUserServiceProvider"
Configure email settings, registration defaults, and permissions in config/ti-ext-user.php.
First Use Case:
@include('ti-ext-user::auth.register')
/login, /register) or integrate with your frontend:
use TastyIgniter\TiExtUser\Facades\Auth;
if (Auth::check()) {
// User is logged in
}
Admin Access:
/admin) and navigate to Users > Customers or Users > Staff to manage users via the built-in UI.Impersonation (Admin Feature):
use TastyIgniter\TiExtUser\Facades\Auth;
$customer = \App\Models\Customer::find(1);
Auth::impersonate($customer);
/resources/views/vendor/ti-ext-user/ for reusable frontend templates./src/Events/ for extending user lifecycle hooks (e.g., UserRegistered, UserLoggedIn)./src/Http/Middleware/ for custom auth logic (e.g., AdminAuth, CustomerAuth).@auth
<p>Welcome, {{ Auth::user()->name }}!</p>
@else
@include('ti-ext-user::auth.login')
@endauth
CustomerRequest or UserRequest:
namespace App\Http\Requests;
use TastyIgniter\TiExtUser\Http\Requests\CustomerRequest as BaseCustomerRequest;
class CustomerRequest extends BaseCustomerRequest
{
public function rules()
{
return array_merge(parent::rules(), [
'custom_field' => 'required|string',
]);
}
}
use TastyIgniter\TiExtUser\Models\Customer;
$customer = Customer::create([
'email' => 'customer@example.com',
'password' => bcrypt('password123'),
'first_name' => 'John',
'last_name' => 'Doe',
'status' => true, // Active/inactive
]);
$customer->assignRole('customer'); // Predefined roles: 'customer', 'staff', 'admin'
use TastyIgniter\TiExtUser\Facades\Auth;
$user = \App\Models\User::find(1);
Auth::impersonate($user);
Auth::endImpersonation();
use TastyIgniter\TiExtUser\Events\UserRegistered;
UserRegistered::listen(function (UserRegistered $event) {
// Send welcome email or trigger automation
\Log::info("New user registered: {$event->user->email}");
});
can() method for authorization:
if (Auth::user()->can('manage_orders')) {
// Grant access
}
use TastyIgniter\TiExtUser\Models\Customer;
$customer = Customer::where('email', $request->email)->first();
if ($customer && Hash::check($request->password, $customer->password)) {
$token = $customer->createToken('auth_token')->plainTextToken;
return response()->json(['token' => $token]);
}
/register).UserRegistered event fires → trigger welcome email/SMS./admin/users/customers (if email verification is enabled)./admin/users/staff./staff/orders).Auth::impersonate($staffUser);
// Debug staff session
Auth::endImpersonation();
/forgot-password.PasswordReset event fires → send reset link./reset-password).Customize Emails:
Override default mail templates in /resources/views/vendor/ti-ext-user/emails/.
Example: Copy resources/views/vendor/ti-ext-user/emails/welcome.blade.php to your project’s resources/views/ti-ext-user/emails/ and modify.
Extend Models:
Add fields to the users or customers table via migrations, then extend the models:
namespace App\Models;
use TastyIgniter\TiExtUser\Models\Customer as BaseCustomer;
class Customer extends BaseCustomer
{
protected $casts = array_merge(BaseCustomer::$casts, [
'loyalty_points' => 'integer',
]);
}
Override Auth Logic:
Publish and modify the AuthServiceProvider:
php artisan vendor:publish --tag=ti-ext-user-auth
Then extend the boot() method in app/Providers/AuthServiceProvider.php.
Localization: The package supports localization. Publish translations:
php artisan vendor:publish --tag=ti-ext-user-lang
Then add your language files to resources/lang/.
Migration Conflicts:
php artisan igniter:up after custom migrations may cause conflicts. Backup your database or use --force cautiously./database/migrations/) before running them.Impersonation Session Issues:
Auth::logoutOtherDevices($request->password);
Auth::impersonate($user);
Auth::onceUsingId($user->id) for one-time impersonation.Email Verification Edge Cases:
failed_jobs table or enable debug logging:
\Illuminate\Support\Facades\Log::channel('single')->debug('Email verification failed');
.env has correct mail settings (MAIL_MAILER=smtp, MAIL_FROM_ADDRESS).Role/Permission Caching:
php artisan cache:clear
Auth::user()->refreshPermissions() in your code if needed.Password Reset Token Expiry:
config/ti-ext-user.php:
'password_reset' => [
'expire' => 60, // minutes
],
Concurrent Impersonation:
Auth::onceUsingId() for temporary impersonation:
Auth::onceUsingId($user->id, function () {
// Perform actions as the user
});
AppServiceProvider to debug:
public function boot()
{
\T
How can I help you explore Laravel packages today?