public function action_register() { $this->auto_render = FALSE; if ($this->request->is_ajax()) { $post = $this->request->post(); $ret = Tool_SMS::instance()->verifyEventSMSCode($post['mobile'], $post['code'], 'register'); if ($ret === TRUE) { $user = ORM::factory('user'); $user->username = $post['username']; $user->mobile = $post['mobile']; $user->password = $post['password']; $user->created = time(); $user->updated = time(); try { $user->save(); jsonReturn(1001, '/login'); } catch (ORM_Validation_Exception $e) { foreach ($e->errors('models') as $v) { jsonReturn(4444, $v); } } } else { jsonReturn($ret); } } $this->response->body(View::factory($this->theme . 'register', array('loginUrl' => '/login'))); }
public function action_sms() { if ($this->request->is_ajax()) { $channel = $this->request->post('channel'); $mobile = $this->request->post('mobile'); $ret = Tool_SMS::instance()->sendEventSMS($mobile, $channel); if ($ret === TRUE) { jsonReturn(1001, '验证码发送成功'); } else { jsonReturn($ret); } } else { $this->redirect('/404'); } }