benedmunds / CodeIgniter-Ion-Auth

Simple and Lightweight Auth System for CodeIgniter
http://benedmunds.com/ion_auth/
MIT License
2.34k stars 1.14k forks source link

forgotten password complete mail #353

Closed danielschweiger closed 12 years ago

danielschweiger commented 12 years ago

the password reset mail with the link to the reset page works, but I get no complete mail. I cant find the place where this is finaly send ...

shouldn't this mail be send somewhere like here in the controller:

//reset password - final step for forgotten password public function reset_password($code = NULL) {

....

$change = $this->ion_auth->reset_password($identity, $this->input->post('new'));

if($change) {

.... // send the complete mail?

With basic setup I dont get this mail, all other mails work ...

benedmunds commented 12 years ago

It should be sent by Ion Auth. Do you get any errors with $this->ion_auth->errors()?

danielschweiger commented 12 years ago

no, no errors, what I changed is in config

/* ------------------------------------------------------------------------- Forgot Password Complete Email Template
Default: new_password.tpl.php

*/ $config['email_forgot_password_complete_html'] = 'new_password.html.php'; $config['email_forgot_password_complete_text'] = 'new_password.text.php';

the files are in place of course

and in /libraries/Ion_auth.php : 226

$message = $this->load->view($this->config->item('email_templates', 'ion_auth').$this->config->item('email_forgot_password_complete_html', 'ion_auth'), $data, true);

so just the email templates ...

I did a dump of $this->ion_auth->errors() right after the ->reset_password() func, but returns null.

Where should I look to find the place where this mail is fired?

benedmunds commented 12 years ago

hmm, go ahead and post your entire config file. The other emails are working right?

danielschweiger commented 12 years ago

yes, activation mail and forget pwd mail work ... there are this functions: forgotten_password_complete() I searched all the code, can't find a place where this functions are used so far ...

<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');

/*
| -------------------------------------------------------------------------
| Database Type
| -------------------------------------------------------------------------
| If set to TRUE, Ion Auth will use MongoDB as its database backend.
|
| If you use MongoDB there are two external dependencies that have to be 
| integrated with your project:
|   CodeIgniter MongoDB Active Record Library - http://github.com/alexbilbie/codeigniter-mongodb-library/tree/v2
|   CodeIgniter MongoDB Session Library - http://github.com/sepehr/ci-mongodb-session
*/
$config['use_mongodb'] = FALSE;

/*
| -------------------------------------------------------------------------
| MongoDB Collection.
| -------------------------------------------------------------------------
| Setup the mongodb docs using the following command: 
| $ mongorestore sql/mongo
|
*/
$config['collections']['users']          = 'users';
$config['collections']['groups']         = 'groups';
$config['collections']['login_attempts'] = 'login_attempts';

/*
| -------------------------------------------------------------------------
| Tables.
| -------------------------------------------------------------------------
| Database table names.
*/
$config['tables']['users']           = 'users';
$config['tables']['groups']          = 'groups';
$config['tables']['users_groups']    = 'users_groups';
$config['tables']['login_attempts']  = 'login_attempts';

/*
 | Users table column and Group table column you want to join WITH.
 |
 | Joins from users.id
 | Joins from groups.id
 */
$config['join']['users']  = 'user_id';
$config['join']['groups'] = 'group_id';

/*
 | -------------------------------------------------------------------------
 | Hash Method (sha1 or bcrypt)
 | -------------------------------------------------------------------------
 | Bcrypt is available in PHP 5.3+
 |
 | IMPORTANT: Based on the recommendation by many professionals, it is highly recommended to use
 | bcrypt instead of sha1.
 |
 | NOTE: If you use bcrypt you will need to increase your password column character limit to (80)
 |
 | Below there is "default_rounds" setting.  This defines how strong the encryption will be,
 | but remember the more rounds you set the longer it will take to hash (CPU usage) So adjust
 | this based on your server hardware.
 |
 | If you are using Bcrypt the Admin password field also needs to be changed in order login as admin:
 | $2a$07$SeBknntpZror9uyftVopmu61qg0ms8Qv1yV6FG.kQOSM.9QhmTo36
 |
 | Becareful how high you set max_rounds, I would do your own testing on how long it takes
 | to encrypt with x rounds.
 */
$config['hash_method']    = 'sha1'; // IMPORTANT: Make sure this is set to either sha1 or bcrypt
$config['default_rounds'] = 8;      // This does not apply if random_rounds is set to true
$config['random_rounds']  = FALSE;
$config['min_rounds']     = 5;
$config['max_rounds']     = 9;

/*
 | -------------------------------------------------------------------------
 | Authentication options.
 | -------------------------------------------------------------------------
 | maximum_login_attempts: This maximum is not enforced by the library, but is
 | used by $this->ion_auth->is_max_login_attempts_exceeded().
 | The controller should check this function and act
 | appropriately. If this variable set to 0, there is no maximum.
 */
$config['site_title']           = "xxx";        // Site Title, example.com
$config['admin_email']          = "support@xxx.xxx";    // Admin Email, admin@example.com
$config['default_group']        = 'members';            // Default group, use name
$config['admin_group']          = 'admin';              // Default administrators group, use name
$config['identity']             = 'email';              // A database column which is used to login with
$config['min_password_length']  = 3;                    // Minimum Required Length of Password
$config['max_password_length']  = 20;                   // Maximum Allowed Length of Password
$config['email_activation']     = TRUE;                 // Email Activation for registration
$config['manual_activation']    = FALSE;                // Manual Activation for registration
$config['remember_users']       = TRUE;                 // Allow users to be remembered and enable auto-login
$config['user_expire']          = 86500;                // How long to remember the user (seconds). Set to zero for no expiration
$config['user_extend_on_login'] = FALSE;                // Extend the users cookies everytime they auto-login
$config['track_login_attempts'] = FALSE;                // Track the number of failed login attempts for each user or ip.
$config['maximum_login_attempts']     = 3;              // The maximum number of failed login attempts.
$config['lockout_time'] = 600;                          // The number of seconds to lockout an account due to exceeded attempts
$config['forgot_password_expiration'] = 0;              // The number of seconds after which a forgot password request will expire. If set to 0, forgot password requests will not expire.

/*
 | -------------------------------------------------------------------------
 | Email options.
 | -------------------------------------------------------------------------
 | email_config:
 |    'file' = Use the default CI config or use from a config file
 |    array  = Manually set your email config settings
 */
$config['use_ci_email'] = TRUE; // Send Email using the builtin CI email class, if false it will return the code and the identity
$config['email_config'] = array(
    'mailtype' => 'html',
        'protocol' => 'smtp',

        'smtp_host' => 'smtp.xxx.xxx',
        'smtp_user' => 'xxx',
        'smtp_pass' => 'xxx',
        'smtp_port' => 587,
        'crlf' => "\r\n",
        'newline' => "\r\n",

);

/*
 | -------------------------------------------------------------------------
 | Email templates.
 | -------------------------------------------------------------------------
 | Folder where email templates are stored.
 | Default: auth/
 */
$config['email_templates'] = 'auth/email/';

/*
 | -------------------------------------------------------------------------
 | Activate Account Email Template
 | -------------------------------------------------------------------------
 | Default: activate.tpl.php
 */
$config['email_activate_text'] = 'activate.text.php';
$config['email_activate_html'] = 'activate.html.php';

/*
 | -------------------------------------------------------------------------
 | Forgot Password Email Template
 | -------------------------------------------------------------------------
 | Default: forgot_password.tpl.php
 */
$config['email_forgot_password_html'] = 'password_reset.html.php';
$config['email_forgot_password_text'] = 'password_reset.text.php';

/*
 | -------------------------------------------------------------------------
 | Forgot Password Complete Email Template
 | -------------------------------------------------------------------------
 | Default: new_password.tpl.php
 */
$config['email_forgot_password_complete_html'] = 'new_password.html.php';
$config['email_forgot_password_complete_text'] = 'new_password.text.php';

/*
 | -------------------------------------------------------------------------
 | Salt options
 | -------------------------------------------------------------------------
 | salt_length Default: 10
 |
 | store_salt: Should the salt be stored in the database?
 | This will change your password encryption algorithm,
 | default password, 'password', changes to
 | fbaa5e216d163a02ae630ab1a43372635dd374c0 with default salt.
 */
$config['salt_length'] = 10;
$config['store_salt']  = FALSE;

/*
 | -------------------------------------------------------------------------
 | Message Delimiters.
 | -------------------------------------------------------------------------
 */
$config['message_start_delimiter'] = '';    // Message start delimiter
$config['message_end_delimiter']   = '';    // Message end delimiter
$config['error_start_delimiter']   = '';        // Error mesage start delimiter
$config['error_end_delimiter']     = '';    // Error mesage end delimiter

/* End of file ion_auth.php */
/* Location: ./application/config/ion_auth.php */
benedmunds commented 12 years ago

Well the method starts at line 188 in libraries/ion_auth.php.

I think you'll have to add some debug code to track down what is happening with the email sending on line 226...

danielschweiger commented 12 years ago

I make an die(); directly in the first line of

public function forgotten_password_complete($code) { die(); ....

but the method dont loads at any time in my case.

where is the place where the forgotten_password_complete method is called?

as I said, I searched all the code but cant find it. where this should be called?

benedmunds commented 12 years ago

Ah damn dude I'm sorry. We recently made a change to the example controller so it will allow you to change the password directly without needing to send the forgotten password complete email.

I thought you were using it but it doesn't sound like you are. It's still there as an option if you want to change the controller to use it, otherwise just use the example how it comes with no email.

danielschweiger commented 12 years ago

ok, I understand ... no problem. what do you recommend where to implement the function?

benedmunds commented 12 years ago

Do you just want a confirmation email or do you want to email them the password instead of allowing them to enter it?

danielschweiger commented 12 years ago

just an email to inform the user that his pwd is changed now. the email and its contents are ready.

benedmunds commented 12 years ago

Put the email code in the controllers/auth.php controller file at line 292.

Bhavinshah5111 commented 9 years ago

ion auth forgot password mail send but not received in mail account.please help me . how can i solve this ?

benedmunds commented 9 years ago

The best thing to do is just to create a test controller method that sends an email to work out the proper email settings.

Bhavinshah5111 commented 9 years ago

problem in config file.but now it works ...sorry for disturbing ...thanks a lot...

benedmunds commented 9 years ago

What was the correct answer? for future users.

Bhavinshah5111 commented 9 years ago

sir i made one email file and changing some security in gmail... in my email config file <?php $config["mailtype"] = "html"; $config["protocol"] = "smtp"; $config["smtp_host"] = "ssl://smtp.googlemail.com"; $config["smtp_user"] = "xxxx@gmail.com"; $config["smtp_pass"] = "xxxx"; $config["smtp_port"] = 465; $config["crlf"] = "\r\n"; $config["newline"] = "\r\n"; ?> suggest to made config file for email

pudyasto commented 7 years ago

Hey sir, I've successfully using reset password and using method forgotten_password_complete. my question : how to change new password with some numbers

like : Your password has been reset to: Yp9p68377WPUFv3xa1oClu

2016-12-14 1

Thanks a lot ...