Skip to content

Commit e5239e7

Browse files
committed
Merge branch '4.1'
2 parents e14cb09 + f87ded6 commit e5239e7

15 files changed

+185
-338
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ vendor
44
composer.lock
55
phpunit.xml
66
.DS_Store
7-
7+
.phpcd

.php_cs

Lines changed: 0 additions & 8 deletions
This file was deleted.

.styleci.yml

Lines changed: 0 additions & 1 deletion
This file was deleted.

.travis.yml

Lines changed: 0 additions & 27 deletions
This file was deleted.

README.md

Lines changed: 45 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,13 @@ easily handle a user verification and validate the e-mail.
77

88
**This package is Laravel 5.4 compliant.**
99

10-
A few minor changes remain to be updated for the email markdown support + queue methods.
11-
A 2.3 ; 3.1 ; 4.1 update is coming soon with several improvements.
12-
13-
| laravel/branch | [2.2](https://github.com/jrean/laravel-user-verification/tree/2.2) | [3.0](https://github.com/jrean/laravel-user-verification/tree/3.0) | [4.0](https://github.com/jrean/laravel-user-verification/tree/4.0) | [master](https://github.com/jrean/laravel-user-verification/tree/master) |
14-
|---------|-----|-----|-----|--------|
15-
| 5.0.* | x | | | |
16-
| 5.1.* | x | | | |
17-
| 5.2.* | x | | | |
18-
| 5.3.* | | x | | |
19-
| 5.4.* | | | x | x |
10+
| laravel/branch | [2.2](https://github.com/jrean/laravel-user-verification/tree/2.2) | [3.0](https://github.com/jrean/laravel-user-verification/tree/3.0) | [4.0](https://github.com/jrean/laravel-user-verification/tree/4.0) | [4.1](https://github.com/jrean/laravel-user-verification/tree/4.1) | [master](https://github.com/jrean/laravel-user-verification/tree/master) |
11+
|---------|-----|-----|-----|-----|--------|
12+
| 5.0.* | x | | | | |
13+
| 5.1.* | x | | | | |
14+
| 5.2.* | x | | | | |
15+
| 5.3.* | | x | | | |
16+
| 5.4.* | | | x | x | x |
2017

2118
## ABOUT
2219

@@ -34,7 +31,7 @@ require block of your composer.json file:
3431

3532
{
3633
"require": {
37-
"jrean/laravel-user-verification": "^4.0"
34+
"jrean/laravel-user-verification": "^4.1"
3835
}
3936

4037
}
@@ -48,7 +45,8 @@ Or run the following command:
4845

4946
### Add the Service Provider & Facade/Alias
5047

51-
Once Larvel User Verification is installed, you need to register the service provider in `config/app.php`. Make sure to add the following line **above** the `RouteServiceProvider`.
48+
Once Larvel User Verification is installed, you need to register the service provider in `config/app.php`.
49+
Make sure to add the following line **above** the `RouteServiceProvider`.
5250

5351
```PHP
5452
Jrean\UserVerification\UserVerificationServiceProvider::class,
@@ -60,6 +58,12 @@ You may add the following `aliases` to your `config/app.php`:
6058
'UserVerification' => Jrean\UserVerification\Facades\UserVerification::class
6159
```
6260

61+
Publish the package config file by running the following command:
62+
63+
```
64+
php artisan vendor:publish --provider="Jrean\UserVerification\UserVerificationServiceProvider" --tag="config"
65+
```
66+
6367
## CONFIGURATION
6468
The model representing the `User` must implement the authenticatable
6569
interface `Illuminate\Contracts\Auth\Authenticatable` which is the default with
@@ -93,9 +97,10 @@ php artisan vendor:publish --provider="Jrean\UserVerification\UserVerificationSe
9397

9498
### Default middleware
9599

96-
This package ships with an optional middleware throwing a `UserNotVerifiedException`. You can setup the desired behaviour, for example a redirect to a specific page, in the `app\Exceptions\Handler.php`. Please refer to the [Laravel Documentation](https://laravel.com/docs/master/errors#the-exception-handler) to learn more about how to work with the exception handler.
100+
This package provides an optional middleware throwing a `UserNotVerifiedException`.
101+
Please refer to the [Laravel Documentation](https://laravel.com/docs/master/errors#the-exception-handler) to learn more about how to work with the exception handler.
97102

98-
To register the default middleware add the following to the `$routeMiddleware` array within the `app/Http/Kernel.php` file:
103+
To register the default middleware add the following lines to the `$routeMiddleware` array within the `app/Http/Kernel.php` file:
99104

100105
```php
101106
protected $routeMiddleware = [
@@ -107,7 +112,7 @@ Apply the middleware on your routes:
107112

108113
```php
109114
Route::group(['middleware' => ['web', 'isVerified']], function () {
110-
115+
//
111116
```
112117

113118
### Custom middleware
@@ -122,11 +127,9 @@ For more details about middlewares, please refer to the [Laravel Documentation](
122127

123128
## E-MAIL
124129

125-
As of this 4.0 release, the markdown support is not yet available.
126-
127130
This package provides a method to send an e-mail with a link containing the verification token.
128131

129-
- `send(AuthenticatableContract $user, $subject = null, $from = null, $name =
132+
- `send(AuthenticatableContract $user, $subject, $from = null, $name =
130133
null)`
131134

132135
By default the package will use the `from` and `name` values defined into the
@@ -147,27 +150,43 @@ The user will receive an e-mail with a link leading to the `getVerification()`
147150
method (endpoint). The view will receive a `$user` variable which contains the
148151
user details such as the verification token.
149152

150-
By default the package loads a sample e-mail view to get you started with:
153+
The package allow you to use both traditional blade view files and markdown.
154+
155+
By default a sample e-mail view is loaded to get you started with:
151156

152157
```
153158
Click here to verify your account: <a href="{{ $link = route('email-verification.check', $user->verification_token) . '?email=' . urlencode($user->email) }}">{{ $link }}</a>
154159
```
155160

161+
If you prefer to use Markdown instead, update the package config file
162+
`user-verification.php` in the `config` directory and replace the following:
163+
164+
```PHP
165+
'email' => [
166+
'type' => 'default',
167+
],
168+
```
169+
170+
by:
171+
172+
```PHP
173+
'email' => [
174+
'type' => 'markdown',
175+
],
176+
```
177+
178+
If you want to customize the e-mail views, run the following command to publish
179+
them and edit them to your needs:
180+
156181
**The URL must contain the verification token as parameter + (mandatory) a
157182
query string with the user's e-mail as parameter.**
158183

159-
If you want to customize the e-mail view, run the following command to publish
160-
it and edit it to your needs:
161-
162184
```
163185
php artisan vendor:publish --provider="Jrean\UserVerification\UserVerificationServiceProvider" --tag="views"
164186
```
165187

166188
The view will be available in the `resources/views/vendor/laravel-user-verification/` directory.
167189

168-
If you want to customize the e-mail view location and name you can create the view file
169-
wherever you want and call `UserVerification::emailView('directory.your-view-name')`.
170-
171190
## ERRORS
172191

173192
This package throws several exceptions. You are free to use `try/catch`
@@ -267,27 +286,15 @@ Send by e-mail a link containing the verification token.
267286

268287
Queue and send by e-mail a link containing the verification token.
269288

270-
* `sendQueueOn($queue, AuthenticatableContract $user, $subject = null, $from = null, $name = null)`
271-
272-
Queue on the given queue and send by e-mail a link containing the verification token.
273-
274289
* `sendLater($seconds, AuthenticatableContract $user, $subject = null, $from = null, $name = null)`
275290

276291
Send later by e-mail a link containing the verification token.
277292

278-
* `sendLaterOn($queue, $seconds, AuthenticatableContract $user, $subject = null, $from = null, $name = null)`
279-
280-
Send later on the given queue by e-mail a link containing the verification token.
281-
282293
* `process($email, $token, $userTable)`
283294

284295
Process the token verification for the given e-mail and token.
285296

286-
* `emailView($name)`
287-
288-
Set the e-mail view name.
289-
290-
For the `sendQueue`, `sendQueueOn`, `sendLater` and
297+
For the `sendQueue`, `sendLater` and
291298
`sendLaterOn` methods, you must [configure your queues](https://laravel.com/docs/)
292299
before using this feature.
293300

composer.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
},
3434
"autoload-dev": {
3535
"psr-4": {
36-
"Jrean\\UserVerification\\Tests\\": "tests"
3736
}
3837
},
3938
"scripts": {
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
<?php
2+
3+
namespace Jrean\UserVerification\Mail;
4+
5+
use Illuminate\Bus\Queueable;
6+
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
7+
use Illuminate\Mail\Mailable;
8+
use Illuminate\Queue\SerializesModels;
9+
use Illuminate\Contracts\Queue\ShouldQueue;
10+
11+
class VerificationTokenGenerated extends Mailable
12+
{
13+
use Queueable, SerializesModels;
14+
15+
/**
16+
* User instance.
17+
*
18+
* @var \Illuminate\Contracts\Auth\Authenticatable
19+
*/
20+
public $user;
21+
22+
/**
23+
* The subject of the message.
24+
*
25+
* @var string
26+
*/
27+
public $subject;
28+
29+
/**
30+
* The person the message is from.
31+
*
32+
* @var mixed
33+
*/
34+
public $from;
35+
36+
/**
37+
* The person name the message is from.
38+
*
39+
* @var mixed
40+
*/
41+
public $name;
42+
43+
/**
44+
* Create a new message instance.
45+
*
46+
* @return void
47+
*/
48+
public function __construct(
49+
AuthenticatableContract $user,
50+
$subject,
51+
$from = null,
52+
$name = null
53+
)
54+
{
55+
$this->user = $user;
56+
$this->subject = $subject;
57+
$this->from = $from;
58+
$this->name = $name;
59+
}
60+
61+
/**
62+
* Build the message.
63+
*
64+
* @return $this
65+
*/
66+
public function build()
67+
{
68+
if (! empty($this->from)) {
69+
$this->from($this->from, $this->name);
70+
}
71+
72+
$this->subject($this->subject);
73+
74+
if (config('user-verification.email.type') == 'markdown') {
75+
$this->markdown('laravel-user-verification::email-markdown');
76+
} else {
77+
$this->view('laravel-user-verification::email');
78+
}
79+
80+
return $this;
81+
}
82+
}

0 commit comments

Comments
 (0)