Skip to content

Commit e0e1fca

Browse files
committed
User not found exception
1 parent 195bba8 commit e0e1fca

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
namespace Jrean\UserVerification\Exceptions;
4+
5+
class UserNotFoundException extends \Exception
6+
{
7+
/**
8+
* The exception description.
9+
*
10+
* @var string
11+
*/
12+
protected $message = 'No user found for that email adresse.';
13+
}

src/UserVerification.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,11 +260,17 @@ public function getUser($token, $table)
260260
* @param string $email
261261
* @param string $table
262262
* @return stdClass
263+
*
264+
* @throws \Jrean\UserVerification\Exceptions\UserNotFoundException
263265
*/
264266
protected function getUserByEmail($email, $table)
265267
{
266268
$user = DB::table($table)->where('email', $email)->first();
267269

270+
if ($user === null) {
271+
throw new UserNotFoundException();
272+
}
273+
268274
$user->table = $table;
269275

270276
return $user;
@@ -280,5 +286,4 @@ protected function getEmail($token)
280286
{
281287
return $this->decryptEmailFromToken($token);
282288
}
283-
284289
}

0 commit comments

Comments
 (0)