summaryrefslogtreecommitdiff
path: root/app/Services/UserService.php
diff options
context:
space:
mode:
authorGreg Roach <fisharebest@webtrees.net>2019-09-22 16:26:40 +0100
committerGreg Roach <fisharebest@webtrees.net>2019-09-22 16:37:55 +0100
commita00bcc6367b57a659a7d6d69e7e1d00f79db8d9f (patch)
tree82cd665bfa0164fa7d14f7656dd6355dd38b7d41 /app/Services/UserService.php
parent502cab9067673ad571ede842ac467603d7f0fe88 (diff)
downloadwebtrees-a00bcc6367b57a659a7d6d69e7e1d00f79db8d9f.tar.gz
webtrees-a00bcc6367b57a659a7d6d69e7e1d00f79db8d9f.tar.bz2
webtrees-a00bcc6367b57a659a7d6d69e7e1d00f79db8d9f.zip
Update password reset procedure
Diffstat (limited to 'app/Services/UserService.php')
-rw-r--r--app/Services/UserService.php23
1 files changed, 23 insertions, 0 deletions
diff --git a/app/Services/UserService.php b/app/Services/UserService.php
index 8c7d83a914..9df644fa97 100644
--- a/app/Services/UserService.php
+++ b/app/Services/UserService.php
@@ -18,6 +18,7 @@ declare(strict_types=1);
namespace Fisharebest\Webtrees\Services;
use Fisharebest\Webtrees\Auth;
+use Fisharebest\Webtrees\Carbon;
use Fisharebest\Webtrees\Contracts\UserInterface;
use Fisharebest\Webtrees\Individual;
use Fisharebest\Webtrees\Tree;
@@ -104,6 +105,28 @@ class UserService
}
/**
+ * Find the user with a specified password reset token.
+ *
+ * @param string $token
+ *
+ * @return User|null
+ */
+ public function findByToken(string $token): ?User
+ {
+ return DB::table('user')
+ ->join('user_setting AS us1', 'us1.user_id', '=', 'user.user_id')
+ ->where('us1.setting_name', '=', 'password-token')
+ ->where('us1.setting_value', '=', $token)
+ ->join('user_setting AS us2', 'us2.user_id', '=', 'user.user_id')
+ ->where('us2.setting_name', '=', 'password-token-expire')
+ ->where('us2.setting_value', '>', Carbon::now()->timestamp)
+ ->select(['user.*'])
+ ->get()
+ ->map(User::rowMapper())
+ ->first();
+ }
+
+ /**
* Find the user with a specified user_name.
*
* @param string $user_name