本文整理汇总了PHP中CApi::AddSecret方法的典型用法代码示例。如果您正苦于以下问题:PHP CApi::AddSecret方法的具体用法?PHP CApi::AddSecret怎么用?PHP CApi::AddSecret使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CApi
的用法示例。
在下文中一共展示了CApi::AddSecret方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: loginToAccount
/**
* @param string $sEmail
* @param string $sIncPassword
* @param string $sIncLogin Default value is empty string.
* @param string $sLanguage Default value is empty string.
*
* @throws CApiManagerException(Errs::WebMailManager_AccountDisabled) 1501
* @throws CApiManagerException(Errs::Mail_AccountAuthentication) 4002
* @throws CApiManagerException(Errs::WebMailManager_AccountCreateOnLogin) 1503
*
* @return CAccount|null|bool
*/
public function loginToAccount($sEmail, $sIncPassword, $sIncLogin = '', $sLanguage = '')
{
$oResult = null;
\CApi::AddSecret($sIncPassword);
/* @var $oApiUsersManager CApiUsersManager */
$oApiUsersManager = CApi::GetSystemManager('users');
$bAuthResult = false;
$oAccount = $oApiUsersManager->getAccountByEmail($sEmail);
if ($oAccount instanceof CAccount) {
if ($oAccount->IsDisabled || $oAccount->Domain && $oAccount->Domain->IsDisabled) {
throw new CApiManagerException(Errs::WebMailManager_AccountDisabled);
}
if (0 < $oAccount->IdTenant) {
$oApiTenantsManager = CApi::GetSystemManager('tenants');
if ($oApiTenantsManager) {
$oTenant = $oApiTenantsManager->getTenantById($oAccount->IdTenant);
if ($oTenant && ($oTenant->IsDisabled || 0 < $oTenant->Expared && $oTenant->Expared < \time())) {
throw new CApiManagerException(Errs::WebMailManager_AccountDisabled);
}
}
}
if (0 < strlen($sLanguage) && $sLanguage !== $oAccount->User->DefaultLanguage) {
$oAccount->User->DefaultLanguage = $sLanguage;
}
if ($oAccount->Domain->AllowWebMail && $oAccount->AllowMail) {
if ($sIncPassword !== $oAccount->IncomingMailPassword) {
$oAccount->IncomingMailPassword = $sIncPassword;
}
try {
\CApi::ExecuteMethod('Mail::ValidateAccountConnection', array('Account' => $oAccount));
} catch (Exception $oException) {
throw $oException;
}
} else {
if ($sIncPassword !== $oAccount->IncomingMailPassword) {
throw new CApiManagerException(Errs::Mail_AccountAuthentication);
}
}
$sObsoleteIncPassword = $oAccount->GetObsoleteValue('IncomingMailPassword');
$sObsoleteLanguage = $oAccount->User->GetObsoleteValue('DefaultLanguage');
if (null !== $sObsoleteIncPassword && $sObsoleteIncPassword !== $oAccount->IncomingMailPassword || null !== $sObsoleteLanguage && $sObsoleteLanguage !== $oAccount->User->DefaultLanguage || $oAccount->ForceSaveOnLogin) {
$oApiUsersManager->updateAccount($oAccount);
}
$oApiUsersManager->updateAccountLastLoginAndCount($oAccount->IdUser);
$oResult = $oAccount;
} else {
if (null === $oAccount) {
$aExtValues = array();
if (0 < strlen($sIncLogin)) {
$aExtValues['Login'] = $sIncLogin;
}
$aExtValues['ApiIntegratorLoginToAccountResult'] = $bAuthResult;
$oAccount = \CApi::ExecuteMethod('Core::CreateAccount', array('Email' => $sEmail, 'Password' => $sIncPassword, 'Language' => $sLanguage, 'ExtValues' => $aExtValues));
if ($oAccount instanceof CAccount) {
$oResult = $oAccount;
} else {
throw new CApiManagerException(Errs::WebMailManager_AccountCreateOnLogin);
}
} else {
$oException = $oApiUsersManager->GetLastException();
throw is_object($oException) ? $oException : new CApiManagerException(Errs::WebMailManager_AccountCreateOnLogin);
}
}
return $oResult;
}