Skip to content

Commit 1f2b263

Browse files
committed
Renamed package from PIN to TOTP
1 parent fe9350a commit 1f2b263

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+619
-613
lines changed

.github/ISSUE_TEMPLATE/config.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
blank_issues_enabled: false
22
contact_links:
33
- name: Ask a question
4-
url: https://github.com/empuxa/laravel-pin-login/discussions/new?category=q-a
4+
url: https://github.com/empuxa/laravel-totp-login/discussions/new?category=q-a
55
about: Ask the community for help
66
- name: Request a feature
7-
url: https://github.com/empuxa/laravel-pin-login/discussions/new?category=ideas
7+
url: https://github.com/empuxa/laravel-totp-login/discussions/new?category=ideas
88
about: Share ideas for new features
99
- name: Report a security issue
10-
url: https://github.com/empuxa/laravel-pin-login/security/policy
10+
url: https://github.com/empuxa/laravel-totp-login/security/policy
1111
about: Learn how to notify us for sensitive bugs

README.md

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,22 @@
1-
# Laravel PIN Login
1+
# Laravel TOTP Login
22

3-
[![Latest Version on Packagist](https://img.shields.io/packagist/v/empuxa/laravel-pin-login.svg?style=flat-square)](https://packagist.org/packages/empuxa/laravel-pin-login)
4-
[![Tests](https://img.shields.io/github/actions/workflow/status/empuxa/laravel-pin-login/run-tests.yml?branch=main&label=tests&style=flat-square)](https://github.com/empuxa/laravel-pin-login/actions/workflows/run-tests.yml)
5-
[![Total Downloads](https://img.shields.io/packagist/dt/empuxa/laravel-pin-login.svg?style=flat-square)](https://packagist.org/packages/empuxa/laravel-pin-login)
3+
[![Latest Version on Packagist](https://img.shields.io/packagist/v/empuxa/laravel-totp-login.svg?style=flat-square)](https://packagist.org/packages/empuxa/laravel-totp-login)
4+
[![Tests](https://img.shields.io/github/actions/workflow/status/empuxa/laravel-totp-login/run-tests.yml?branch=main&label=tests&style=flat-square)](https://github.com/empuxa/laravel-totp-login/actions/workflows/run-tests.yml)
5+
[![Total Downloads](https://img.shields.io/packagist/dt/empuxa/laravel-totp-login.svg?style=flat-square)](https://packagist.org/packages/empuxa/laravel-totp-login)
66

7-
![Banner](https://banners.beyondco.de/Laravel%20PIN%20Login.png?theme=light&packageManager=composer+require&packageName=empuxa%2Fpin-login&pattern=architect&style=style_1&description=Goodbye+passwords%21&md=1&showWatermark=0&fontSize=100px&images=https%3A%2F%2Flaravel.com%2Fimg%2Flogomark.min.svg)
7+
![Banner](https://banners.beyondco.de/Laravel%20TOTP%20Login.png?theme=light&packageManager=composer+require&packageName=empuxa%2Ftotp-login&pattern=architect&style=style_1&description=Goodbye+passwords%21&md=1&showWatermark=0&fontSize=100px&images=https%3A%2F%2Flaravel.com%2Fimg%2Flogomark.min.svg)
88

9-
Say goodbye to passwords and sign in via PIN instead!
10-
Laravel PIN Login is a convenient package that allows you to easily add a PIN login feature to your Laravel application.
9+
Say goodbye to passwords and sign in via a time-based one-time password instead!
10+
Laravel TOTP Login is a convenient package that allows you to easily add a TOTP login feature to your Laravel application.
1111

12-
## Why Choose Laravel PIN Login?
13-
You might wonder why you should opt for a PIN login instead of a magic link solution. Well, this package is designed to complement the existing login methods in your application. It provides an alternative sign-in option for users who haven't set a password yet or don't have an email address. For instance, users who signed up with only a phone number can still enjoy the benefits of secure login through a PIN.
12+
## Why Choose Laravel TOTP Login?
13+
You might wonder why you should opt for a TOTP login instead of a magic link solution.
14+
Well, this package is designed to complement the existing login methods in your application.
15+
It provides an alternative sign-in option for users who haven't set a password yet or don't have an email address.
16+
For instance, users who signed up with only a phone number can still enjoy the benefits of secure login through a TOTP.
1417

1518
## Features
16-
- Simplified sign-in process using a PIN
19+
- Simplified sign-in process using a TOTP
1720
- Compatibility with existing login methods
1821
- Support for users without passwords or email addresses
1922

@@ -31,13 +34,13 @@ Also, you need to have a notifiable user model.
3134
Install the package via composer:
3235

3336
```bash
34-
composer require empuxa/laravel-pin-login
37+
composer require empuxa/laravel-totp-login
3538
```
3639

37-
Copy the vendor files and adjust the config file `config/pin-login.php` to your needs:
40+
Copy the vendor files and adjust the config file `config/totp-login.php` to your needs:
3841

3942
```bash
40-
php artisan vendor:publish --provider="Empuxa\PinLogin\PinLoginServiceProvider"
43+
php artisan vendor:publish --provider="Empuxa\TotpLogin\TotpLoginServiceProvider"
4144
```
4245

4346
Run the migrations:
@@ -47,37 +50,38 @@ php artisan migrate
4750
```
4851

4952
That's it!
50-
You're ready to start using the PIN login feature in your Laravel application.
53+
You're ready to start using the TOTP login feature in your Laravel application.
5154

5255
## Usage
5356

5457
The sign-in process for this repository involves three steps:
55-
1. Enter the user's email address, phone number, or any other specified identifier, and request a PIN.
56-
2. If the entered information is valid, a PIN will be sent to the user. You may need to customize the notification channel based on the user model you are using.
57-
3. Enter the received PIN to log in the user.
58+
1. Enter the user's email address, phone number, or any other specified identifier, and request a TOTP.
59+
2. If the entered information is valid, a TOTP will be sent to the user. You may need to customize the notification channel based on the user model you are using.
60+
3. Enter the received TOTP to log in the user.
5861

5962
### Customizing the Views
6063

6164
While the initial steps are relatively straightforward, it's now necessary to customize the views.
62-
These views have been designed to be as simple as possible (some might even consider them "ugly") and can be located in the `resources/views/vendor/pin-login` directory.
65+
These views have been designed to be as simple as possible (some might even consider them "ugly") and can be located in the `resources/views/vendor/totp-login` directory.
6366

6467
*Why are they not visually appealing?*
6568
Different applications adopt various layouts and frameworks.
6669
Since you have the most knowledge about your application, you can change the views to suit your specific requirements.
6770

6871
### Modifying the Notification
69-
Within the copied views, you will come across a notification that's sent to the user.
72+
Within the copied views, you will come across a notification sent to the user.
7073
You may want to make adjustments to this notification to align it with your preferences and needs.
7174

7275
#### Different Notification Channels
73-
If you plan on utilizing SMS or similar as your preferred notification channel, you have the option to create a custom notification class.
74-
The PIN and the user's IP address will be passed to the constructor of this class. Finally, replace the default notification class within the `config/pin-login.php` file with your custom notification.
76+
If you plan on using SMS or similar as your preferred notification channel, you can create a custom notification class.
77+
The TOTP and the user's IP address will be passed to the constructor of this class.
78+
Finally, replace the default notification class within the `config/totp-login.php` file with your custom notification.
7579

7680
### Custom User Model Scope
7781
To apply a scope to your user model, add the following method to your model:
7882

7983
```php
80-
public static function pinLoginScope(): Builder
84+
public static function totpLoginScope(): Builder
8185
{
8286
return self::yourGlobalScope();
8387
}

composer.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
{
2-
"name": "empuxa/laravel-pin-login",
2+
"name": "empuxa/laravel-totp-login",
33
"description": "Say goodbye to passwords and sign in via PIN instead.",
44
"keywords": [
55
"empuxa",
6-
"pin-login",
6+
"totp-login",
77
"passwordless"
88
],
9-
"homepage": "https://github.com/empuxa/laravel-pin-login",
9+
"homepage": "https://github.com/empuxa/laravel-totp-login",
1010
"license": "MIT",
1111
"authors": [
1212
{
@@ -33,12 +33,12 @@
3333
},
3434
"autoload": {
3535
"psr-4": {
36-
"Empuxa\\PinLogin\\": "src"
36+
"Empuxa\\TotpLogin\\": "src"
3737
}
3838
},
3939
"autoload-dev": {
4040
"psr-4": {
41-
"Empuxa\\PinLogin\\Tests\\": "tests"
41+
"Empuxa\\TotpLogin\\Tests\\": "tests"
4242
}
4343
},
4444
"scripts": {
@@ -55,7 +55,7 @@
5555
"extra": {
5656
"laravel": {
5757
"providers": [
58-
"Empuxa\\PinLogin\\PinLoginServiceProvider"
58+
"Empuxa\\TotpLogin\\TotpLoginServiceProvider"
5959
]
6060
}
6161
},

config/pin-login.php renamed to config/totp-login.php

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,29 +9,29 @@
99

1010
/**
1111
* The notification to send to the user.
12-
* Default: \Empuxa\PinLogin\Notifications\LoginPin::class
12+
* Default: \Empuxa\TotpLogin\Notifications\LoginCode::class
1313
*/
14-
'notification' => \Empuxa\PinLogin\Notifications\LoginPin::class,
14+
'notification' => \Empuxa\TotpLogin\Notifications\LoginCode::class,
1515

1616
'columns' => [
1717
/**
1818
* The main identifier of the user model.
1919
* We will use this column to authenticate the user and to send the PIN to.
2020
* Default: 'email'
2121
*/
22-
'identifier' => 'email',
22+
'identifier' => 'email',
2323

2424
/**
2525
* The column where the PIN is stored.
26-
* Default: 'login_pin'
26+
* Default: 'login_totp_code'
2727
*/
28-
'pin' => 'login_pin',
28+
'code' => 'login_totp_code',
2929

3030
/**
3131
* The column where we store the information, how long the PIN is valid.
32-
* Default: 'login_pin_valid_until'
32+
* Default: 'login_totp_code_valid_until'
3333
*/
34-
'pin_valid_until' => 'login_pin_valid_until',
34+
'code_valid_until' => 'login_totp_code_valid_until',
3535
],
3636

3737
'route' => [
@@ -71,7 +71,7 @@
7171
'enable_throttling' => true,
7272
],
7373

74-
'pin' => [
74+
'code' => [
7575
/**
7676
* The length of the PIN.
7777
* Keep in mind that longer PINs might break the layout.
@@ -81,7 +81,7 @@
8181

8282
/**
8383
* The time in seconds after which the PIN expires.
84-
* This is the information being stored in the `login_pin_valid_until` column.
84+
* This is the information being stored in the `login_totp_code_valid_until` column.
8585
* Default: 600
8686
*/
8787
'expires_in' => 600,
@@ -111,10 +111,10 @@
111111
/**
112112
* Enable the "superpin" feature.
113113
* When enabled, any user can also sign in with the PIN of your choice on non-production environments.
114-
* Set the environment variable `PIN_LOGIN_SUPERPIN` to the PIN you want to use.
115-
* Default: env('PIN_LOGIN_SUPERPIN', false)
114+
* Set the environment variable `TOTP_LOGIN_SUPERPIN` to the PIN you want to use.
115+
* Default: env('TOTP_LOGIN_SUPERPIN', false)
116116
*/
117-
'superpin' => env('PIN_LOGIN_SUPERPIN', false),
117+
'superpin' => env('TOTP_LOGIN_SUPERPIN', false),
118118

119119
/**
120120
* The redirect path after a successful login.
@@ -124,21 +124,21 @@
124124

125125
'events' => [
126126
/**
127-
* This event is fired when a user submits a PIN.
128-
* Default: \Empuxa\PinLogin\Events\PinRequested::class
127+
* This event is fired when a user submits a TOTP.
128+
* Default: \Empuxa\TotpLogin\Events\PinRequested::class
129129
*/
130-
'login_request_via_pin' => \Empuxa\PinLogin\Events\LoginRequestViaPin::class,
130+
'login_request_via_totp' => \Empuxa\TotpLogin\Events\LoginRequestViaTotp::class,
131131

132132
/**
133133
* This event is fired when a user was successfully logged in.
134-
* Default: \Empuxa\PinLogin\Events\LoggedInViaPin::class
134+
* Default: \Empuxa\TotpLogin\Events\LoggedInViaTotp::class
135135
*/
136-
'logged_in_via_pin' => \Empuxa\PinLogin\Events\LoggedInViaPin::class,
136+
'logged_in_via_totp' => \Empuxa\TotpLogin\Events\LoggedInViaTotp::class,
137137

138138
/**
139139
* This event is fired when a user was successfully logged in.
140140
* Default: \Illuminate\Auth\Events\Lockout::class
141141
*/
142-
'lockout' => \Illuminate\Auth\Events\Lockout::class,
142+
'lockout' => \Illuminate\Auth\Events\Lockout::class,
143143
],
144144
];

database/migrations/2023_06_23_150000_add_pin_columns_to_users_table.php

Lines changed: 0 additions & 26 deletions
This file was deleted.
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
3+
use Illuminate\Database\Migrations\Migration;
4+
use Illuminate\Database\Schema\Blueprint;
5+
use Illuminate\Support\Facades\Schema;
6+
7+
return new class extends Migration
8+
{
9+
public function up(): void
10+
{
11+
Schema::table(app(config('totp-login.model'))->getTable(), static function (Blueprint $table): void {
12+
$table->string(config('totp-login.columns.code'))->nullable();
13+
$table->timestamp(config('totp-login.columns.code_valid_until'))->nullable();
14+
});
15+
}
16+
17+
public function down(): void
18+
{
19+
Schema::table(app(config('totp-login.model'))->getTable(), static function (Blueprint $table): void {
20+
$table->dropColumn([
21+
config('totp-login.columns.code'),
22+
config('totp-login.columns.code_valid_until'),
23+
]);
24+
});
25+
}
26+
};

database/migrations/add_pin_columns_to_users_table.php.stub

Lines changed: 0 additions & 26 deletions
This file was deleted.
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
3+
use Illuminate\Database\Migrations\Migration;
4+
use Illuminate\Database\Schema\Blueprint;
5+
use Illuminate\Support\Facades\Schema;
6+
7+
return new class extends Migration
8+
{
9+
public function up(): void
10+
{
11+
Schema::table(app(config('totp-login.model'))->getTable(), static function (Blueprint $table): void {
12+
$table->string(config('totp-login.columns.code'))->nullable();
13+
$table->timestamp(config('totp-login.columns.code_valid_until'))->nullable();
14+
});
15+
}
16+
17+
public function down(): void
18+
{
19+
Schema::table(app(config('totp-login.model'))->getTable(), static function (Blueprint $table): void {
20+
$table->dropColumn([
21+
config('totp-login.columns.code'),
22+
config('totp-login.columns.code_valid_until'),
23+
]);
24+
});
25+
}
26+
};

resources/lang/de/controller.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
<?php
22

33
return [
4-
'handle_pin_request' => [
4+
'handle_code_request' => [
55
'success' => 'Login erfolgreich.',
66
'error' => [
77
'rate_limit' => 'Zu viele falsche Anfragen. Ihre Account wurde für :seconds Sekunden geblockt.',
8-
'expired' => 'Der eingegebene PIN ist nicht mehr gültig. Wir haben Ihnen einen neuen PIN per E-Mail geschickt.',
9-
'wrong_pin' => 'Der PIN ist ungültig. Sie haben noch :attempts_left Versuche bis wir Ihren Account temporär blockieren.',
8+
'expired' => 'Der eingegebene Code ist nicht mehr gültig. Wir haben Ihnen einen neuen Code per E-Mail geschickt.',
9+
'wrong_totp' => 'Der Code ist ungültig. Sie haben noch :attempts_left Versuche bis wir Ihren Account temporär blockieren.',
1010
],
1111
],
1212
];

resources/lang/de/notification.php

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

33
return [
44
'mail' => [
5-
'subject' => 'Your login PIN for :app',
6-
'greeting' => 'Hello :name,',
7-
'line-1' => 'There was a login request from :ip. Here is your PIN, which is valid until :valid_until:',
8-
'line-2' => "If it wasn't you: no reason to panic. You can find more information about our login process here: https://google.com",
9-
'line-3' => "Thank you for using our services. If you have any questions, please contact us. We're happy to help!",
10-
'cta' => 'Sign in now',
5+
'subject' => 'Ihr Anmeldecode für :app',
6+
'greeting' => 'Hallo :name,',
7+
'line-1' => 'Es gab eine Anmeldeanforderung von :ip. Hier ist Ihr Code, gültig bis :valid_until:',
8+
'line-2' => 'Falls Sie dies nicht waren: Kein Grund zur Panik. Weitere Informationen zu unserem Anmeldeverfahren finden Sie hier: https://google.com',
9+
'line-3' => 'Vielen Dank, dass Sie unsere Dienste nutzen. Bei Fragen stehen wir Ihnen gerne zur Verfügung!',
10+
'cta' => 'Jetzt anmelden',
1111
],
1212
];

0 commit comments

Comments
 (0)