essai fix bug connection
This commit is contained in:
parent
f611f4997c
commit
ac167feda5
application
@ -58,7 +58,7 @@ $autoload['packages'] = array();
|
||||
|
|
||||
| $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');
|
||||
}
|
||||
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('albums_list',['albums'=>$albums]);
|
||||
$this->load->view('albums_list', $data);
|
||||
$this->load->view('layout/footer');
|
||||
}
|
||||
|
||||
|
@ -43,36 +43,37 @@ class Connect extends CI_Controller {
|
||||
}
|
||||
|
||||
public function login()
|
||||
{
|
||||
$this->load->library('form_validation');
|
||||
$this->form_validation->set_rules('email', 'Email', 'required|valid_email');
|
||||
$this->form_validation->set_rules('password', 'Password', 'required');
|
||||
{
|
||||
$this->load->library('form_validation');
|
||||
$this->form_validation->set_rules('email', 'Email', 'required|valid_email');
|
||||
$this->form_validation->set_rules('password', 'Password', 'required');
|
||||
|
||||
if ($this->form_validation->run() === FALSE) {
|
||||
$this->load->view('layout/header');
|
||||
$this->load->view('login');
|
||||
$this->load->view('layout/footer');
|
||||
if ($this->form_validation->run() === FALSE) {
|
||||
$this->load->view('layout/header');
|
||||
$this->load->view('login');
|
||||
$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 {
|
||||
$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 {
|
||||
$data['error'] = 'Adresse email ou mot de passe incorrect';
|
||||
$this->load->view('layout/header');
|
||||
$this->load->view('login', $data);
|
||||
$this->load->view('layout/footer');
|
||||
}
|
||||
$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()
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user