You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
'type' => 'profile' // Sort key. If we don't specify this, sortKeyDefault will be used.
231
231
]);
232
232
@@ -268,7 +268,7 @@ Please refer to [Query Builder](#query-builder) for the details.
268
268
269
269
## Authentication with model
270
270
271
-
We can create a Custom User Provider to authenticate with DynamoDB. For the detail, please refer to [Laravel's official document](https://laravel.com/docs/6.x/authentication#adding-custom-user-providers).
271
+
We can create a Custom User Provider to authenticate with DynamoDB. For the detail, please refer to [Laravel's official document](https://laravel.com/docs/8.x/authentication#adding-custom-user-providers).
272
272
273
273
To use authentication with the model, the model should implement `Illuminate\Contracts\Auth\Authenticatable` contract. In this section, we'll use the example `User` model above.
274
274
@@ -296,29 +296,6 @@ public function boot()
296
296
}
297
297
```
298
298
299
-
### Modify LoginController
300
-
301
-
The default authentication uses the `email` and `password` column to validate, which is not the primary key of the table. However, DynamoDB needs to use the primary key to identify, so we need to tweak the LoginController a bit.
302
-
303
-
```php
304
-
namespace App\Http\Controllers\Auth;
305
-
306
-
class LoginController extends Controller
307
-
{
308
-
...
309
-
310
-
/**
311
-
* Get the login username to be used by the controller.
312
-
*
313
-
* @return string
314
-
*/
315
-
public function username()
316
-
{
317
-
return 'your-primary-key';
318
-
}
319
-
}
320
-
```
321
-
322
299
### Change auth config
323
300
324
301
Then specify driver and model name for authentication in `config/auth.php`.
@@ -343,6 +320,45 @@ Then specify driver and model name for authentication in `config/auth.php`.
343
320
344
321
`api_token_name` and `api_token_index` are optional, but we need them if we use api token authentication.
345
322
323
+
### Registration Controller
324
+
325
+
You might need to modify the registration controller. For example, if we use Laravel Breeze, the modification looks like below.
$fail('The '.$attribute.' has already been taken.');
339
+
}
340
+
}],
341
+
'password' => 'required|string|confirmed|min:8',
342
+
]);
343
+
344
+
$user = new User([
345
+
'name' => $request->name,
346
+
'email' => $request->email,
347
+
'password' => Hash::make($request->password),
348
+
]);
349
+
$user->save();
350
+
351
+
Auth::login($user);
352
+
353
+
event(new Registered($user));
354
+
355
+
return redirect(RouteServiceProvider::HOME);
356
+
}
357
+
}
358
+
```
359
+
360
+
There are two modifications. The first one is adding the closure validator for `email` instead of `unique` validator. The second one is using the `save()` method to create user instead of the `create()` method.
0 commit comments