Welcome Guest, Not a member yet? Register   Sign In
Community Auth recover password example throws header error after using SSL
#1

I installed Community Auth and got it working. Tested all the examples (create_user, login, recover) and they all worked.

Then I purchased an SSL certificate, and according to documentation, edited the file application/hooks/auth_constants.php to define 'USE SSL' from 0 to 1.

Did that, and then the recover password example now throws the error " Cannot modify header information - headers already sent"

Searching keywords I found this forum thread: https://forum.codeigniter.com/thread-63473.html

That is similar to my situation, but mine only triggers when I turn on the 'USE SSL'. When I turn it back off, the example works again.

Also, I have not edited the views nor the controller in any customized way. It's a fresh install of both CodeIgniter and Community Auth. I'm pretty confident I followed the instructions well.

Thanks in advance for any help. -- jo

Attached Files Thumbnail(s)
   
Reply
#2

(04-11-2017, 06:26 AM)johnosmond Wrote: I installed Community Auth and got it working. Tested all the examples (create_user, login, recover) and they all worked.

Then I purchased an SSL certificate, and according to documentation, edited the file application/hooks/auth_constants.php to define 'USE SSL' from 0 to 1.

Did that, and then the recover password example now throws the error " Cannot modify header information - headers already sent"

Searching keywords I found this forum thread: https://forum.codeigniter.com/thread-63473.html

That is similar to my situation, but mine only triggers when I turn on the 'USE SSL'. When I turn it back off, the example works again.

Also, I have not edited the views nor the controller in any customized way. It's a fresh install of both CodeIgniter and Community Auth. I'm pretty confident I followed the instructions well.

Thanks in advance for any help. -- jo


Try clearing your cookies. I just went through everything with USE_SSL set to 1, and I'm not getting any errors.
Reply
#3

Thanks for your reply. I did that. No fix.

The token is being set when the form is loaded, which is called in the SECOND of three views. So it calls the header view (which sends output to the browser), then it calls the view that loads the the recover password form, which creates a token.

The documentation says you have to create the token BEFORE any output is sent to the browser, yet the example given (the recover password example) does just the opposite. What am I missing?
Reply
#4

(This post was last modified: 04-12-2017, 03:49 PM by skunkbad.)

(04-12-2017, 12:28 PM)johnosmond Wrote: Thanks for your reply. I did that. No fix.

The token is being set when the form is loaded, which is called in the SECOND of three views. So it calls the header view (which sends output to the browser), then it calls the view that loads the the recover password form, which creates a token.

The documentation says you have to create the token BEFORE any output is sent to the browser, yet the example given (the recover password example) does just the opposite. What am I missing?

I suppose you could be right. To confirm, try replacing the three lines that echo the view contents with:

PHP Code:
$h $this->load->view('examples/page_header'''TRUE);
$c $this->load->view('examples/recover_form', ( isset( $view_data ) ) ? $view_data ''TRUE );
$f $this->load->view('examples/page_footer'''TRUE);
echo 
$h.$c.$f

If that really is the problem, that simple change would take care of the issue. If you report back that it was successful, I'll update the repo. If it's something else, it'll be difficult to debug, but like everyone else I will give you the option of zipping up your site with a database dump, provide a link for me, and I'll figure it out.

Also, just so you know, the examples attempt to be the bare minimum just to show that Community Auth is working. It's a little strange that nobody else would have reported this issue, but I'll fix anything if it's broke.

And finally, I'd never build a website the way the examples are put together, and that should be obvious. Just glean from the examples what you can, and build your application.
Reply
#5

That worked! Hope I helped you make your plugin a little better. Thank you for all your work.
Reply
#6

Oh, but your recovery verification page is doing the same thing. I made the same change and viola!
Reply




Theme © iAndrew 2016 - Forum software by © MyBB