essai fix bug connection
This commit is contained in:
		@@ -58,7 +58,7 @@ $autoload['packages'] = array();
 | 
				
			|||||||
|
 | 
					|
 | 
				
			||||||
|	$autoload['libraries'] = array('user_agent' => 'ua');
 | 
					|	$autoload['libraries'] = array('user_agent' => 'ua');
 | 
				
			||||||
*/
 | 
					*/
 | 
				
			||||||
$autoload['libraries'] = array('session');
 | 
					$autoload['libraries'] = array('database','session','form_validation');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/*
 | 
					/*
 | 
				
			||||||
| -------------------------------------------------------------------
 | 
					| -------------------------------------------------------------------
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -9,9 +9,14 @@ class Albums extends CI_Controller {
 | 
				
			|||||||
		$this->load->library('session');
 | 
							$this->load->library('session');
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	public function index(){
 | 
						public function index(){
 | 
				
			||||||
		$albums = $this->model_music->getAlbums();
 | 
							$albums = $this->model_music->getAlbums();	
 | 
				
			||||||
 | 
							$is_logged_in = $this->session->userdata('logged_in');
 | 
				
			||||||
 | 
							$data = array(
 | 
				
			||||||
 | 
					            'albums' => $albums,
 | 
				
			||||||
 | 
					            'is_logged_in' => $is_logged_in
 | 
				
			||||||
 | 
					        );
 | 
				
			||||||
		$this->load->view('layout/header');
 | 
							$this->load->view('layout/header');
 | 
				
			||||||
		$this->load->view('albums_list',['albums'=>$albums]);
 | 
							$this->load->view('albums_list', $data);
 | 
				
			||||||
		$this->load->view('layout/footer');
 | 
							$this->load->view('layout/footer');
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -43,36 +43,37 @@ class Connect extends CI_Controller {
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public function login()
 | 
					    public function login()
 | 
				
			||||||
    {
 | 
					{
 | 
				
			||||||
        $this->load->library('form_validation');
 | 
					    $this->load->library('form_validation');
 | 
				
			||||||
        $this->form_validation->set_rules('email', 'Email', 'required|valid_email');
 | 
					    $this->form_validation->set_rules('email', 'Email', 'required|valid_email');
 | 
				
			||||||
        $this->form_validation->set_rules('password', 'Password', 'required');
 | 
					    $this->form_validation->set_rules('password', 'Password', 'required');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if ($this->form_validation->run() === FALSE) {
 | 
					    if ($this->form_validation->run() === FALSE) {
 | 
				
			||||||
            $this->load->view('layout/header');
 | 
					        $this->load->view('layout/header');
 | 
				
			||||||
            $this->load->view('login');
 | 
					        $this->load->view('login');
 | 
				
			||||||
            $this->load->view('layout/footer');
 | 
					        $this->load->view('layout/footer');
 | 
				
			||||||
 | 
					    } else {
 | 
				
			||||||
 | 
					        $email = $this->input->post('email');
 | 
				
			||||||
 | 
					        $password = $this->input->post('password');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $user = $this->User_model->get_user_by_email($email);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if ($user && password_verify($password, $user['password'])) {
 | 
				
			||||||
 | 
					            $this->session->set_userdata([
 | 
				
			||||||
 | 
					                'user_id' => $user['id'],
 | 
				
			||||||
 | 
					                'email' => $user['email'],
 | 
				
			||||||
 | 
					                'logged_in' => TRUE
 | 
				
			||||||
 | 
					            ]);
 | 
				
			||||||
 | 
					            redirect('albums/index');
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
            $email = $this->input->post('email');
 | 
					            $data['error'] = 'Adresse email ou mot de passe incorrect';
 | 
				
			||||||
            $password = $this->input->post('password');
 | 
					            $this->load->view('layout/header');
 | 
				
			||||||
 | 
					            $this->load->view('login', $data);
 | 
				
			||||||
            $user = $this->User_model->get_user_by_email($email);
 | 
					            $this->load->view('layout/footer');
 | 
				
			||||||
 | 
					 | 
				
			||||||
            if ($user && password_verify($password, $user['password'])) {
 | 
					 | 
				
			||||||
                $this->session->set_userdata([
 | 
					 | 
				
			||||||
                    'user_id' => $user['id'],
 | 
					 | 
				
			||||||
                    'email' => $user['email'],
 | 
					 | 
				
			||||||
                    'logged_in' => TRUE
 | 
					 | 
				
			||||||
                ]);
 | 
					 | 
				
			||||||
                redirect('albums/index');
 | 
					 | 
				
			||||||
            } else {
 | 
					 | 
				
			||||||
                $data['error'] = 'Adresse email ou mot de passe incorrect';
 | 
					 | 
				
			||||||
                $this->load->view('layout/header');
 | 
					 | 
				
			||||||
                $this->load->view('login', $data);
 | 
					 | 
				
			||||||
                $this->load->view('layout/footer');
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public function logout()
 | 
					    public function logout()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user