Fixed email wording
Change-Id: I640c5ce1d39265830ec72e5ae13037d5980121bd Signed-off-by: smarcet <smarcet@gmail.com>
This commit is contained in:
parent
5e2a87df69
commit
2420988947
@ -17,6 +17,8 @@ use Illuminate\Mail\Mailable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
use Illuminate\Support\Facades\URL;
|
||||
|
||||
/**
|
||||
* Class WelcomeNewUserEmail
|
||||
* @package App\Mail
|
||||
@ -37,14 +39,27 @@ final class WelcomeNewUserEmail extends Mailable
|
||||
*/
|
||||
public $user_fullname;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $verification_link;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $bio_link;
|
||||
|
||||
/**
|
||||
* WelcomeNewUserEmail constructor.
|
||||
* @param User $user
|
||||
* @param string|null $verification_link
|
||||
*/
|
||||
public function __construct(User $user)
|
||||
public function __construct(User $user, ?string $verification_link)
|
||||
{
|
||||
$this->user_email = $user->getEmail();
|
||||
$this->user_fullname = $user->getFullName();
|
||||
$this->verification_link = $verification_link;
|
||||
$this->bio_link = URL::action("UserController@getLogin");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -77,14 +77,16 @@ final class EventServiceProvider extends ServiceProvider
|
||||
if(is_null($user)) return;
|
||||
if(! $user instanceof User) return;
|
||||
$user_service = App::make(IUserService::class);
|
||||
if(!$user_service instanceof IUserService) return;
|
||||
|
||||
$user_service->generateIdentifier($user);
|
||||
|
||||
Mail::queue(new WelcomeNewUserEmail($user));
|
||||
$verification_link = $user_service->sendWelcomeEmail($user);
|
||||
|
||||
if(!$user->isEmailVerified()) {
|
||||
|
||||
if (!$user->hasCreator())
|
||||
$user_service->sendVerificationEmail($user);
|
||||
$user_service->sendVerificationEmail($user, $verification_link);
|
||||
}
|
||||
else{
|
||||
// email is already verified
|
||||
|
@ -47,10 +47,11 @@ interface IUserService
|
||||
|
||||
/**
|
||||
* @param User $user
|
||||
* @return User
|
||||
* @param string|null $verification_link
|
||||
* @throws ValidationException
|
||||
* @return User
|
||||
*/
|
||||
public function sendVerificationEmail(User $user): User;
|
||||
public function sendVerificationEmail(User $user, string $verification_link = null): User;
|
||||
|
||||
/**
|
||||
* @param User $user
|
||||
@ -98,4 +99,10 @@ interface IUserService
|
||||
* @return void
|
||||
*/
|
||||
public function recalculateUserSpamType(User $user):void;
|
||||
|
||||
/**
|
||||
* @param User $user
|
||||
* @return string|null
|
||||
*/
|
||||
public function sendWelcomeEmail(User $user):?string;
|
||||
}
|
@ -22,6 +22,7 @@ use App\libs\Auth\Repositories\IUserPasswordResetRequestRepository;
|
||||
use App\libs\Auth\Repositories\IUserRegistrationRequestRepository;
|
||||
use App\Mail\UserEmailVerificationRequest;
|
||||
use App\Mail\UserPasswordResetRequestMail;
|
||||
use App\Mail\WelcomeNewUserEmail;
|
||||
use App\Services\AbstractService;
|
||||
use Auth\IUserNameGeneratorService;
|
||||
use Auth\Repositories\IUserRepository;
|
||||
@ -178,31 +179,55 @@ final class UserService extends AbstractService implements IUserService
|
||||
|
||||
/**
|
||||
* @param User $user
|
||||
* @return User
|
||||
* @throws ValidationException
|
||||
* @return string
|
||||
*/
|
||||
public function sendVerificationEmail(User $user): User
|
||||
{
|
||||
return $this->tx_service->transaction(function() use($user){
|
||||
if($user->isEmailVerified())
|
||||
throw new ValidationException
|
||||
(
|
||||
sprintf
|
||||
(
|
||||
"User %s (%s) has already verified his/her email.",
|
||||
$user->getEmail(),
|
||||
$user->getId()
|
||||
)
|
||||
);
|
||||
private function generateVerificationLink(User $user):string{
|
||||
|
||||
return $this->tx_service->transaction(function() use($user) {
|
||||
|
||||
//generate unique token
|
||||
do{
|
||||
do {
|
||||
$token = $user->generateEmailVerificationToken();
|
||||
$former_user = $this->user_repository->getByVerificationEmailToken($token);
|
||||
if(is_null($former_user)) break;
|
||||
} while(true);
|
||||
if (is_null($former_user)) break;
|
||||
} while (true);
|
||||
|
||||
$verification_link = URL::route("verification_verify", ["token" => $token]);
|
||||
return URL::route("verification_verify", ["token" => $token]);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param User $user
|
||||
* @return string|null
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function sendWelcomeEmail(User $user):?string {
|
||||
|
||||
return $this->tx_service->transaction(function() use($user){
|
||||
|
||||
$verification_link = null;
|
||||
|
||||
if(!$user->isEmailVerified())
|
||||
$verification_link = $this->generateVerificationLink($user);
|
||||
|
||||
Mail::queue(new WelcomeNewUserEmail($user, $verification_link));
|
||||
|
||||
return $verification_link;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param User $user
|
||||
* @param string|null $verification_link
|
||||
* @return User
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function sendVerificationEmail(User $user, string $verification_link = null): User
|
||||
{
|
||||
return $this->tx_service->transaction(function() use($user, $verification_link){
|
||||
|
||||
if(empty($verification_link))
|
||||
$verification_link = $this->generateVerificationLink($user);
|
||||
|
||||
Mail::queue(new UserEmailVerificationRequest($user, $verification_link));
|
||||
|
||||
|
@ -1491,10 +1491,15 @@ SQL;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return String
|
||||
* @return string
|
||||
* @throws ValidationException
|
||||
*/
|
||||
public function generateEmailVerificationToken(): string
|
||||
{
|
||||
if($this->isEmailVerified()){
|
||||
throw new ValidationException(sprintf("User %s (%s) is already verified.", $this->id, $this->email));
|
||||
}
|
||||
|
||||
$generator = new RandomGenerator();
|
||||
$token = strval($this->id) . $generator->randomToken();
|
||||
$this->email_verified_token_hash = self::createConfirmationTokenHash($token);
|
||||
|
@ -221,7 +221,7 @@ return [
|
||||
|
||||
'version' => env('APP_VERSION', 'XX.XX.XX'),
|
||||
'app_name' => env('APP_NAME', 'OpenStackID'),
|
||||
'tenant_name' => env('TENANT_NAME', 'OpenStack'),
|
||||
'tenant_name' => env('TENANT_NAME', 'Open Infrastructure'),
|
||||
'logo_url' => env('LOGO_URL', '/assets/img/openstack-logo-full.svg'),
|
||||
'tenant_favicon' => env('TENANT_FAV_ICON_URL', '/assets/img/favicon-32x32.png'),
|
||||
'help_email' => env('HELP_EMAIL', 'support@openstack.org'),
|
||||
|
@ -6,7 +6,7 @@
|
||||
<body>
|
||||
<p>Dear {!!$user_fullname!!},</p>
|
||||
<p>
|
||||
Thank you for your interest in joining the Open Infrastructure community! In order to verify your email,
|
||||
Thank you for your interest in joining the {!! Config::get('app.tenant_name') !!} community! In order to verify your email,
|
||||
please click the verification link: <a href="{!! $verification_link !!}" target="_blank">Verify Email Address.</a>
|
||||
</p>
|
||||
<p>
|
||||
|
@ -6,10 +6,15 @@
|
||||
<body>
|
||||
<p>Dear {!!$user_fullname!!},</p>
|
||||
<p>
|
||||
You will use this account to access all Open Infrastructure community apps and websites that require an {!! Config::get('app.app_name') !!},
|
||||
You will use this account to access all {!! Config::get('app.tenant_name') !!} community apps and websites that require an {!! Config::get('app.app_name') !!},
|
||||
including the virtual Open Infrastructure Summit. Your user details are associated with your {!! Config::get('app.app_name') !!} and you
|
||||
are able to grant access to that information to each app at your discretion.
|
||||
</p>
|
||||
@if($verification_link)
|
||||
<p>
|
||||
In order to verify your email, please click the verification link: <a href="{!! $verification_link !!}" target="_blank">Verify Email Address.</a>
|
||||
</p>
|
||||
@endif
|
||||
<p>
|
||||
To edit your profile just click <a href="{!! URL::action("UserController@getLogin") !!}">here</a>.
|
||||
You may update your photo, add a bio, and other information you wish to share.
|
||||
|
Loading…
x
Reference in New Issue
Block a user