/** * Reactivate the given user. * * @param int $id * @return \Illuminate\Http\RedirectResponse */ public function reactivate($id) { $user = Sentinel::findById($id); $activation = Activation::exists($user) ?: Activation::create($user); if (Activation::complete($user, $activation->code)) { return Redirect::route('user.edit', $id)->withSuccess(trans('users/messages.success.activate')); } return Redirect::route('user.edit', $id)->withErrors(trans('users/messages.error.activate')); }
/** * @param $id * @param $code * @return $this|\Illuminate\Http\RedirectResponse */ public function getReactivate($id, $code) { if (!($user = Sentinel::check())) { return Redirect::to('login'); } $activation = Activation::exists($user) ?: Activation::create($user); // This is used for the demo, usually you would want // to activate the account through the link you // receive in the activation email Activation::complete($user, $activation->code); $code = $activation->code; $sent = Mail::send('emails.activate', compact('user', 'code'), function ($m) use($user) { $m->to($user->email)->subject('Activate Your Account'); }); if ($sent === 0) { return Redirect::to('login')->withErrors('Failed to send activation email.'); } return Redirect::to('account')->withSuccess('Account activated.'); }
//Route::get('auth/social', Route::get('wait', function () { return View::make('sentinel.wait'); }); Route::get('activate/{id}/{code}', function ($id, $code) { $user = Sentinel::findById($id); if (!Activation::complete($user, $code)) { return Redirect::to("login")->withErrors('Invalid or expired activation code.'); } return Redirect::to('login')->withSuccess('Account activated.'); })->where('id', '\\d+'); Route::get('reactivate', function () { if (!($user = Sentinel::check())) { return Redirect::to('login'); } $activation = Activation::exists($user) ?: Activation::create($user); // This is used for the demo, usually you would want // to activate the account through the link you // receive in the activation email Activation::complete($user, $activation->code); // $code = $activation->code; // $sent = Mail::send('sentinel.emails.activate', compact('user', 'code'), function($m) use ($user) // { // $m->to($user->email)->subject('Activate Your Account'); // }); // if ($sent === 0) // { // return Redirect::to('register') // ->withErrors('Failed to send activation email.'); // } return Redirect::to('account')->withSuccess('Account activated.');