Laravel-admin: Users can not reset their own password

Created on 12 Feb 2017  ·  4Comments  ·  Source: z-song/laravel-admin

How can I configure laravel-admin to use the users table that brings the default scafolding of laravel make:auth and so that each user can reset their own password and login to the system using the email and password.

Most helpful comment

Actually, it turned out to be surprisingly easy to get make:auth compatibility. The biggest problem is that username field is not configurable in laravel-admin, otherwise it would've been a few lines of code

Anyway, here's how to make laravel-admin make:auth compatible (with password reset and all).

1) copy vendor/encore/laravel-admin/views/login.blade.php to resources/views/admin/login.blade.php
2) replace username with email everywhere in that file
3) in config/admin.php replace admin_users with users
4) in config/auth.php replace 'guard' => 'web', with 'guard' => 'admin',
5) copy cp vendor/encore/laravel-admin/src/Controllers/AuthController.php to app/Admin/Controllers/AuthController.php
6) replace username with email
7) replace namespace Encore\Admin\Controllers; to namespace App\Admin\Controllers;
8) replace admin::login with admin.login (not sure why it's not picking up cusom view)
9) add to app/Admin/routes.php:

    $router->get('/auth/login', '\\App\\Admin\\Controllers\\AuthController@getLogin');
    $router->post('/auth/login', '\\App\\Admin\\Controllers\\AuthController@postLogin');
    $router->get('auth/setting', '\\App\\Admin\\Controllers\\AuthController@getSetting');
    $router->put('auth/setting', '\\App\\Admin\\Controllers\\AuthController@putSetting');

If laravel-admin were to replace 'username' with something like config('admin.username_field') - that would've been much easier! (only config changes)

All 4 comments

I made a change in the question that had been written in the wrong way

Custom passport is not support currently, I'll woking for this.

I'd love to see php artisan make:auth compatibility.

Actually, it turned out to be surprisingly easy to get make:auth compatibility. The biggest problem is that username field is not configurable in laravel-admin, otherwise it would've been a few lines of code

Anyway, here's how to make laravel-admin make:auth compatible (with password reset and all).

1) copy vendor/encore/laravel-admin/views/login.blade.php to resources/views/admin/login.blade.php
2) replace username with email everywhere in that file
3) in config/admin.php replace admin_users with users
4) in config/auth.php replace 'guard' => 'web', with 'guard' => 'admin',
5) copy cp vendor/encore/laravel-admin/src/Controllers/AuthController.php to app/Admin/Controllers/AuthController.php
6) replace username with email
7) replace namespace Encore\Admin\Controllers; to namespace App\Admin\Controllers;
8) replace admin::login with admin.login (not sure why it's not picking up cusom view)
9) add to app/Admin/routes.php:

    $router->get('/auth/login', '\\App\\Admin\\Controllers\\AuthController@getLogin');
    $router->post('/auth/login', '\\App\\Admin\\Controllers\\AuthController@postLogin');
    $router->get('auth/setting', '\\App\\Admin\\Controllers\\AuthController@getSetting');
    $router->put('auth/setting', '\\App\\Admin\\Controllers\\AuthController@putSetting');

If laravel-admin were to replace 'username' with something like config('admin.username_field') - that would've been much easier! (only config changes)

Was this page helpful?
0 / 5 - 0 ratings