Skip to content
Snippets Groups Projects
Sign.php 3.24 KiB
Newer Older
<?php defined('SYSPATH') or die('No direct script access.');

class Controller_Handler_Sign extends Controller_Handler {
        
        public function before() {
            $this->setAccessLevel(self::ACCESS_GUEST);
            parent::before();
        }

        public function action_in()
        {
            $this->post->rule('login', 'email')->rule('login', 'not_empty');
            $checklogin = true; $response['success'] = false;
            if(!$this->post->check())
                $this->post = Validation::factory($this->post->as_array());
                $this->post->rule('login', 'alpha_dash')->rule('login', 'not_empty');
                if(!$this->post->check())
                {
                    // Данные не безопасны, даже не пытаемся авторизоваться
                    $checklogin = false;
                }
        public function action_up()
        {
            $config = Kohana::$config->load('security.securityPolicy');
            $response['success'] = false;
                ->rule('login', 'not_empty')
                ->rule('password', 'min_length', array(':value', $config['password']['length']))
                ->rule('confirm_password', 'matches', array(':validation', 'confirm_password', 'password'))
                ->rule('email', 'not_empty')
Anton's avatar
Anton committed
                ->rule('email', 'email')
                ->rule('confirm_email', 'matches', array(':validation', 'confirm_email', 'email')); 
                        ->signUp($this->post->offsetGet('activation_code'),
                                $this->post->offsetGet('email'),
                                $this->post->offsetGet('login'),
                                $this->post->offsetGet('password'));
                if(!$response['success'])
                        case 'login_exists':
                            $this->post->error('login', 'already_exists');
                        break;
                        case 'mail_exists':
                            $this->post->error('email', 'already_exists');
                        break;
                        case 'invalid_code':
                            $this->post->error('activation_code', 'invalid_code');
                        break;
                    }
                }
            }
            if(!$response['success'])
            {
                $response['errors'] = $this->post->errors ('signin');
            }
            $this->response->body(json_encode($response));
        }        
        
        public function action_remindpass()
        {
            
        }        

        
}