Ticket #499: swt_auth_demo_controller.patch

File swt_auth_demo_controller.patch, 1.3 kB (added by Stalwart, 10 months ago)

controller patch

  • .php

    old new  
    3727        { 
    3828                $form = new Forge(NULL, 'Create User'); 
    3929 
    40                 $form->input('email')->label(TRUE)->rules('required|length[4,32]'); 
     30                $form->input('email')->label(TRUE)->rules('required|valid_email'); 
    4131                $form->input('username')->label(TRUE)->rules('required|length[4,32]'); 
    4232                $form->password('password')->label(TRUE)->rules('required|length[5,40]'); 
    4333                $form->submit('Create New User'); 
     
    4737                        // Create new user 
    4838                        $user = new User_Model; 
    4939 
    50                         if ( ! $user->username_exists($this->input->post('username'))) 
     40                        if ( ! $user->username_exists($this->input->post('username')) 
     41                                AND ! $user->email_exists($this->input->post('email'))) 
    5142                        { 
    5243                                foreach($form->as_array() as $key => $val) 
    5344                                { 
     
    5748 
    5849                                if ($user->save() AND $user->add_role('login')) 
    5950                                { 
     51                                        // Log in created user 
     52                                        $this->auth->login($user, $this->input->post('password')); 
     53                                         
    6054                                        // Redirect to the login page 
    6155                                        url::redirect('auth/login'); 
    6256                                }