forked from anonaddy/anonaddy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated hashing algo for verify email URL
- Loading branch information
1 parent
0478d9e
commit dd0ea08
Showing
10 changed files
with
212 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
<?php | ||
|
||
namespace App\Notifications; | ||
|
||
use App\Models\User; | ||
use Illuminate\Auth\Notifications\VerifyEmail; | ||
use Illuminate\Bus\Queueable; | ||
use Illuminate\Contracts\Queue\ShouldBeEncrypted; | ||
use Illuminate\Contracts\Queue\ShouldQueue; | ||
use Illuminate\Notifications\Messages\MailMessage; | ||
use Illuminate\Support\Carbon; | ||
use Illuminate\Support\Facades\Config; | ||
use Illuminate\Support\Facades\Hash; | ||
use Illuminate\Support\Facades\Lang; | ||
use Illuminate\Support\Facades\URL; | ||
|
||
class CustomVerifyEmail extends VerifyEmail implements ShouldQueue, ShouldBeEncrypted | ||
{ | ||
use Queueable; | ||
|
||
/** | ||
* Build the mail representation of the notification. | ||
* | ||
* @param mixed $notifiable | ||
* @return \Illuminate\Notifications\Messages\MailMessage | ||
*/ | ||
public function toMail($notifiable) | ||
{ | ||
$verificationUrl = $this->verificationUrl($notifiable); | ||
|
||
if (static::$toMailCallback) { | ||
return call_user_func(static::$toMailCallback, $notifiable, $verificationUrl); | ||
} | ||
|
||
$feedbackId = $notifiable instanceof User ? 'VU:anonaddy' : 'VR:anonaddy'; | ||
$recipientId = $notifiable instanceof User ? $notifiable->default_recipient_id : $notifiable->id; | ||
|
||
return (new MailMessage) | ||
->subject(Lang::get('Verify Email Address')) | ||
->markdown('mail.verify_email', [ | ||
'verificationUrl' => $verificationUrl, | ||
'recipientId' => $recipientId | ||
]) | ||
->withSwiftMessage(function ($message) use ($feedbackId) { | ||
$message->getHeaders() | ||
->addTextHeader('Feedback-ID', $feedbackId); | ||
}); | ||
} | ||
|
||
/** | ||
* Get the verification URL for the given notifiable. | ||
* | ||
* @param mixed $notifiable | ||
* @return string | ||
*/ | ||
protected function verificationUrl($notifiable) | ||
{ | ||
if (static::$createUrlCallback) { | ||
return call_user_func(static::$createUrlCallback, $notifiable); | ||
} | ||
|
||
return URL::temporarySignedRoute( | ||
'verification.verify', | ||
Carbon::now()->addMinutes(Config::get('auth.verification.expire', 60)), | ||
[ | ||
'id' => $notifiable->getKey(), | ||
'hash' => base64_encode(Hash::make($notifiable->getEmailForVerification())), | ||
] | ||
); | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.