NOW MANAGED ON CODEBERG
Cleaned up old token services
Dan Brown4835a0dcb138
diff --git a/app/Auth/Access/EmailConfirmationService.php b/app/Auth/Access/EmailConfirmationService.phpindex 9c357d95f..1873cad08 100644--- a/app/Auth/Access/EmailConfirmationService.php+++ b/app/Auth/Access/EmailConfirmationService.php@@ -8,8 +8,8 @@ use BookStack\Notifications\ConfirmEmail;class EmailConfirmationService extends UserTokenService{- protected $tokenTable = 'email_confirmations';- protected $expiryTime = 24;+ protected string $tokenTable = 'email_confirmations';+ protected int $expiryTime = 24;/*** Create new confirmation for a user,diff --git a/app/Auth/Access/UserInviteService.php b/app/Auth/Access/UserInviteService.phpindex d884cd636..191a03dd5 100644--- a/app/Auth/Access/UserInviteService.php+++ b/app/Auth/Access/UserInviteService.php@@ -7,14 +7,12 @@ use BookStack\Notifications\UserInvite;class UserInviteService extends UserTokenService{- protected $tokenTable = 'user_invites';- protected $expiryTime = 336; // Two weeks+ protected string $tokenTable = 'user_invites';+ protected int $expiryTime = 336; // Two weeks/*** Send an invitation to a user to sign into BookStack* Removes existing invitation tokens.- *- * @param User $user*/public function sendInvitation(User $user){diff --git a/app/Auth/Access/UserTokenService.php b/app/Auth/Access/UserTokenService.phpindex ffd828ab5..8dfe570f9 100644--- a/app/Auth/Access/UserTokenService.php+++ b/app/Auth/Access/UserTokenService.php@@ -14,41 +14,29 @@ class UserTokenService{/*** Name of table where user tokens are stored.- *- * @var string*/- protected $tokenTable = 'user_tokens';+ protected string $tokenTable = 'user_tokens';/*** Token expiry time in hours.- *- * @var int*/- protected $expiryTime = 24;+ protected int $expiryTime = 24;/**- * Delete all email confirmations that belong to a user.- *- * @param User $user- *- * @return mixed+ * Delete all tokens that belong to a user.*/- public function deleteByUser(User $user)+ public function deleteByUser(User $user): void{- return DB::table($this->tokenTable)+ DB::table($this->tokenTable)->where('user_id', '=', $user->id)->delete();}/**- * Get the user id from a token, while check the token exists and has not expired.- *- * @param string $token+ * Get the user id from a token, while checking the token exists and has not expired.** @throws UserTokenNotFoundException* @throws UserTokenExpiredException- *- * @return int*/public function checkTokenAndGetUserId(string $token): int{@@ -67,8 +55,6 @@ class UserTokenService/*** Creates a unique token within the email confirmation database.- *- * @return string*/protected function generateToken(): string{@@ -82,10 +68,6 @@ class UserTokenService/*** Generate and store a token for the given user.- *- * @param User $user- *- * @return string*/protected function createTokenForUser(User $user): string{@@ -102,10 +84,6 @@ class UserTokenService/*** Check if the given token exists.- *- * @param string $token- *- * @return bool*/protected function tokenExists(string $token): bool{@@ -115,12 +93,8 @@ class UserTokenService/*** Get a token entry for the given token.- *- * @param string $token- *- * @return object|null*/- protected function getEntryByToken(string $token)+ protected function getEntryByToken(string $token): ?stdClass{return DB::table($this->tokenTable)->where('token', '=', $token)@@ -129,10 +103,6 @@ class UserTokenService/*** Check if the given token entry has expired.- *- * @param stdClass $tokenEntry- *- * @return bool*/protected function entryExpired(stdClass $tokenEntry): bool{diff --git a/app/Http/Controllers/Auth/ConfirmEmailController.php b/app/Http/Controllers/Auth/ConfirmEmailController.phpindex b282d0601..fdde8e70c 100644--- a/app/Http/Controllers/Auth/ConfirmEmailController.php+++ b/app/Http/Controllers/Auth/ConfirmEmailController.php@@ -14,21 +14,11 @@ use Illuminate\Http\Request;class ConfirmEmailController extends Controller{- protected EmailConfirmationService $emailConfirmationService;- protected LoginService $loginService;- protected UserRepo $userRepo;-- /**- * Create a new controller instance.- */public function __construct(- EmailConfirmationService $emailConfirmationService,- LoginService $loginService,- UserRepo $userRepo+ protected EmailConfirmationService $emailConfirmationService,+ protected LoginService $loginService,+ protected UserRepo $userRepo) {- $this->emailConfirmationService = $emailConfirmationService;- $this->loginService = $loginService;- $this->userRepo = $userRepo;}/**