48 lines
976 B
PHP
48 lines
976 B
PHP
|
<?php
|
||
|
|
||
|
namespace App\Http\Controllers\Auth;
|
||
|
|
||
|
use App\Http\Controllers\Controller;
|
||
|
use App\User;
|
||
|
use Illuminate\Foundation\Auth\RedirectsUsers;
|
||
|
use Illuminate\Support\Facades\App;
|
||
|
|
||
|
class ActivateController extends Controller
|
||
|
{
|
||
|
use RedirectsUsers;
|
||
|
|
||
|
/**
|
||
|
* Where to redirect users after activation.
|
||
|
*
|
||
|
* @var string
|
||
|
*/
|
||
|
protected $redirectTo = '/login';
|
||
|
|
||
|
/**
|
||
|
* Create a new controller instance.
|
||
|
*
|
||
|
* @return void
|
||
|
*/
|
||
|
public function __construct()
|
||
|
{
|
||
|
$this->middleware('guest');
|
||
|
}
|
||
|
|
||
|
public function activate($token)
|
||
|
{
|
||
|
/** @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();
|
||
|
|
||
|
return redirect($this->redirectPath());
|
||
|
}
|
||
|
}
|