Welcome Guest, Not a member yet? Register   Sign In
Erkana Auth - Private Function (utility?)
#1

[eluser]lkoreality[/eluser]
I'm trying to get erkana auth to work. I don't understand how to check login.. or use private functions "_function()". I get the error "Undefined function" with this.

At this point, I have the validation working. I have a database called "users", but have yet to add any data. This will just be for admin login (one user).

This is what I have so far:

Code:
<?php

class Admin extends Controller {

    function Admin()
    {
        parent::Controller();    
        
    $this->load->helper(array('form', 'url'));
    $this->load->library('form_validation');
    $this->load->library('erkanaauth');
    
    }
    
    function index() {
    // check if currently logged in - if not, go to login
        if (!$this->erkanaauth->try_session_login()) {
        redirect('admin/login');
        } else {
            echo "Admin Area";
        }  
    }
    
    function _check_login($email) {
    // check login
        $this->load->helper('security');
        $password = dohash($this->input->post('password'));
        
        if ($this->erkanaauth->try_login(array('email'=>$email, 'password'=>$password))) {
            return TRUE;
        } else {
            $this->validation->set_message('_check_login', 'Incorrect login info.');
            return FALSE;
        }
    }
        
    function login() {
    // login form - if invalid, show form - if valid, check login first - if login valid, go to Admin Area
        //Validation Rules    
        $this->form_validation->set_rules('email', 'Email', 'trim|required|valid_email');
        $this->form_validation->set_rules('password', 'Password', 'trim|required|md5');
        
        if ($this->form_validation->run() == FALSE) {
        
        $this->load->view('form');
        
        } else {
        
            $email = $this->input->post('email');
            if(_check_login($email)) {
                echo "Admin Area!";
            } else {
                $this->load->view('form');
            }
        
        }
    }
}

/* End of file admin.php */
/* Location: ./system/application/controllers/admin.php */
#2

[eluser]Unknown[/eluser]
Don't forget that you are in a class and that you are calling a method within the class.
Code:
if($this->_check_login($email)) {




Theme © iAndrew 2016 - Forum software by © MyBB