Welcome Guest, Not a member yet? Register   Sign In
Community Auth for mobile login
#4

You are correct, I do not using CI to display webpage content, just a json response. From within the app I can create a POST, identical in many ways to a form post, then the app creates the UI based upon the json response from CI.

Since Community Auth routes login attempts back to the html login page I could not figure a way to override this process without affecting the normal html login.

To get around this I manually implemented parts of your Authentication.php library into a mobile controller. The login function runs the standard CI form validation and then performs the authentication functions:

Code:
$response = array(
"success" => 0,
"message" => 'Test Response');
                
$this->load->model('Auth_model');
$login_string     = $this->input->post('login_string');
$login_pass   = $this->input->post('login_pass');
/**
* Validate the posted username / email address and password.
*/
$this->load->library('form_validation');
$this->config->load( 'form_validation/auth/login' );
$this->form_validation->set_rules( config_item('login_rules') );
if( $this->form_validation->run() !== FALSE )
{

// Get user table data if username or email address matches a record
if( $auth_data = $this->auth_model->get_auth_data( $login_string ) )
{
// Confirm user
if( ! $this->_user_confirmed( $auth_data, 1, $login_pass ) )
{
$json_response["message"] = "Login failed! Incorrect username or password";


Now I need to see if I can maintain a login while accessing controller functions that uses something like:

if( $this->require_min_level(1) )

It is indeed a hack, while I ponder a better solution.

BTW: I have a control version of Community Auth for CI3 under evaluation for the next major revision of this CI Project.

Thanks for alacrity in responding to my question.
Reply


Messages In This Thread
Community Auth for mobile login - by escaperadius - 01-23-2016, 09:56 AM
RE: Community Auth for mobile login - by skunkbad - 01-23-2016, 12:08 PM
RE: Community Auth for mobile login - by skunkbad - 01-23-2016, 06:44 PM
RE: Community Auth for mobile login - by escaperadius - 01-23-2016, 07:21 PM
RE: Community Auth for mobile login - by skunkbad - 01-23-2016, 09:45 PM
RE: Community Auth for mobile login - by skunkbad - 01-24-2016, 10:10 AM



Theme © iAndrew 2016 - Forum software by © MyBB