本文整理汇总了PHP中Sentry::findUserByActivationCode方法的典型用法代码示例。如果您正苦于以下问题:PHP Sentry::findUserByActivationCode方法的具体用法?PHP Sentry::findUserByActivationCode怎么用?PHP Sentry::findUserByActivationCode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sentry
的用法示例。
在下文中一共展示了Sentry::findUserByActivationCode方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: doUserActivate
public function doUserActivate($code)
{
try {
$user = Sentry::findUserByActivationCode($code);
$user->attemptActivation($code);
if ($user->isActivated()) {
$user->password = Input::get('password');
$user->save();
Sentry::login($user);
$data = array('status' => true, 'link' => URL::to('user/cabinet'));
return Response::json($data);
}
} catch (UserNotFoundException $e) {
App::abort('404');
}
}
示例2: getActivation
/**
* Actiovation account
*/
public function getActivation($code = null)
{
if (Session::get('activated')) {
return View::make(Config::get('larauth::views.activation'));
}
if (Input::get('code')) {
$code = Input::get('code');
}
if ($code) {
try {
$user = Sentry::findUserByActivationCode($code);
$user->attemptActivation($code);
// добавляем пользователя в группы
foreach (Config::get('larauth::append_groups') as $group) {
try {
$oGroup = Sentry::findGroupByName($group);
} catch (\Cartalyst\Sentry\Groups\GroupNotFoundException $e) {
Log::alert("Попытка добавдения пользователя :user_email в несуществующую группу :group", ['user_email' => $user->email, 'group' => $group]);
}
$user->addGroup($oGroup);
}
$data = ['email' => $user->email, 'password' => Cache::pull(md5($user->email)), 'subject' => trans('larauth::larauth.registration_success')];
$this->sendMail(Config::get('larauth::views.mail_registration'), $data);
return Redirect::route('larauth.activation')->with('activated', TRUE);
} catch (Cartalyst\Sentry\Users\UserNotFoundException $e) {
return Redirect::route('larauth.activation')->with('error', trans('larauth::larauth.wrong_activation_code'));
}
}
return View::make(Config::get('larauth::views.activation'), ['error' => Session::get('error'), 'code' => $code]);
}
示例3: activateUser
/**
* @param $activationcode
*
* Activate a user when he clicks the link in the mailbox.
*/
function activateUser($activationcode)
{
try {
$user = Sentry::findUserByActivationCode($activationcode);
if ($user->attemptActivation($activationcode)) {
// User activation passed
return Redirect::to('login')->with('success', 'User successfully activated');
} else {
// User activation failed
return Redirect::to('login')->with('message', 'Ooops, something went wrong please contact the system administrator.');
}
} catch (Cartalyst\Sentry\Users\UserNotFoundException $e) {
echo 'User was not found.';
} catch (Cartalyst\Sentry\Users\UserAlreadyActivatedException $e) {
echo 'User is already activated.';
}
// return 'lets veryify this ' . $activationcode;
}
示例4: activate
public function activate($code)
{
try {
$user = Sentry::findUserByActivationCode($code);
try {
if ($user->attemptActivation($code)) {
Session::flash('success', trans('user.activate.success'));
} else {
Session::flash('error', trans('user.activate.error'));
}
} catch (Cartalyst\Sentry\Users\UserAlreadyActivatedException $e) {
Session::flash('warning', trans('user.activate.already-activated'));
}
} catch (Cartalyst\Sentry\Users\UserNotFoundException $e) {
Session::flash('error', trans('user.activate.not-found'));
return Redirect::route('user.register');
}
return Redirect::route('home');
}