| 17 | | // TODO: コード書くw |
| | 17 | var $dbUtil; |
| | 18 | |
| | 19 | function LoginCondition(&$db){ |
| | 20 | $this->dbUtil =& $db; |
| | 21 | } |
| | 22 | |
| | 23 | function condition($request){ |
| | 24 | if($request->isPost()){ |
| | 25 | if($request->getVariable('login') == ''){ |
| | 26 | ExceptionTrigger::raise(new RequireException(array(Message::_('name'))), 'user_mail'); |
| | 27 | } |
| | 28 | if($request->getVariable('password') == ''){ |
| | 29 | ExceptionTrigger::raise(new RequireException(array(Message::_('password'))), 'user_password'); |
| | 30 | } |
| | 31 | if(ExceptionTrigger::isException()){ |
| | 32 | return false; |
| | 33 | } |
| | 34 | |
| | 35 | $login = $request->getVariable('login'); |
| | 36 | if(strpos($login, '@') !== false){ |
| | 37 | $criterion = Q::eq(User::columnEMail(), $login); |
| | 38 | } else { |
| | 39 | $criterion = Q::eq(User::columnName(), $login); |
| | 40 | } |
| | 41 | $account = $this->dbUtil->get( |
| | 42 | new User(), |
| | 43 | new C( |
| | 44 | $criterion, |
| | 45 | Q::eq(User::columnPassword(), sha1($request->getVariable('password'))) |
| | 46 | ) |
| | 47 | ); |
| | 48 | if(Variable::istype('TableObjectBase', $account)){ |
| | 49 | RequestLogin::setLoginSession($account); |
| | 50 | return true; |
| | 51 | } |
| | 52 | } |
| | 53 | return false; |
| | 54 | } |
| | 55 | |
| | 56 | function _invalidForward($request){ |
| | 57 | $htmlParser = new HtmlParser(); |
| | 58 | $login = $request->getVariable("login"); |
| | 59 | |
| | 60 | $request->clearVariable("password","login","args"); |
| | 61 | $htmlParser->setVariable("requestvar",$request->getVariable()); |
| | 62 | $template = Rhaco::templatepath("login.html"); |
| | 63 | $htmlParser->write($template); |
| | 64 | Rhaco::end(); |
| | 65 | } |
| | 66 | // spell miss?? |
| | 67 | function _invalidForword($request){ |
| | 68 | return $this->_invalidForward($request); |
| | 69 | } |