本文整理匯總了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');
}