use BookStack\Exceptions\UserTokenExpiredException;
use BookStack\Exceptions\UserTokenNotFoundException;
use Carbon\Carbon;
-use Illuminate\Database\Connection as Database;
+use Illuminate\Support\Facades\DB;
use Illuminate\Support\Str;
use stdClass;
*/
protected $expiryTime = 24;
- protected $db;
-
- /**
- * UserTokenService constructor.
- *
- * @param Database $db
- */
- public function __construct(Database $db)
- {
- $this->db = $db;
- }
-
/**
* Delete all email confirmations that belong to a user.
*
*/
public function deleteByUser(User $user)
{
- return $this->db->table($this->tokenTable)
+ return DB::table($this->tokenTable)
->where('user_id', '=', $user->id)
->delete();
}
protected function createTokenForUser(User $user): string
{
$token = $this->generateToken();
- $this->db->table($this->tokenTable)->insert([
+ DB::table($this->tokenTable)->insert([
'user_id' => $user->id,
'token' => $token,
'created_at' => Carbon::now(),
*/
protected function tokenExists(string $token): bool
{
- return $this->db->table($this->tokenTable)
+ return DB::table($this->tokenTable)
->where('token', '=', $token)->exists();
}
*/
protected function getEntryByToken(string $token)
{
- return $this->db->table($this->tokenTable)
+ return DB::table($this->tokenTable)
->where('token', '=', $token)
->first();
}