Welcome Guest, Not a member yet? Register   Sign In
Erkanaauth and user authentication
#1

[eluser]Unknown[/eluser]
Hi, I know I shouldn 't run before I work but even with very little CI knowledge and not much better php know how I have a admin with the ability to email a newsletter, modify pages and add subscribers. The only bit which is causing me issue is getting the admini authentication working.

I'm using the library from Erkana: http://www.michaelwales.com/2007/10/erka...n-library/. The form submits but nothing is happening. I know its doing the first function "check_username" but not sure if its doing the second. My controller code is below:

Code:
function check_username() {
      $this->load->library('validation');
      // Validation Rules and Fields
      if ($this->validation->run()) {
        redirect('admin/home');
      } else {
        $data['title'] = "Admin Home";
        $data['body'] = "<p>Please enter your username and password below.</p>";        
        $data['error'] = "<p><strong>Error</strong></p>";            
        $this->load->view('cms', $data);
      }
    }

    function _check_login($username,$password) {
      $this->load->helper('security');
        $username = $this->input->post('username');
        $password = dohash($this->input->post('password'));
      if ($this->erkanaauth->try_login(array('username' => $username, 'password' => $password))) {
        return TRUE;
      } else {
        $this->validation->set_message('_check_login', 'Incorrect login info.');        
        return FALSE;
      }
    }

and view

Code:
&lt;?php
    echo form_open('cms/check_username/');
    echo form_fieldset();
    
    //echo form_label('ID:', 'id');
    //echo form_input('id','');
    
    echo form_label('Username:', 'username');
    echo form_input('username','');

    echo form_label('Password:', 'password');
    echo form_password('password','');
    
    echo form_fieldset_close();
    ?&gt;    
    <button value="Submit Post" name="mysubmit" type="submit">Submit</button>
    &lt;?
    echo form_close('');
    ?&gt;

Apologies if its something basic but any guidance would be appreciated.

TIA,
Darren
#2

[eluser]Ebot Ndip-Agbor[/eluser]
Never used ErkanaAuth before, but looking at your code I have a question.
Quote:
Code:
function _check_login($username,$password) {
      $this->load->helper('security');
        $username = $this->input->post('username');
        $password = dohash($this->input->post('password'));
      if ($this->erkanaauth->try_login(array('username' => $username, 'password' => $password))) {
        return TRUE;
      } else {
        $this->validation->set_message('_check_login', 'Incorrect login info.');        
        return FALSE;
      }
    }

If this is one of your controller functions. Then why will you return true
Code:
if ($this->erkanaauth->try_login(array('username' => $username, 'password' => $password))) {
        return TRUE;
if the input is valid? I think what you should do is direct the user to the admin page or something.




Theme © iAndrew 2016 - Forum software by © MyBB