add resend functionality
This commit is contained in:
@ -37,15 +37,36 @@ class MailFactory
|
||||
*
|
||||
* @return MailService
|
||||
*/
|
||||
public static function makeRecoveryMailerService($email, Token $token = null) {
|
||||
public static function makeRecoveryMailerService($email, Token $token = null)
|
||||
{
|
||||
/** @var Module $module */
|
||||
$module = Yii::$app->getModule('user');
|
||||
$to = $email;
|
||||
$from = $module->mailParams['fromEmail'];
|
||||
$subject = $module->mailParams['recoveryMailSubject'];
|
||||
$params = [
|
||||
'user' => $token && $token->user ? $token->user : null,
|
||||
'token' => $token
|
||||
];
|
||||
|
||||
return static::makeMailerService($from, $to, $subject, 'recovery');
|
||||
return static::makeMailerService($from, $to, $subject, 'recovery', $params);
|
||||
}
|
||||
|
||||
public static function makeConfirmationMailerService(User $user, Token $token = null)
|
||||
{
|
||||
/** @var Module $module */
|
||||
$module = Yii::$app->getModule('user');
|
||||
$to = $user->email;
|
||||
$from = $module->mailParams['fromEmail'];
|
||||
$subject = $module->mailParams['confirmationMailSubject'];
|
||||
$params = [
|
||||
'user' => $token && $token->user ? $token->user : null,
|
||||
'token' => $token
|
||||
];
|
||||
|
||||
return static::makeMailerService($from, $to, $subject, 'recovery', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds a MailerService
|
||||
*
|
||||
|
||||
33
lib/User/Factory/TokenFactory.php
Normal file
33
lib/User/Factory/TokenFactory.php
Normal file
@ -0,0 +1,33 @@
|
||||
<?php
|
||||
namespace Da\User\Factory;
|
||||
|
||||
use Da\User\Model\Token;
|
||||
use Da\User\Model\User;
|
||||
use Da\User\Traits\ContainerTrait;
|
||||
use Yii;
|
||||
|
||||
|
||||
class TokenFactory
|
||||
{
|
||||
|
||||
/**
|
||||
* @param $userId
|
||||
*
|
||||
* @return Token
|
||||
*/
|
||||
public static function makeConfirmationToken($userId)
|
||||
{
|
||||
$token = self::make(Token::class, ['user_id' => $userId, 'type' => Token::TYPE_CONFIRMATION]);
|
||||
|
||||
$token->save(false);
|
||||
|
||||
return $token;
|
||||
|
||||
}
|
||||
|
||||
protected static function make($class, $params = [])
|
||||
{
|
||||
return Yii::$container->get($class, $params);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user