2016-09-06 14:19:16 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Controllers\Auth;
|
|
|
|
|
|
|
|
use App\Http\Controllers\Controller;
|
2018-10-06 09:43:58 +01:00
|
|
|
use App\Traits\ActivatesUsers;
|
2016-09-06 14:19:16 +01:00
|
|
|
use App\User;
|
|
|
|
use Illuminate\Foundation\Auth\RedirectsUsers;
|
2016-09-06 14:45:51 +01:00
|
|
|
use Illuminate\Http\Request;
|
2016-09-06 14:19:16 +01:00
|
|
|
use Illuminate\Support\Facades\App;
|
|
|
|
|
|
|
|
class ActivateController extends Controller
|
|
|
|
{
|
2018-10-06 09:43:58 +01:00
|
|
|
use RedirectsUsers, ActivatesUsers;
|
2016-09-06 14:19:16 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Where to redirect users after activation.
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
protected $redirectTo = '/login';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a new controller instance.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function __construct()
|
|
|
|
{
|
|
|
|
$this->middleware('guest');
|
|
|
|
}
|
|
|
|
|
2016-09-06 14:45:51 +01:00
|
|
|
public function activate(Request $request, $token)
|
2016-09-06 14:19:16 +01:00
|
|
|
{
|
|
|
|
/** @var User $user */
|
|
|
|
$user = User::where(['is_activated' => false, 'activation_token' => $token])->first();
|
|
|
|
|
|
|
|
if (is_null($user))
|
|
|
|
{
|
|
|
|
App::abort(404);
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
$user->is_activated = true;
|
|
|
|
$user->activation_token = null;
|
|
|
|
$user->save();
|
|
|
|
|
2016-09-06 14:45:51 +01:00
|
|
|
$request->session()->flash('info', trans('auth.account_activated_message'));
|
|
|
|
|
2018-11-19 13:26:44 +00:00
|
|
|
$this->logActivatedActivity($user);
|
2018-10-06 09:43:58 +01:00
|
|
|
$this->sendUserActivatedEmails($user);
|
|
|
|
|
2016-09-06 14:19:16 +01:00
|
|
|
return redirect($this->redirectPath());
|
|
|
|
}
|
|
|
|
}
|