2021-06-26 23:23:15 +08:00
|
|
|
<?php
|
|
|
|
|
2023-05-18 00:56:55 +08:00
|
|
|
namespace BookStack\Access;
|
2019-08-17 22:52:33 +08:00
|
|
|
|
2023-09-12 02:26:28 +08:00
|
|
|
use BookStack\Access\Notifications\UserInviteNotification;
|
2023-05-18 00:56:55 +08:00
|
|
|
use BookStack\Users\Models\User;
|
2019-08-17 22:52:33 +08:00
|
|
|
|
|
|
|
class UserInviteService extends UserTokenService
|
|
|
|
{
|
2023-04-04 17:44:38 +08:00
|
|
|
protected string $tokenTable = 'user_invites';
|
|
|
|
protected int $expiryTime = 336; // Two weeks
|
2019-08-17 22:52:33 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Send an invitation to a user to sign into BookStack
|
|
|
|
* Removes existing invitation tokens.
|
|
|
|
*/
|
|
|
|
public function sendInvitation(User $user)
|
|
|
|
{
|
|
|
|
$this->deleteByUser($user);
|
|
|
|
$token = $this->createTokenForUser($user);
|
2023-09-12 02:26:28 +08:00
|
|
|
$user->notify(new UserInviteNotification($token));
|
2019-08-17 22:52:33 +08:00
|
|
|
}
|
|
|
|
}
|