public function confirm($code)
{
$user = User::where('confirmation_code', '=', $code)->get()->first();
if ($user) {
$notice_msg = trans('texts.security.confirmation');
$user->confirmed = true;
$user->confirmation_code = '';
$user->save();
if ($user->public_id) {
Auth::logout();
$token = Password::getRepository()->create($user);
return Redirect::to("/password/reset/{$token}");
} else {
if (Auth::check()) {
if (Session::has(REQUESTED_PRO_PLAN)) {
Session::forget(REQUESTED_PRO_PLAN);
$url = '/settings/account_management?upgrade=true';
} else {
$url = '/dashboard';
}
} else {
$url = '/login';
}
return Redirect::to($url)->with('message', $notice_msg);
}
} else {
$error_msg = trans('texts.security.wrong_confirmation');
return Redirect::to('/login')->with('error', $error_msg);
}
}