function perform()
{
// get request params
$company_id = $this->af->get('company_id');
$login_id = $this->af->get('login_id');
$password = $this->af->get('password');
$app_name = $this->config->get('app_name');
$company_cookei_key = $app_name . '_COMPANYCD';
$loginid_cookei_key = $app_name . '_LOGINID';
$expiretime = time() + 3600 * 24 * 30;
// パスワードをハッシュ化
$pwd_hash = md5($password);
$output = array();
try {
$login = new LoginController();
$params = array('company_id' => $company_id, 'login_id' => $login_id, 'password' => $pwd_hash);
// ユーザ状態をチェック
$code = $login->login($params);
if ($code >= 1) {
// 1 以上はエラー
// IP、会社コード、ログインID、パスワードをログに記録
$login_ip = getenv("REMOTE_ADDR");
$authErrorMsg = $code . '/' . $login_ip . '/' . $company_id . '/' . $login_id . '/' . $password;
$this->logger->log(LOG_INFO, 'Login failed: ' . $authErrorMsg);
return array(401);
}
// パスワード強制変更
// ログインのレスポンスとしては下記3項目
$output = array('password_forced_change_flg' => '', 'password_forced_change_msg' => '', 'password_forced_change_location' => '');
// 期限切れフラグチェック
if ($this->session->get('pwd_kigengire') == 1) {
// 期限切れなので、レスポンスに値を含める
$output['password_forced_change_flg'] = 1;
$output['password_forced_change_msg'] = Konst::ERR_MSG_LOGIN_PWD_FORCED_CHANGE_MSG;
$output['password_forced_change_location'] = Konst::ERR_MSG_LOGIN_PWD_FORCED_CHANGE_LOCATION;
} else {
// 期限は切れていないので、フラグは0
$output['password_forced_change_flg'] = 0;
}
$this->session->set('current_locale', $this->af->get('locale'));
setcookie($company_cookei_key, $company_id, $expiretime);
setcookie($loginid_cookei_key, $login_id, $expiretime);
return array('json', $output);
} catch (Exception $e) {
// 致命的なエラーが発生
$this->logger->log(LOG_DEBUG, $e->getTraceAsString());
return array(500, $e->getMessage());
}
exit;
}