New user registrations now get an activation e-mail

This commit is contained in:
Andy Heathershaw 2016-09-06 13:48:52 +01:00
parent 2a1311b2ba
commit 57bc8d86cc
5 changed files with 30 additions and 7 deletions

View File

@ -75,7 +75,7 @@ class RegisterController extends Controller
if (UserConfig::get('require_email_verification'))
{
$activationData['is_activated'] = false;
$activationData['activation_code'] = MiscHelper::randomString();
$activationData['activation_token'] = MiscHelper::randomString();
}
return User::create(array_merge(
@ -89,6 +89,11 @@ class RegisterController extends Controller
));
}
public function activate($token)
{
return Theme::render('auth.activate');
}
public function register(Request $request)
{
if (!UserConfig::get('allow_self_registration'))

View File

@ -33,11 +33,14 @@ class UserActivationRequired extends Mailable
*/
public function build()
{
$subject = trans('email.activation_required_subject', ['app_name' => UserConfig::get('app_name')]);
return $this
->from(UserConfig::get('sender_address'), UserConfig::get('sender_name'))
->subject(trans('email.activation_required_subject', ['app_name' => UserConfig::get('app_name')]))
->subject($subject)
->view(Theme::viewName('email.user_activation_required'))
->with([
'subject' => $subject,
'user' => $this->user
]);
}

View File

@ -1,5 +1,10 @@
<?php
return [
'activation_required_p1' => 'Thank you for registering an account on :app_name.',
'activation_required_p2' => 'To confirm your e-mail address and activate your account, please click the link below. ' .
'You may also need to copy + paste this into your browser\'s address bar if your e-mail reader has split this line.',
'activation_required_subject' => 'Activate your :app_name account',
'generic_intro' => 'Hi :user_name,',
'generic_regards' => 'Regards,',
'test_email_subject' => 'Test e-mail from :app_name'
];

View File

@ -1,6 +1,15 @@
Hi {{ $user->name }},
@extends('themes.base.email_layout')
Thanks for registering.
Regards,
{{ UserConfig::get('app_name') }}
@section('title', $subject)
@section('content')
<p>@lang('email.generic_intro', ['user_name' => $user->name])</p>
<p>@lang('email.activation_required_p1', ['app_name' => UserConfig::get('app_name')])</p>
<p>@lang('email.activation_required_p2')</p>
<p><a href="{{ route('auth.activate', ['token' => $user->activation_token]) }}">{{ route('auth.activate', ['token' => $user->activation_token]) }}</a></p>
<p>
-- <br/>
@lang('email.generic_regards')<br/>
{{ UserConfig::get('app_name') }}<br/>
<a href="{{ route('home') }}">{{ route('home') }}</a>
</p>
@endsection

View File

@ -33,6 +33,7 @@ Route::group(['prefix' => 'admin'], function () {
// Gallery
Route::get('/', 'Gallery\DefaultController@index')->name('home');
Route::get('/activate/{token}', 'Auth\RegisterController@activate')->name('auth.activate');
Route::get('{albumUrlAlias}', 'Gallery\AlbumController@index')->name('viewAlbum');
Route::get('{albumUrlAlias}/{photoFilename}', 'Gallery\PhotoController@show')->name('viewPhoto');
Route::get('photo/{albumUrlAlias}/{photoFilename}', 'Gallery\PhotoController@download')->name('downloadPhoto');