Skip to content
This repository has been archived by the owner on May 7, 2019. It is now read-only.

Commit

Permalink
Clean up email subjects and fix routes when using daemon queue worker
Browse files Browse the repository at this point in the history
  • Loading branch information
TheReverend403 committed Jul 4, 2016
1 parent e0c1d97 commit d5c9d06
Show file tree
Hide file tree
Showing 10 changed files with 27 additions and 19 deletions.
2 changes: 1 addition & 1 deletion app/Exceptions/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function report(Exception $e)
];

Mail::queue(['text' => 'emails.admin.exception'], $data, function (Message $message) use ($data) {
$message->subject(sprintf("[%s] Application Exception", config('upste.site_name')));
$message->subject('Application Exception');
$message->to(config('upste.owner_email'));
});
}
Expand Down
9 changes: 5 additions & 4 deletions app/Http/Controllers/Account/AccountController.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,18 +74,19 @@ public function deleteUpload(Upload $upload)
return redirect()->back();
}

public function postResetKey()
public function postResetKey(Request $request)
{
do {
$newKey = str_random(Helpers::API_KEY_LENGTH);
} while (User::whereApikey($newKey)->first());

$user = Auth::user();
$user = $request->user();
$user->fill(['apikey' => $newKey])->save();
flash()->success(trans('messages.api_key_changed', ['api_key' => $newKey]))->important();

Mail::queue(['text' => 'emails.user.api_key_reset'], $user->toArray(), function (Message $message) use ($user) {
$message->subject(sprintf("[%s] API Key Reset", config('upste.site_name')));
$passwordRoute = route('account.password.email');
Mail::queue(['text' => 'emails.user.api_key_reset'], compact('user', 'passwordRoute'), function (Message $message) use ($user) {
$message->subject('API Key Reset');
$message->to($user->email);
});

Expand Down
9 changes: 5 additions & 4 deletions app/Http/Controllers/Admin/AdminController.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,9 @@ public function postUserAccept(User $user)
{
$user->fill(['enabled' => true])->save();

Mail::queue(['text' => 'emails.user.account_accepted'], $user->toArray(), function (Message $message) use ($user) {
$message->subject(sprintf("[%s] Account Request Accepted", config('upste.site_name')));
$loginRoute = route('login');
Mail::queue(['text' => 'emails.user.account_accepted'], compact('user', 'loginRoute'), function (Message $message) use ($user) {
$message->subject('Account Request Accepted');
$message->to($user->email);
});

Expand All @@ -136,8 +137,8 @@ public function postUserAccept(User $user)

public function postUserReject(User $user)
{
Mail::queue(['text' => 'emails.user.account_rejected'], $user->toArray(), function (Message $message) use ($user) {
$message->subject(sprintf("[%s] Account Request Rejected", config('upste.site_name')));
Mail::queue(['text' => 'emails.user.account_rejected'], compact('user'), function (Message $message) use ($user) {
$message->subject('Account Request Rejected');
$message->to($user->email);
});

Expand Down
5 changes: 3 additions & 2 deletions app/Http/Controllers/Auth/AuthController.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,9 @@ public function postRegister(Request $request)
$data = $request->all();
$user = $this->create($data);

Mail::queue(['text' => 'emails.admin.new_registration'], $data, function (Message $message) use ($data) {
$message->subject(sprintf("[%s] New User Registration", config('upste.site_name')));
$requestRoute = route('admin.requests');
Mail::queue(['text' => 'emails.admin.new_registration'], compact('user', 'requestRoute'), function (Message $message) use ($data) {
$message->subject('New User Registration');
$message->to(config('upste.owner_email'));
});

Expand Down
5 changes: 5 additions & 0 deletions app/Http/Controllers/Auth/PasswordController.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ public function sendResetLinkEmail(Request $request)

$broker = $this->getBroker();

$passwordRoute = route('account.password.email');
view()->composer('emails.user.password_reset', function($view) {
$view->with(compact('passwordRoute'));
});

$response = Password::broker($broker)->sendResetLink($request->only('email'), function (Message $message) {
$message->subject($this->getEmailSubject());
});
Expand Down
4 changes: 2 additions & 2 deletions resources/views/emails/admin/new_registration.blade.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{ $name }} ({{ $email }}) has just registered at {{ config('upste.site_name') }}
{{ $user->name }} ({{ $user->email }}) has just registered at {{ config('upste.site_name') }}
@if (config('upste.require_user_approval'))

Check pending requests at {{ route('admin.requests') }}
Check pending requests at {{ $requestRoute }}
@endif
4 changes: 2 additions & 2 deletions resources/views/emails/user/account_accepted.blade.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Hi {{ $name }},
Hi {{ $user->name }},

Your request for an account at {{ config('upste.site_name') }} was just accepted!
Log in at {{ route('login') }} and don't forget to read the new user notice.
Log in at {{ $loginRoute }} and don't forget to read the new user notice.
2 changes: 1 addition & 1 deletion resources/views/emails/user/account_rejected.blade.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Hi {{ $name }},
Hi {{ $user->name }},

Unfortunately, your request for an account at {{ config('upste.site_name') }} was rejected.
This is most likely because the site owner doesn't know you or wasn't expecting your request.
Expand Down
4 changes: 2 additions & 2 deletions resources/views/emails/user/api_key_reset.blade.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Hi {{ $name }},
Hi {{ $user->name }},

Somebody, probably you, just reset your API key at {{ config('upste.site_name') }}.
If this was you, you can safely ignore this email.
If not, we recommend resetting your password at {{ route('account.password.email') }} (you'll need to log out first).
If not, we recommend resetting your password at {{ $passwordRoute }} (you'll need to be logged out first).
2 changes: 1 addition & 1 deletion resources/views/emails/user/password_reset.blade.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Go here to reset your password: {{ route("account.password.reset") . "/$token" }}
Go here to reset your password: {{ $passwordRoute . "/$token" }}

0 comments on commit d5c9d06

Please sign in to comment.