Skip to content

Commit baf036a

Browse files
authored
Update readme and config file (#18)
* Update readme and config file * refactor
1 parent 6845985 commit baf036a

File tree

6 files changed

+19
-35
lines changed

6 files changed

+19
-35
lines changed

.github/workflows/phpstan.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,6 @@ on:
55
paths:
66
- '**.php'
77
- 'phpstan.neon.dist'
8-
pull_request:
9-
paths:
10-
- '**.php'
11-
- 'phpstan.neon.dist'
128

139

1410
jobs:

.github/workflows/pint.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@ on:
44
push:
55
paths:
66
- '**.php'
7-
pull_request:
8-
paths:
9-
- '**.php'
107

118
jobs:
129
pint:

README.md

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,9 @@
22

33
![PASSWORDLESS-AUTH](./loginlink.png)
44
# LARAVEL PASSWORDLESS AUTHENTICATION
5-
Laravel Passwordless Authentication with Magic Link.
5+
Laravel Passwordless Authentication using Magic Link.
66

7-
This package allows authentication via email link.
8-
It removes the need for users to provide password to authenticate but rely on user email address to send
9-
them a login link to their inbox to follow to authenticate user securely.
7+
This package enables authentication through email links, eliminating the requirement for users to input passwords for authentication. Instead, it leverages the user's email address to send a login link to their inbox. Users can securely authenticate by clicking on this link. It's important to note that the package does not include a user interface for the authentication page; it assumes that the application's login page will be custom-built. Make sure to scaffold your login UI page accordingly to integrate seamlessly with this package.
108

119
**PS. Email provider must be setup correctly and working to email magic link to authenticate user**
1210

@@ -22,18 +20,18 @@ php artisan vendor:publish --provider="NorbyBaru\Passwordless\PasswordlessServic
2220
```
2321

2422
## Preparing the database
25-
You need to publish the migration to create table:
23+
Publish the migration to create required table:
2624
```sh
2725
php artisan vendor:publish --provider="NorbyBaru\Passwordless\PasswordlessServiceProvider" --tag="passwordless-migrations"
2826
```
29-
After that, you need to run migrations.
27+
Run migrations.
3028
```sh
3129
php artisan migrate
3230
```
3331

3432
# Basic Usage
3533
## Preparing Model
36-
Open the `User::class` Model and make sure to implements `NorbyBaru\Passwordless\CanUsePasswordlessAuthenticatable::class` and add trait `NorbyBaru\Passwordless\Traits\PasswordlessAuthenticatable::class` to the class
34+
Open the `User::class` Model and ensure to implements `NorbyBaru\Passwordless\CanUsePasswordlessAuthenticatable::class` and to add trait `NorbyBaru\Passwordless\Traits\PasswordlessAuthenticatable::class` to the class
3735

3836
```php
3937
<?php
@@ -71,7 +69,7 @@ eg.
7169
```
7270

7371
## Setup Login Routes
74-
Make sure to setup new login routes and update your application to use the new login route
72+
Update application Login routes to sen Magic Link to user
7573

7674
```php
7775
<?php
@@ -119,11 +117,20 @@ return [
119117
];
120118
```
121119

122-
## Setup Auth Provider
123-
124120
# Advance Usage
125121
## Override MagicLinkNotification
126122

123+
To override default notification template, override method `sendAuthenticationMagicLink` in your User model which implements interface `CanUsePasswordlessAuthenticatable`
124+
125+
```php
126+
public function sendAuthenticationMagicLink(string $token): void
127+
{
128+
// Replace with your notification class.
129+
130+
// eg. $this->notify(new SendMagicLinkNotification($token));
131+
}
132+
```
133+
127134
## Run Unit Test
128135
```sh
129136
composer test

config/passwordless.php

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,6 @@
3535
*/
3636
'login_route' => 'login',
3737

38-
/*
39-
|--------------------------------------------------------------------------
40-
| Auth Provider
41-
|--------------------------------------------------------------------------
42-
|
43-
|
44-
|
45-
*/
46-
'provider' => 'users',
47-
4838
/*
4939
|--------------------------------------------------------------------------
5040
| Table Name

database/migrations/create_passwordless_auth_table.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
*/
1414
public function up()
1515
{
16-
Schema::create('passwordless_auth', function (Blueprint $table) {
16+
Schema::create(config('passwordless.table'), function (Blueprint $table) {
1717
$table->id();
1818
$table->string('email')->index();
1919
$table->string('token')->unique();

src/MagicLink.php

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,8 @@ class MagicLink
4747
*/
4848
const MAGIC_LINK_VERIFIED = 'passwordless.verified';
4949

50-
protected TokenInterface $token;
51-
52-
protected UserProvider $user;
53-
54-
public function __construct(TokenInterface $tokenInterface, UserProvider $user)
50+
public function __construct(protected TokenInterface $token, protected UserProvider $user)
5551
{
56-
$this->token = $tokenInterface;
57-
$this->user = $user;
5852
}
5953

6054
public function generateUrl(CanUsePasswordlessAuthenticatable $notifiable, string $token): string

0 commit comments

Comments
 (0)