Skip to content

Commit 66bd7c7

Browse files
committed
publication logic, clean up, and readme
1 parent 27cbb92 commit 66bd7c7

File tree

15 files changed

+484
-237
lines changed

15 files changed

+484
-237
lines changed

README.md

Lines changed: 93 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,16 @@ Laravel 2-Step verification is a package to add 2-Step user authentication to an
2525

2626
Laravel 2-Step Authentication Verification for Laravel. Can be used in out the box with Laravel's authentication scaffolding or integrated into other projects.
2727

28-
2928
### Features
3029

31-
| Laravel 2 Step Verification |
30+
| Laravel 2 Step Verification Features |
3231
| :------------ |
33-
| XXX |
32+
| Uses [Notification](https://laravel.com/docs/5.5/notifications) Class to send user code to users email |
33+
| Can publish customizable views and assets |
34+
| Lots of [configuration](#configuration) options |
35+
| Uses Language [localization](https://laravel.com/docs/5.5/localization) files |
36+
| Verificaton Page |
37+
| Locked Page |
3438

3539
### Requirements
3640
* [Laravel 5.3, 5.4, or 5.5+](https://laravel.com/docs/installation)
@@ -44,8 +48,92 @@ Laravel 2-Step Authentication Verification for Laravel. Can be used in out the b
4448

4549
2. Register the package
4650

47-
...
51+
* Laravel 5.5 and up
52+
Uses package auto discovery feature, no need to edit the `config/app.php` file.
53+
54+
* Laravel 5.4 and below
55+
Register the package with laravel in `config/app.php` under `providers` with the following:
56+
57+
```php
58+
'providers' => [
59+
jeremykenedy\laravel2step\laravel2stepServiceProvider::class,
60+
];
61+
```
62+
63+
3. Publish the packages views, config file, assets, and language files by running the following from your projects root folder:
64+
65+
```bash
66+
php artisan vendor:publish --tag=laravel2step
67+
```
68+
69+
4. Optionally Update your `.env` file and associated settings (see [Environment File](#environment-file) section)
70+
71+
5. Run the migration to add the verifications codes table:
72+
73+
```php
74+
php artisan migrate
75+
```
76+
77+
* Note: If you want to specify a different table or connection make sure you update your `.env` file with the needed configuration variables.
78+
79+
6. Make sure your apps email is configured - this is usually done by configuring the Laravel out the box settings in the `.env` file.
80+
81+
### Configuration
82+
Laravel 2-Step Verification can be configured in directly in `/config/laravel2step.php` or in the variables in your `.env` file.
83+
84+
##### Environment File
85+
Here are the `.env` file variables available:
86+
87+
```bash
88+
LARAVEL_2STEP_ENABLED=true
89+
LARAVEL_2STEP_DATABASE_CONNECTION=mysql
90+
LARAVEL_2STEP_DATABASE_TABLE=laravel2step
91+
LARAVEL_2STEP_USER_MODEL=App\User
92+
LARAVEL_2STEP_EMAIL_FROM=""
93+
LARAVEL_2STEP_EMAIL_FROM_NAME="Laravel 2 Step Verification"
94+
LARAVEL_2STEP_EMAIL_SUBJECT='Laravel 2 Step Verification'
95+
LARAVEL_2STEP_EXCEEDED_COUNT=3
96+
LARAVEL_2STEP_EXCEEDED_COUNTDOWN_MINUTES=1440
97+
LARAVEL_2STEP_VERIFIED_LIFETIME_MINUTES=360
98+
LARAVEL_2STEP_RESET_BUFFER_IN_SECONDS=300
99+
LARAVEL_2STEP_CSS_ENABLED=true
100+
```
101+
102+
### Usage
103+
Laravel 2-Step Verification is enabled via middleware.
104+
You can enable 2-Step Verification in your routes and controllers via the following middleware:
105+
106+
```php
107+
twostep
108+
```
109+
110+
Example to start recording page views using middlware in `web.php`:
111+
112+
```php
113+
Route::group(['middleware' => ['auth', 'twostep']], function () {
114+
Route::get('/', 'WelcomeController@welcome')->name('welcome');
115+
});
116+
```
117+
118+
### Routes
119+
* ```/verification/needed```
120+
* ```/verification/verify```
121+
* ```/verification/resend```
122+
123+
### Screenshots
124+
![Verification Page](...)
125+
![Locked Page](...)
126+
![Verification Email](...)
127+
128+
### File Tree
129+
130+
```
131+
...
132+
133+
```
48134

135+
* Tree command can be installed using brew: `brew install tree`
136+
* File tree generated using command `tree -a -I '.git|node_modules|vendor|storage|tests`
49137

50138
### Future
51139
* Readme
@@ -67,5 +155,5 @@ Laravel 2-Step Authentication Verification for Laravel. Can be used in out the b
67155
* Create Artisan command and job to prune said entries.
68156

69157
### License
70-
Laravel-monitor is licensed under the MIT license. Enjoy!
158+
Laravel 2-Step Verification is licensed under the MIT license. Enjoy!
71159

src/Laravel2stepServiceProvider.php

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public function register()
4141
}
4242

4343
/**
44-
* Publish files for Laravel Monitor.
44+
* Publish files for Laravel 2-Step Verification.
4545
*
4646
* @return void
4747
*/
@@ -50,25 +50,28 @@ private function publishFiles()
5050
$publishTag = 'laravel2step';
5151

5252
$this->publishes([
53-
__DIR__.'/App/Mail/SendVerificationCode.php' => app_path('Mail/SendVerificationCode.php'),
53+
__DIR__.'/config/laravel2step.php' => base_path('config/laravel2step.php'),
5454
], $publishTag);
5555

5656
$this->publishes([
57-
__DIR__.'/config/laravel2step.php' => base_path('config/laravel2step.php'),
57+
__DIR__ . '/database/migrations/' => base_path('/database/migrations'),
5858
], $publishTag);
5959

60+
$this->publishes([
61+
__DIR__.'/public/css' => public_path('css/laravel2step'),
62+
], $publishTag);
6063

61-
// $this->publishes([
62-
// __DIR__.'/resources/views/emails/verification.blade.php' => resource_path('views/emails/verification.blade.php'),
63-
// ], $publishTag);
64+
$this->publishes([
65+
__DIR__.'/resources/assets/scss' => resource_path('assets/scss/laravel2step'),
66+
], $publishTag);
6467

65-
// $this->publishes([
66-
// __DIR__.'/resources/views' => base_path('resources/views/vendor/laravel2step'),
67-
// ], $publishTag);
68+
$this->publishes([
69+
__DIR__.'/resources/views' => resource_path('views/vendor/laravel2step'),
70+
], $publishTag);
6871

69-
// $this->publishes([
70-
// __DIR__.'/resources/lang' => base_path('resources/lang/vendor/laravel2step'),
71-
// ], $publishTag);
72+
$this->publishes([
73+
__DIR__.'/resources/lang' => base_path('resources/lang/vendor/laravel2step'),
74+
], $publishTag);
7275

7376
}
7477
}

src/app/Http/Controllers/TwoStepController.php

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ class TwoStepController extends Controller
1414
{
1515
use Laravel2StepTrait;
1616

17-
private $_user;
18-
private $_twoStepAuth;
1917
private $_authCount;
2018
private $_authStatus;
19+
private $_twoStepAuth;
2120
private $_remainingAttempts;
21+
private $_user;
2222

2323
/**
2424
* Create a new controller instance.
@@ -40,6 +40,7 @@ public function __construct()
4040
/**
4141
* Set the User2Step Variables
4242
*
43+
* @return void
4344
*/
4445
private function setUser2StepData()
4546
{
@@ -81,12 +82,12 @@ private function invalidCodeReturnData($errors = null)
8182
/**
8283
* Show the twostep verification form.
8384
*
84-
90
85+
* @return \Illuminate\Http\Response
8586
*/
8687
public function showVerification()
8788
{
88-
$twoStepAuth = $this->_twoStepAuth;
89-
$authStatus = $this->_authStatus;
89+
$twoStepAuth = $this->_twoStepAuth;
90+
$authStatus = $this->_authStatus;
9091

9192
if ($this->checkExceededTime($twoStepAuth->updated_at)) {
9293
$this->resetExceededTime($twoStepAuth);
@@ -179,12 +180,12 @@ public function verify(Request $request)
179180
}
180181
}
181182

182-
/**
183-
* Resend the validation code triggered by user
184-
*
185-
* @return \Illuminate\Http\Response
186-
*
187-
*/
183+
/**
184+
* Resend the validation code triggered by user
185+
*
186+
* @return \Illuminate\Http\Response
187+
*
188+
*/
188189
public function resend()
189190
{
190191
$twoStepAuth = $this->_twoStepAuth;

src/config/laravel2step.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44

55
/*
66
|--------------------------------------------------------------------------
7-
| Laravel Two Step Authentication Enabled
7+
| Verification Authentication Enabled
88
|--------------------------------------------------------------------------
99
*/
1010

1111
'laravel2stepEnabled' => env('LARAVEL_2STEP_ENABLED', true),
1212

1313
/*
1414
|--------------------------------------------------------------------------
15-
| Laravel Logger Database Settings
15+
| Verification Database Settings
1616
|--------------------------------------------------------------------------
1717
*/
1818

src/public/css/app.css

Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
.invalid-shake {
2+
-webkit-animation: kf_shake 0.4s 1 linear;
3+
-moz-animation: kf_shake 0.4s 1 linear;
4+
-o-animation: kf_shake 0.4s 1 linear;
5+
}
6+
7+
@-webkit-keyframes kf_shake {
8+
0% {
9+
-webkit-transform: translate(40px);
10+
}
11+
20% {
12+
-webkit-transform: translate(-40px);
13+
}
14+
40% {
15+
-webkit-transform: translate(20px);
16+
}
17+
60% {
18+
-webkit-transform: translate(-20px);
19+
}
20+
80% {
21+
-webkit-transform: translate(8px);
22+
}
23+
100% {
24+
-webkit-transform: translate(0px);
25+
}
26+
}
27+
@-moz-keyframes kf_shake {
28+
0% {
29+
-moz-transform: translate(40px);
30+
}
31+
20% {
32+
-moz-transform: translate(-40px);
33+
}
34+
40% {
35+
-moz-transform: translate(20px);
36+
}
37+
60% {
38+
-moz-transform: translate(-20px);
39+
}
40+
80% {
41+
-moz-transform: translate(8px);
42+
}
43+
100% {
44+
-moz-transform: translate(0px);
45+
}
46+
}
47+
@-o-keyframes kf_shake {
48+
0% {
49+
-o-transform: translate(40px);
50+
}
51+
20% {
52+
-o-transform: translate(-40px);
53+
}
54+
40% {
55+
-o-transform: translate(20px);
56+
}
57+
60% {
58+
-o-transform: translate(-20px);
59+
}
60+
80% {
61+
-o-transform: translate(8px);
62+
}
63+
100% {
64+
-o-origin-transform: translate(0px);
65+
}
66+
}
67+
.modal .modal-header {
68+
-webkit-border-radius: 5px 5px 0 0;
69+
-moz-border-radius: 5px 5px 0 0;
70+
-ms-border-radius: 5px 5px 0 0;
71+
-o-border-radius: 5px 5px 0 0;
72+
border-radius: 5px 5px 0 0;
73+
}
74+
.modal.modal-success .modal-header {
75+
color: #ffffff;
76+
background-color: #2ab27b;
77+
}
78+
.modal.modal-warning .modal-header {
79+
color: #ffffff;
80+
background-color: #cbb956;
81+
}
82+
.modal.modal-danger .modal-header {
83+
color: #ffffff;
84+
background-color: #bf5329;
85+
}
86+
.modal.modal-info .modal-header {
87+
color: #ffffff;
88+
background-color: #8eb4cb;
89+
}
90+
.modal.modal-primary .modal-header {
91+
color: #ffffff;
92+
background-color: #3097D1;
93+
}
94+
95+
.two-step-verification .verification-exceeded-panel {
96+
margin-top: 2.5em;
97+
}
98+
.two-step-verification .verification-exceeded-panel h4,
99+
.two-step-verification .verification-exceeded-panel p {
100+
margin: 0 0 2.5em 0;
101+
}
102+
.two-step-verification .verification-exceeded-panel .locked-icon {
103+
font-size: 3.5em;
104+
margin: 30px 0 0;
105+
}
106+
.two-step-verification #failed_login_alert {
107+
display: none;
108+
}
109+
.two-step-verification #failed_login_alert .glyphicon {
110+
font-size: 6em;
111+
text-align: center;
112+
display: block;
113+
margin: .25em 0 .75em;
114+
}
115+
.two-step-verification .panel {
116+
overflow: hidden;
117+
}
118+
.two-step-verification .verification-form-panel {
119+
margin-top: 2.5em;
120+
}
121+
.two-step-verification .verification-form-panel .code-inputs {
122+
margin-bottom: 3em;
123+
}
124+
.two-step-verification .verification-form-panel .submit-container {
125+
margin-bottom: 2em;
126+
}
127+
.two-step-verification .verification-form-panel input {
128+
font-size: 2em;
129+
height: 90px;
130+
}
131+
@media (min-width: 500px) {
132+
.two-step-verification .verification-form-panel input {
133+
font-size: 3em;
134+
height: 140px;
135+
}
136+
}
137+
@media (min-width: 650px) {
138+
.two-step-verification .verification-form-panel input {
139+
font-size: 4em;
140+
height: 180px;
141+
}
142+
}

src/public/css/app.min.css

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)