Welcome Guest, Not a member yet? Register   Sign In
Ion Auth - Lightweight Auth System based on Redux Auth 2

[eluser]JonoB[/eluser]
in the example controller, there is a function change_password.

If the action is successful, then some flashdata is set, and the logout function is called.

Code:
if ($change)
{ //if the password was successfully changed
    $this->session->set_flashdata('message', $this->ion_auth->messages());
    $this->logout();
}

Code:
function logout()
{
    $this->data['title'] = "Logout";

    //log the user out
    $logout = $this->ion_auth->logout();

    //redirect them back to the page they came from
    redirect('auth', 'refresh');
}

$this->ion_auth->logout(), amongst other things calls

Code:
$this->ci->session->sess_destroy();

This means, that once the redirect in the auth/logout function happens, the flashdata will be lost.

Is there any point in setting flash data in auth/change_password?

[eluser]roark[/eluser]
Hi Ben,

Great 'plugin' thanks for the great work!

Regarding the flashdata/messaging/errors implementation, what do you think about setting the message type i.e.
Code:
$this->data['message'] = array('type'=>'error','details'=>(validation_errors()) ? validation_errors() : $this->session->flashdata('message'));
And...
Code:
$this->session->set_flashdata('message', array('type'=>'success','details'=>$this->ion_auth->messages()));

This will allow us to style the front-end depening on the message type...

Code:
<?php if (!empty($message['details'])): ?>
    <div class="message &lt;?=$message['type']?&gt;">
        &lt;?php if(is_array($message['details'])):?&gt;
        <ul>
            &lt;?php foreach($message['details'] AS $error): ?&gt;
            <li>&lt;?=$error?&gt;</li>
            &lt;?php endforeach;?&gt;
        </ul>
        &lt;?php else: ?&gt;
        &lt;?=$message['details']?&gt;
        &lt;?php endif; ?&gt;
    </div>
    &lt;?php endif;?&gt;

It may not be the ideal way to handle this, but I've implemented it successfully in one of my projects.

Thanks again!

[eluser]malcomhfc[/eluser]
Nice idea roark Smile

May come in handy for some people, me included. Smile

[eluser]DephNet[Paul][/eluser]
Hi Guys,

After spending a few days trying to write my own authentication library, I have decided that I would rather use a library that has constant updates to it and Ion Auth looks like it will fit my needs.

I do however have a few questions before I commit to using Ion Auth so here goes, Sorry if these have been asked, and answered, elsewhere I spent a few hours searching the forums and could not find any answers.

1) Am I able to set certain pages to be accessible to everyone, and certain pages to be "members only", or does this put the entire site behind a login box?
2) Am I able to style the pages myself? I assume I can by simply editing the views.
3) How extensible is this? For example, if I wanted to interface with WHMCS, to auto generate login details, am I able to do that?
4) Is a "git pull" the only way of keeping upto date with Ion Auth, or does Ben release "stable" versions of Ion Auth regularly?

Many thanks for your help
--Paul

[eluser]JonoB[/eluser]
[quote author="DephNet[Paul]" date="1307303237"]Hi Guys,

After spending a few days trying to write my own authentication library, I have decided that I would rather use a library that has constant updates to it and Ion Auth looks like it will fit my needs.

I do however have a few questions before I commit to using Ion Auth so here goes, Sorry if these have been asked, and answered, elsewhere I spent a few hours searching the forums and could not find any answers.

1) Am I able to set certain pages to be accessible to everyone, and certain pages to be "members only", or does this put the entire site behind a login box?
2) Am I able to style the pages myself? I assume I can by simply editing the views.
3) How extensible is this? For example, if I wanted to interface with WHMCS, to auto generate login details, am I able to do that?
4) Is a "git pull" the only way of keeping upto date with Ion Auth, or does Ben release "stable" versions of Ion Auth regularly?

Many thanks for your help
--Paul[/quote]

1. Sure. Set up a MY_Controller and use something like $this->ion_auth->logged_in()
or $this->ion_auth->is_group('admin')). See http://philsturgeon.co.uk/blog/2010/02/C...ing-it-DRY

2. Sure. Apply your own css as you see fit

3. No problem...limits are only as far as your programming skills will take you. You may of course have to modify the lib

4. As far as what I have seen, generally whats released onto Git is stable. I will leave Ben to answer this one though...

[eluser]DephNet[Paul][/eluser]
Hi Jono,

Thanks for your prompt response, with regards to question 2 again. Am I correct in thinking I can change the HTML markup as well as the CSS for the pages?

I will probably download Ion Auth later today and have a play with it before I commit to using it.

--Paul

[eluser]JonoB[/eluser]
[quote author="DephNet[Paul]" date="1307307537"]Am I correct in thinking I can change the HTML markup as well as the CSS for the pages?[/quote]
Sure you can. Its the first thing I changed when I downloaded ion-auth Smile

[eluser]Clone[/eluser]
Just an FYI. $this->ion_auth->change_password() is not documented here. http://benedmunds.com/ion_auth/

[eluser]JonoB[/eluser]
[quote author="Clone" date="1307349169"]Just an FYI. $this->ion_auth->change_password() is not documented here. http://benedmunds.com/ion_auth/[/quote]
It is, however, in the sample controller that comes with the package:
https://github.com/benedmunds/CodeIgnite...s/auth.php

Code:
//change password
function change_password()
{
  ...
  $change = $this->ion_auth->change_password($identity, $this->input->post('old'), $this->input->post('new'));
  ...
}

[eluser]DephNet[Paul][/eluser]
Right,

So I have downloaded Ion Auth and had a quick play with it last night and it is just what I want, although I have a little problem error messages.

Starting with the forgot_password() function in the Auth controller I have slowly started to change the error checking logic. I have so far come up with:
Code:
function forgot_password() {
            $this->data["title"] = "Recover Password";

            $this->data["form"]    = array("id" => "content", "name" => "content");
            $this->data["email"]   = array("id" => "email"  , "name" => "email"  );
            
            if(isset($_POST["submit"])) {
                if(empty($_POST["email"])) {
                    $this->data["message"] = array("type" => "error",   "body" => "Email address not detected, please check and try again");
                } else {
                    if(!preg_match("/@/i", $_POST["email"])) {
                        $this->data["message"] = array("type" => "error",   "body" => "Invalid email address detected, please check and try again");
                    } else {
                        if(!checkdnsrr(substr(strstr($_POST["email"], "@"), 1),'MX')) {
                            $this->data["message"] = array("type" => "error",   "body" => "Invalid email domain detected, please check and try again");
                        } else {
                            $query = "SELECT * FROM users WHERE email = ?";
                            $query = $this->db->query($query, $_POST["email"]);

                            if ($query->num_rows() != 1) {
                                $this->data["message"] = array("type" => "error",   "body" => "Email address not found, please check and try again");
                            } else {
                                $this->data["message"] = array("type" => "success", "body" => "This is a success message");
                            }
                        }
                    }
                }
            }

            $this->load->view("auth/forgot_password", $this->data);
        }

I have noticed that a default Ion Auth install uses $this->ion_auth->errors() which reads the language file for displaying the error in the correct language. How can I make use of $this->ion_auth->errors() within my script to call the correct error message from the language file.

Sorry if this is a noobish question, this is my first time using a pre written library for CI.

--Paul




Theme © iAndrew 2016 - Forum software by © MyBB