CodeIgniter Forums
Can't login with Freakauth - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter Archived (from EllisLab) (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: Can't login with Freakauth (/thread-6466.html)



Can't login with Freakauth - El Forum - 02-28-2008

[eluser]flokky[/eluser]
I'm having some problems with CI 1.6.1 and FreakAuth. Everything worked great, just until yesterday. I already used a compare tool, to compare my code, to a fresh instance and there were some differences, but they were all related to configuration (database) and modifications (fckeditor in formhelper)

When I enter the correct username and password, I get the same login screen.
When I enter the wrong username and/or password, I get a notification that I've entered an 'invalid username or password'.

I've debugged through the code, placed some echo's and it seems that CI can find the user in the backend database.

Second problem: when I try to show a message (flashmessage as called in code) like this.

Controller:
Code:
//set a flash message
$msg = $this->db->affected_rows().$this->lang->line('FAL_text_added');
flashMsg($msg);
redirect('admin/texts', 'location');

View:
Code:
<?php
$flash=$this->db_session->flashdata('flashMessage');
if (isset($flash) AND $flash!='')
{?>
<div id="flashMessage">
   &lt;?=$flash?&gt;
</div>
&lt;?php }?&gt;

This doesn't show up in HTML. I'm sure I've loaded the language file. I've already tried with passing a hardcoded string. And tried echoing the flashdata('flashMessage'), but that was just an empty string.


Can't login with Freakauth - El Forum - 02-28-2008

[eluser]Michael Wales[/eluser]
I'm not familiar with FreakAuth, but I believe it's flash message works similar to CI's default flash messages.

Flash messages are only available upon the next request (and only the next request).

So, this will not work:
Code:
// Controller:
function korn() {
  flashMsg('string');
  $this->load->view('view');
}

// View:
&lt;?= $flash; ?&gt;

This, will work:
Code:
// Controller:
function korn() {
  flashMsg('string');
  redirect('some_method');
}

function some_method() {
  $this->load->view('view');
}

// View:
&lt;?= $flash; ?&gt;


Note - in the second version, we are redirect - thus, creating a new request in which the flash data is available.


Can't login with Freakauth - El Forum - 02-28-2008

[eluser]flokky[/eluser]
Michael: thanks for the reply. I've updated my first post with the 'redirect' code. Actually I think I'm doing it like you've said in your post.

As I have dug deeper in the code, I loose track in function set_userdata($key, $value) in the DB_session file.

Code:
function set_flashdata($key, $value){
        $flash_key = $this->flash_key.':new:'.$key; //I can echo the $flash_key correctly here
        $this->set_userdata($flash_key, $value);
}

function set_userdata($newdata = array(), $newval = ''){
        // I cannot echo anything here. Here I loose track what is going on
    if (is_string($newdata))
    {
        $newdata = array($newdata => $newval);
    }    

    if (count($newdata) > 0)
    {
        foreach ($newdata as $key => $val)
        {
            $this->userdata[$key] = $val;
        }
    }
    
        $this->sess_update();
}



Can't login with Freakauth - El Forum - 03-01-2008

[eluser]flokky[/eluser]
As an update: I've re-installed a fresh CI + FreakAuth and copied over my adjusted code and everything is working again.
By taking a closer look by enabling the PROFILER, I saw the flashmessage and some other needed information for logging is wasn't saved into the ci_session db, which might explain why it didn't worked.

But why is still a question.. Smile


Can't login with Freakauth - El Forum - 06-24-2008

[eluser]JulianM[/eluser]
Hi, I had the same problem.

I fixed it loading the Db_session library on the autoload config file. (autoload.php)

Try to search here:

http://godbit.com/forum/viewtopic.php?id=2367

or do a ci_session freakauth search at weblatam here:

http://weblatam.com/wp/?s=freakauth

Julian


Can't login with Freakauth - El Forum - 08-29-2008

[eluser]redtuxrising[/eluser]
[quote author="flokky" date="1204387253"]
By taking a closer look by enabling the PROFILER, I saw the flashmessage and some other needed information for logging is wasn't saved into the ci_session db, which might explain why it didn't worked.

But why is still a question.. Smile[/quote]

This is a common problem with database driven session handlers. User Agent string is too large for the database field type. So, modify user_agent field in ci_sessions table to varchar(255), I think it's varchar(50) by default, and you should be good.