Beispiel #1
0
 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')));
 }
Beispiel #2
0
 public static function instance()
 {
     if (self::$_instance === NULL) {
         self::$_instance = new self();
     }
     return self::$_instance;
 }
Beispiel #3
0
 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');
     }
 }