Welcome Guest, Not a member yet? Register   Sign In
Can't login with Freakauth
#1

[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.
#2

[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.
#3

[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();
}
#4

[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
#5

[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
#6

[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.




Theme © iAndrew 2016 - Forum software by © MyBB