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

[eluser]joytopia[/eluser]
Ben,

I just began to implement the activation email.
As I do not use html emails, I would propose to set the mailtype in the config:

Code:
/**
* Mail type, "text" or "html"
*/
$config['mailtype']     = "html";

and change the 3 lines in the library:

Code:
$config['mailtype'] = $this->ci->config->item('mailtype', 'ion_auth');

Best regards
Bernd

[eluser]farocco[/eluser]
[quote author="farocco" date="1272935797"]Ben,

Any thing I have to do to host this on Godaddy?
I am getting an email error when trying to use the forgot_password.

Thanks

Frank

A PHP Error was encountered

Severity: Warning

Message: mail() [function.mail]: Bad parameters to mail() function, mail not sent.

Filename: libraries/Email.php

Line Number: 1519

A PHP Error was encountered

Severity: Warning

Message: Cannot modify header information - headers already sent by (output started at /home/content/n/t/w/ntwfrankfort/html/ci/system/libraries/Exceptions.php:166)

Filename: libraries/Session.php

Line Number: 662

A PHP Error was encountered

Severity: Warning

Message: Cannot modify header information - headers already sent by (output started at /home/content/n/t/w/ntwfrankfort/html/ci/system/libraries/Exceptions.php:166)

Filename: helpers/url_helper.php

Line Number: 539[/quote]

Hi Ben,

I just tried a simple php cript to send email using the mail protocol and did not get any errors. Any idea why it is not working in ion-auth.

Thanks

Frank

[eluser]internut[/eluser]
I'm glad I found Ion. Just started to look at it and how I can benefit from it.

Any useful tips on having a registered set of users but basically different groups will be part of the end solution. Though different groups would have different custom meta fields.

Wondering if I should just have all fields in the "meta" table and based on the "group" they belong to output those fields to the user and check required fields (on save) based on the group.

An admin would really not need to use any of those meta fields of course as its just an admin account.

Any thoughts on the above much appreciated. Just trying to wrap my head around the programming as I wire-frame it out.

[eluser]joytopia[/eluser]
Ben,

the concept of email-templates seems very useful to customize the appearance of activation emails etc.

However,at this time the subject is still hard coded. I would propose to put subject and message into the same view and separate them with ###markers###.

Here my activate.tpl.php (in my case for text emails)

Quote:###subject###

<?php echo $this->config->item('site_title', 'ion_auth') . ' - Test: Account Activation' ?>

###message###

Activate account for <?php echo $identity;?>


Test: Please click this link to Activate Your Account:
<?php echo base_url().'auth/activate/'. $id .'/'. $activation;?>

and here some changes in function register of the library:

Code:
$message = $this->ci->load->view($this->ci->config->item('email_templates', 'ion_auth').$this->ci->config->item('email_activate', 'ion_auth'), $data, true);
            
            $subject = substr($message, 0, strpos($message, '###message###'));
            $message = trim(str_replace($subject.'###message###', '', $message));
            $subject = trim(str_replace('###subject###','',$subject));


            $this->ci->email->clear();
            $config['mailtype'] = ($this->ci->config->item('mailtype', 'ion_auth')) ? $this->ci->config->item('mailtype', 'ion_auth') : 'html'; // gradido: mailtype from config
            $this->ci->email->initialize($config);
            $this->ci->email->set_newline("\r\n");
            $this->ci->email->from($this->ci->config->item('admin_email', 'ion_auth'), $this->ci->config->item('site_title', 'ion_auth'));
            $this->ci->email->to($email);
            
            if($subject) $this->ci->email->subject($subject);
            else $this->ci->email->subject($this->ci->config->item('site_title', 'ion_auth') . ' - Account Activation');
            
            $this->ci->email->message($message);

I tested it with the register / activate emails. The code is backward compatible. The other email-functions should be similar.

Best regards
Bernd

[eluser]crashfellow[/eluser]
Just implemented this and have been able to get it up and running nicely Smile just have a couple of questions Smile

1) How can i change the login to be username instead of email? without breaking the forgottenpassword.

2) I would like my application to load up the login page straight away when you visit the site (unless your login is still in session) and once logging in your site continues.

Also on a per page / controller basis, what would i do to check to make sure you are currently logged in?

Keeping in mind that the admin person should go to one area (ie: /admin) and a non admin would just go to a page (ie: list/display)

Thanks for this system btw! currently writing a project and using this as the basis for the login and user system Smile

[eluser]joytopia[/eluser]
crashfellow,

1. you can set the the identity-column in the config file:
Code:
/**
* A database column which is used to
* login with.
**/
$config['identity']            = 'username';

After this you will have to make some changes in the controller and the view, so that the correct field is shown and validated.

2. The function logged_in() returns true if the user is logged in
The function is_admin() returns true if the user is an admin.

3. If you want to show the login form on every page, you can take the example code from the auth-controller, change it to your needs and put into a method which returns the form as a content string, which you can put anywhere you want to.

Best regards
Bernd

[eluser]crashfellow[/eluser]
Thank you for the reply Smile

I've set up the following function for login:

// check for login
if (!$this->ion_auth->logged_in()) {
redirect(base_url() . 'auth/login.html', 'refresh');
}

Which is currently working perfectly. However shouldn't there be a way in a constructor to do so? perhaps in the top of each controllers constructor?

[eluser]Phil Sturgeon[/eluser]
Bad!

[quote author="crashfellow" date="1273601637"]Thank you for the reply Smile

I've set up the following function for login:

// check for login
if (!$this->ion_auth->logged_in()) {
redirect(base_url() . 'auth/login.html', 'refresh');
}

Which is currently working perfectly. However shouldn't there be a way in a constructor to do so? perhaps in the top of each controllers constructor?[/quote]

Better

Code:
if (!$this->ion_auth->logged_in()) {
  redirect('auth/login', 'refresh');
}

Best

Code:
$this->ion_auth->logged_in() or redirect('auth/login');

Anyhow, the controllers in Ion Auth are the only as an example. You should be putting this in your Controller constructor or even better in your named Base Controller. That is all way out of scope of this simple example controller.

[eluser]crashfellow[/eluser]
Thanks for your reply, but you didn't really have to yell bad! at it did you Tongue

The reason for base url() is because if my code is currently at:

localhost/site/controller/

then if i do a redirect, i will then get:

localhost/site/auth/login/

which doesn't work. This base class idea however is perfect, i think that'll do exactly what i want.

So would i shift the functionality of Ion Auth into the base controller?

[eluser]Ben Edmunds[/eluser]
Hey crashfellow,

The redirect function will insert your base_url.

You wouldn't shift the functionality but you would do the checking there. So in MY_controller you would check if the user is logged in and if not redirect to auth/login.



And please don't do this, this really sucks:

Code:
$this->ion_auth->logged_in() or redirect('auth/login');

Phil is going through a very hard time right now as he struggles with his sexual orientation and his code is suffering greatly for it.

Do this instead:

Code:
if (!$this->ion_auth->logged_in())
    redirect('auth/login');

or even this if you're desperate for white space:

Code:
if (!$this->ion_auth->logged_in()) redirect('auth/login');




Theme © iAndrew 2016 - Forum software by © MyBB