-
Notifications
You must be signed in to change notification settings - Fork 0
/
laravel-login-with-email-or-phone-or-name
87 lines (70 loc) · 1.87 KB
/
laravel-login-with-email-or-phone-or-name
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
Step 1
App\Providers\JetstreamServiceProvider class:
<?php
namespace App\Providers;
use App\Models\User;
use Illuminate\Http\Request;
use Laravel\Fortify\Fortify;
use Laravel\Jetstream\Jetstream;
use Illuminate\Support\Facades\Hash;
use App\Actions\Jetstream\DeleteUser;
use Illuminate\Support\ServiceProvider;
class JetstreamServiceProvider extends ServiceProvider
{
/**
* Register any application services.
*
* @return void
*/
public function register()
{
//
}
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
$this->configurePermissions();
Jetstream::deleteUsersUsing(DeleteUser::class);
Fortify::authenticateUsing(function (Request $request) {
$user = User::where('email', $request->login)
->orWhere('name', $request->login)
->orWhere('phone_no', $request->login)
->first();
if (
$user &&
Hash::check($request->password, $user->password)
) {
return $user;
}
});
}
/**
* Configure the permissions that are available within the application.
*
* @return void
*/
protected function configurePermissions()
{
Jetstream::defaultApiTokenPermissions(['read']);
Jetstream::permissions([
'create',
'read',
'update',
'delete',
]);
}
}
Step 2
config/fortify.php
'username' => 'login',
Step 3
resources/views/auth/login.blade.php
<div>
<x-jet-label for="login" value="{{ __('Email / Name / Phone no') }}" />
<x-jet-input id="login" class="block mt-1 w-full" type="text" name="login" :value="old('login')" required
autofocus />
</div>