Welcome Guest, Not a member yet? Register   Sign In
flexi auth - A user authentication library for CodeIgniter

[eluser]bunoire14[/eluser]
Hey,

Can anyone help me please! im tearing my hair out! :-D

I am working on a subscription website and have dropped in the Flexi Auth library to handle all my user management needs. I have created a relatively simple registration form and want to implement the reCaptcha library on it. I have managed to get the captcha box to show up on the form, no problems there, and it all seems to submit fine, but every time it submits It fails the captcha required validation.

I have checked the post data and it seems the captcha_response_field isn't being passed as part of the post data so Im wondering what im doing wrong?

I think its got to be something to do with the view... but ill post up my code anyway:

Model: auth/auth_model.php

Code:
$validation_rules = array(
   array('field' => 'register_first_name', 'label' => 'First Name', 'rules' => 'required'),
   array('field' => 'register_last_name', 'label' => 'Last Name', 'rules' => 'required'),
   array('field' => 'register_username', 'label' => 'Username', 'rules' => 'required|min_length[4]|identity_available'),
   array('field' => 'register_email', 'label' => 'Email Address', 'rules' => 'required|valid_email|identity_available'),
   array('field' => 'register_password', 'label' => 'Password', 'rules' => 'required|validate_password'),
   array('field' => 'register_confirm_password', 'label' => 'Confirm Password', 'rules' => 'required|matches[register_password]'),
   array('field' => 'recaptcha_response_field', 'label' => 'Captcha Answer', 'rules' =>'required|validate_recaptcha')
  );
  
  $this->form_validation->set_rules($validation_rules);

Controller: register/register.php

Code:
// Redirect user away from registration page if already logged in.
  if ($this->flexi_auth->is_logged_in())
  {
   redirect('dashboard');
  }
  // If 'Registration' form has been submitted, attempt to register their details as a new account.
  else if ($this->input->post('register_user'))
  {  
   $this->auth_model->register_account();

  }
  

  // Get any status message that may have been set.
  $this->data['message'] = (! isset($this->data['message'])) ? $this->session->flashdata('message') : $this->data['message'];  
  //send recaptcha info
  $this->data['captcha'] = $this->flexi_auth->recaptcha(FALSE);
  //Load the Selected Layout.
  $this->load->view('registration/registration_form', $this->data);

View: registration/registration_form

Code:
<?php echo $this->load->view('global/html_head'); ?>

<div class="span12">
<h1>Registration</h1>
<p>Please fill out the form to register on our system.</p>

<hr />
&lt;?php if (! empty($message) ) {
  echo '
  <div id="messages">
   '.$message.'
  </div>';


  }
  ?&gt;  
</div>

<div class="span6">
&lt;?php

echo form_open(current_url(), 'class="form-horizontal"');
echo form_fieldset('User Information');

  echo '<div class="control-group">';
  echo form_label('First Name', 'register_first_name', array('class' => 'control-label'));
  echo '<div class="controls">';
  echo form_input('register_first_name', set_value('register_first_name'), 'id="register_first_name"');
  echo '</div></div>';

  echo '<div class="control-group">';
  echo form_label('Last Name', 'register_last_name', array('class' => 'control-label'));
  echo '<div class="controls">';
  echo form_input('register_last_name', set_value('register_last_name'), 'id="register_last_name"');
  echo '</div></div>';

  echo '<div class="control-group">';
  echo form_label('Username', 'register_username', array('class' => 'control-label'));
  echo '<div class="controls">';
  echo form_input('register_username', set_value('register_username'), 'id="register_username"');
  echo '</div></div>';

  echo '<div class="control-group">';
  echo form_label('Email', 'register_email', array('class' => 'control-label'));
  echo '<div class="controls">';
  echo form_input('register_email', set_value('register_email'), 'id="register_email"');
  echo '</div></div>';

  echo '<div class="control-group">';
  echo form_label('Choose Password', 'register_password', array('class' => 'control-label'));
  echo '<div class="controls">';
  echo form_password('register_password', '', 'id="register_password"');
  echo '</div></div>';

  echo '<div class="control-group">';
  echo form_label('Confirm Password', 'register_confrim_password', array('class' => 'control-label'));
  echo '<div class="controls">';
  echo form_password('register_confirm_password', '', 'id="register_confirm_password"');
  echo '</div></div>';

echo form_fieldset_close();
?&gt;
</div>

<div class="span6">
&lt;?php
  if (isset($captcha))
  {
   echo form_fieldset('reCaptcha - Lets Stop Spam!');
   echo $captcha;
   echo form_fieldset_close();
  }
?&gt;
</div>
<div class="span12">
&lt;?php
echo form_submit('register_user', 'Register', 'class="btn btn-primary"');
echo form_close();
?&gt;
</div>

&lt;?php echo $this->load->view('global/html_footer'); ?&gt;

Any pointers on this would be great, I'm sure I'm missing something simple... but you know how it is sometimes you just cant see it for looking!

Thanks in advance!




[eluser]bunoire14[/eluser]
OK Figured it out.... funny old thing id didn't like me splitting the form into separate <div>'s..... school boy error! All working now

[eluser]devha[/eluser]
With default configuration, flexi auth allows only limited set of characters for password ( regex '\.\,\-_ a-z0-9' ).

Is there any reason why I should limit valid characters to this so small set? As password is not stored to database as such, there is no risk of sql injection etc?

Any example how to allow more wider set of characters for password, like !, @, % etc... Can i just set: $config['security']['valid_password_chars'] = '.';

[eluser]Unknown[/eluser]
Hi, I'm using the library flexi_auth with another call HMVC and I have the following problem.
I made a module called Auth, and the folder structure is as follows.
- application
+ controlllers
+ models
- modules
- Auth
- controllers
- auth.php
- libraries
- Flexi_auth.php
- Flexi_auth_lite.php
+ models
+ views
+ views

when I load the library in auth.php controller $this->load->library('auth/flexi_auth') the browser shows me this error "Unable to locate the specified class: Flexi_auth_lite.php".
I tried to locate the library in application/libraries and works well, but I need to working within the modules folder. Any idea why this error.?
Also tried other libraries within modules and work well.

[eluser]hyperfire[/eluser]
I'm having some trouble logging in with flexiauth installed on subdomains.

While on localhost or main domain, flexiauth works fine, but for some reason, whenever I login on a subdomain, I get the login true on the login page if I debug, but as soon as I redirect user after login to another controller, this child controller don't find the login info and kicks the user back to login page.

Let me be clear:
my.domain.com/login
$this->flexi_auth->is_logged_in() // returns true after login on login page (debugging)

my.domain.com/dashboard
$this->flexi_auth->is_logged_in() // returns false after login


Am I doing anything wrong?

I'm trying to debug it right now, as I believe it to be a issue with cookies & subdomains, but I donno yet! thanks!!


EDIT:
Ok, got it working in 3 steps:

1) edit config.php > $config['cookie_domain'] = '.domain.com'; // have to set .domain for sitewide cookies

2) clear browser cookies

3) login

Cheers!!

[eluser]Unknown[/eluser]
Hello guys

I just started using Flexi Auth as my main user management library. It is great! So thank you very much haseydesign.

I found an error that I managed to fix and wanted to share with you guys.

When loading the flexi_auth_model I got a 500 server error! I looked into the code and noticed that the class extends flexi_auth_lite_model which was not loaded. I managed to fix that by adding the following code to the top of the flexi_auth_model file.

right before:
class Flexi_auth_model extends Flexi_auth_lite_model {

Add:
load_class('Flexi_auth_lite_model', 'models', FALSE);

That's it. Have fun!

[eluser]Unknown[/eluser]
Hello!

Is it possible to change the user's group?

I've tried this without success:

Code:
public function set_user_group($groupID){
        // Get group details
        $query = $this->db->get_where("user_groups",array("ugrp_id"=>$groupID));
        $row = $query->row();
        // Set session data
        $this->auth->session_data[$this->auth->session_name['group']] = array($row->ugrp_id=>$row->ugrp_name);
        // Update database
        $this->db->where("uacc_id",$this->flexi_auth->get_user_id());
        $this->db->update("user_accounts",array("uacc_group_fk" => 1));
        // Gives new group ID
        // echo $this->flexi_auth->get_user_group_id();
       redirect("test");
}
public function test(){
        // Gives old group ID
        echo $this->flexi_auth->get_user_group_id();
}

[eluser]mautone[/eluser]
Hi there.

I've just started using Flexi auth.
I like the features very much and, decided to use it for my next big project. An ERP system for my self.

I have a big problem with the login part.
I get these warnings everytime i try to login:
Quote:A PHP Error was encountered

Severity: Notice

Message: Trying to get property of non-object

Filename: models/flexi_auth_model.php

Line Number: 1770

A PHP Error was encountered

Severity: Notice

Message: Trying to get property of non-object

Filename: models/flexi_auth_model.php

Line Number: 1773

A PHP Error was encountered

Severity: Notice

Message: Trying to get property of non-object

Filename: models/flexi_auth_model.php

Line Number: 1773

A PHP Error was encountered

Severity: Warning

Message: Cannot modify header information - headers already sent by (output started at /Applications/MAMP/htdocs/mpanel/system/core/Exceptions.php:185)

Filename: libraries/Session.php

Line Number: 675
My controller:
Code:
class Auth extends CI_Controller{
function __construct(){
  parent::__construct();
  $this->auth = new stdClass;
  
  // Load 'standard' flexi auth library by default.
  $this->load->library('flexi_auth');
}

public function index(){
  
  if($this->flexi_auth->login($this->input->post('username'), $this->input->post('password'))){
   echo "Logget ind";
  } else {
   $this->load->view('login');
  }
  
}

public function logout(){
  $this->flexi_auth->logout(TRUE);
  $this->index();
}
}

My view:
Code:
<h1>Login</h1>
&lt;?php
echo form_open('auth/index');
echo form_input('username');
echo form_input('password');
echo form_submit('submit', 'Submit');
echo form_close();

I just want to get to familiar with it before I implementing in the design.

Can anyone help me?


SOLVED.
It needs some data in certen tables.

[eluser]Unknown[/eluser]
I am rebuilding a site using CI and the flexi auth library. I moved all the user information into the appropriate tables but my issue is that all my user's passwords are already hashed using md5. So when I try to login, I am getting incorrect credentials error.

Anyway to make the system check against md5 only?

[eluser]Unknown[/eluser]
Hi..
I’d started to know with your library and i like it a lot .
but i have a problem , i designed my user table schema before know about your library , so now how can i merge these 2 database and change all columns name in library ?!

is that possible ?!




Theme © iAndrew 2016 - Forum software by © MyBB