本文整理匯總了PHP中bizley\podium\models\User::generateAuthKey方法的典型用法代碼示例。如果您正苦於以下問題:PHP User::generateAuthKey方法的具體用法?PHP User::generateAuthKey怎麽用?PHP User::generateAuthKey使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類bizley\podium\models\User
的用法示例。
在下文中一共展示了User::generateAuthKey方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: _addAdmin
/**
* Adds Administrator account.
* @return string result message.
*/
protected function _addAdmin()
{
try {
$podium = PodiumModule::getInstance();
if ($podium->userComponent == PodiumModule::USER_INHERIT) {
if (!empty($podium->adminId)) {
$this->authManager->assign($this->authManager->getRole('podiumAdmin'), $podium->adminId);
return $this->outputSuccess(Yii::t('podium/flash', Messages::ADMINISTRATOR_PRIVILEGES_SET, ['id' => $podium->adminId]));
} else {
return $this->outputWarning(Yii::t('podium/flash', Messages::NO_ADMINISTRATOR_PRIVILEGES_SET));
}
} else {
$admin = new User();
$admin->setScenario('installation');
$admin->username = self::DEFAULT_USERNAME;
$admin->email = self::DEFAULT_USER_EMAIL;
$admin->status = User::STATUS_ACTIVE;
$admin->role = User::ROLE_ADMIN;
$admin->generateAuthKey();
$admin->setPassword(self::DEFAULT_USERNAME);
if ($admin->save()) {
$this->authManager->assign($this->authManager->getRole('podiumAdmin'), $admin->getId());
return $this->outputSuccess(Yii::t('podium/flash', Messages::ADMINISTRATOR_ACCOUNT_CREATED) . ' ' . Html::tag('strong', Yii::t('podium/flash', 'Login') . ':') . ' ' . Html::tag('kbd', self::DEFAULT_USERNAME) . ' ' . Html::tag('strong', Yii::t('podium/flash', 'Password') . ':') . ' ' . Html::tag('kbd', self::DEFAULT_USERNAME));
} else {
$this->setError(true);
return $this->outputDanger(Yii::t('podium/flash', Messages::ACCOUNT_CREATING_ERROR) . ': ' . Html::tag('pre', VarDumper::dumpAsString($admin->getErrors())));
}
}
} catch (Exception $e) {
Yii::error([$e->getName(), $e->getMessage()], __METHOD__);
$this->setError(true);
return $this->outputDanger(Yii::t('podium/flash', Messages::ACCOUNT_CREATING_ERROR) . ': ' . Html::tag('pre', $e->getMessage()));
}
}
示例2: _addAdmin
/**
* Adds Administrator account.
* @return string result message.
*/
protected function _addAdmin()
{
try {
$podium = PodiumModule::getInstance();
if ($podium->userComponent == PodiumModule::USER_INHERIT) {
if (!empty($podium->adminId)) {
$admin = new User();
$admin->setScenario('installation');
$admin->inherited_id = $podium->adminId;
$admin->username = self::DEFAULT_USERNAME;
$admin->status = User::STATUS_ACTIVE;
$admin->role = User::ROLE_ADMIN;
$admin->timezone = User::DEFAULT_TIMEZONE;
if ($admin->save()) {
$this->authManager->assign($this->authManager->getRole(Rbac::ROLE_ADMIN), $podium->adminId);
return $this->outputSuccess(Yii::t('podium/flash', 'Administrator privileges have been set for the user of ID {id}.', ['id' => $podium->adminId]));
} else {
$this->setError(true);
return $this->outputDanger(Yii::t('podium/flash', 'Error during account creating') . ': ' . Html::tag('pre', VarDumper::dumpAsString($admin->getErrors())));
}
} else {
return $this->outputWarning(Yii::t('podium/flash', 'No administrator privileges have been set.'));
}
} else {
$admin = new User();
$admin->setScenario('installation');
$admin->username = self::DEFAULT_USERNAME;
$admin->status = User::STATUS_ACTIVE;
$admin->role = User::ROLE_ADMIN;
$admin->timezone = User::DEFAULT_TIMEZONE;
$admin->generateAuthKey();
$admin->setPassword(self::DEFAULT_USERNAME);
if ($admin->save()) {
$this->authManager->assign($this->authManager->getRole(Rbac::ROLE_ADMIN), $admin->getId());
return $this->outputSuccess(Yii::t('podium/flash', 'Administrator account has been created.') . ' ' . Html::tag('strong', Yii::t('podium/flash', 'Login') . ':') . ' ' . Html::tag('kbd', self::DEFAULT_USERNAME) . ' ' . Html::tag('strong', Yii::t('podium/flash', 'Password') . ':') . ' ' . Html::tag('kbd', self::DEFAULT_USERNAME));
} else {
$this->setError(true);
return $this->outputDanger(Yii::t('podium/flash', 'Error during account creating') . ': ' . Html::tag('pre', VarDumper::dumpAsString($admin->getErrors())));
}
}
} catch (Exception $e) {
Yii::error([$e->getName(), $e->getMessage()], __METHOD__);
$this->setError(true);
return $this->outputDanger(Yii::t('podium/flash', 'Error during account creating') . ': ' . Html::tag('pre', $e->getMessage()));
}
}