Skip to content

Commit af6fbe4

Browse files
authored
21 make create account optional (#22)
1 parent 562ed6a commit af6fbe4

File tree

3 files changed

+31
-3
lines changed

3 files changed

+31
-3
lines changed

README.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ return [
128128
*/
129129

130130
'models' => [
131-
'authenticatable' => env('AUTH_MODEL', App\Models\User::class),
131+
'authenticatable' => App\Models\User::class,
132132
],
133133

134134
/*
@@ -157,6 +157,19 @@ return [
157157

158158
'template' => 'otpz::mail.otpz',
159159
// 'template' => 'otpz::mail.notification',
160+
161+
/*
162+
|--------------------------------------------------------------------------
163+
| User Resolver
164+
|--------------------------------------------------------------------------
165+
|
166+
| Defines the class responsible for finding or creating users by email address.
167+
| The default implementation will create a new user when an email doesn't exist.
168+
| Replace with your own implementation for custom user resolution logic.
169+
|
170+
*/
171+
172+
'user_resolver' => BenBjurstrom\Otpz\Actions\GetUserFromEmail::class,
160173
];
161174
```
162175

config/otpz.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
*/
3232

3333
'models' => [
34-
'authenticatable' => env('AUTH_MODEL', App\Models\User::class),
34+
'authenticatable' => App\Models\User::class,
3535
],
3636

3737
/*
@@ -60,4 +60,17 @@
6060

6161
'template' => 'otpz::mail.otpz',
6262
// 'template' => 'otpz::mail.notification',
63+
64+
/*
65+
|--------------------------------------------------------------------------
66+
| User Resolver
67+
|--------------------------------------------------------------------------
68+
|
69+
| Defines the class responsible for finding or creating users by email address.
70+
| The default implementation will create a new user when an email doesn't exist.
71+
| Replace with your own implementation for custom user resolution logic.
72+
|
73+
*/
74+
75+
'user_resolver' => BenBjurstrom\Otpz\Actions\GetUserFromEmail::class,
6376
];

src/Actions/SendOtp.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ class SendOtp
1717
public function handle(string $email, bool $remember = false): Otp
1818
{
1919
$mailable = config('otpz.mailable', OtpzMail::class);
20-
$user = (new GetUserFromEmail)->handle($email);
20+
$userResolver = config('otpz.user_resolver', GetUserFromEmail::class);
21+
22+
$user = (new $userResolver)->handle($email);
2123
[$otp, $code] = (new CreateOtp)->handle($user, $remember);
2224

2325
Mail::to($user)->send(new $mailable($otp, $code));

0 commit comments

Comments
 (0)