CodeIgniter Tank Auth - send_again 函数的问题

发布于 2024-11-03 22:56:04 字数 349 浏览 3 评论 0原文

我一直在使用这个库,这绝对是很棒的。我正在测试它,我认为当未激活的用户尝试登录时会出现问题。我只是想知道你们中是否有人注意到了这一点?发生的情况是,用户被重定向到 send_again 页面,但一旦到达那里,我们就无法再将 url 更改为任何其他位置。我猜测发生这种情况是因为会话信息没有被破坏 - 在登录函数中:

elseif ($this->tank_auth->is_logged_in(FALSE)) {
// logged in, not activated
redirect('/auth/send_again/'); 

它一直被执行(除非我们强制注销)。有人知道如何解决这个问题吗? 谢谢!

I have been playing around with this library, which is absolutely awesome. I was testing it and I think there's a problem when a non activated User tries to log in. I was just wondering if any of you noticed this already? What happens is that the User is redirected to the send_again page, but once there, we are not able to change the url to any other location anymore. I am guessing that this happens because of the session info that is not destroyed - in the login function :

elseif ($this->tank_auth->is_logged_in(FALSE)) {
// logged in, not activated
redirect('/auth/send_again/'); 

this gets executed all the time (unless we force a logout). Does anybody knows how to fix this?
Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

記柔刀 2024-11-10 22:56:05

尝试删除 \controllers\auth.php 函数登录上的重定向值并发现:

elseif (isset($errors['not_activated'])) {              
redirect('');//auth/send_again/ 
}

当您不是激活用户时,将始终调用 send_again 函数。因此,要传递 send_again 函数,您只需删除重定向值,

如果您想激活电子邮件激活,则需要在配置文件夹中配置 email.php

try to remove the redirect value on \controllers\auth.php function login and find this :

elseif (isset($errors['not_activated'])) {              
redirect('');//auth/send_again/ 
}

send_again function will always be called when you are not activated user. So, to pass the send_again function you just need to delete redirect value

if you want to activate email activation you need to configure email.php on config folder

美男兮 2024-11-10 22:56:05

我在客户的网站上发现了这个错误。强制注销似乎可以解决此问题。
因此,我在重新发送函数中设置了强制注销,就在它发送激活链接之后。

工作代码在 application/controllers/auth.php 中看起来像这样

    function send_again()
    {
    if (!$this->tank_auth->is_logged_in(FALSE)) {                           // not logged in or activated
        redirect('/auth/login/');

    } else {
        $this->form_validation->set_rules('email', 'Email', 'trim|required|xss_clean|valid_email');

        $data['errors'] = array();

        if ($this->form_validation->run()) {                                // validation ok
            if (!is_null($data = $this->tank_auth->change_email(
                    $this->form_validation->set_value('email')))) {         // success

                $data['site_name']  = $this->config->item('website_name', 'tank_auth');
                $data['activation_period'] = $this->config->item('email_activation_expire', 'tank_auth') / 3600;

                $this->_send_email('activate', $data['email'], $data);

                $this->_display_message(sprintf($this->lang->line('auth_message_activation_email_sent'), $data['email']));

                /* 
                 * Force a logout here or tank_auth remains 
                 * stuck in the resend mode.
                 */ 
                $this->tank_auth->logout();

            } else {
                $errors = $this->tank_auth->get_error_message();
                foreach ($errors as $k => $v)   $data['errors'][$k] = $this->lang->line($v);
            }
.....

据我所知,这只是 hack,但它为我解决了问题。我不知道该网站的创建者是否在 Tank_auth 操作中更改了任何内容。

我希望它对其他人有用。

I found this bug to on a client's site. Forcing a logout seems to fix it.
So, I put a forced logout in the function resend function, just after it sends the activation link.

The working code looks like this in application/controllers/auth.php

    function send_again()
    {
    if (!$this->tank_auth->is_logged_in(FALSE)) {                           // not logged in or activated
        redirect('/auth/login/');

    } else {
        $this->form_validation->set_rules('email', 'Email', 'trim|required|xss_clean|valid_email');

        $data['errors'] = array();

        if ($this->form_validation->run()) {                                // validation ok
            if (!is_null($data = $this->tank_auth->change_email(
                    $this->form_validation->set_value('email')))) {         // success

                $data['site_name']  = $this->config->item('website_name', 'tank_auth');
                $data['activation_period'] = $this->config->item('email_activation_expire', 'tank_auth') / 3600;

                $this->_send_email('activate', $data['email'], $data);

                $this->_display_message(sprintf($this->lang->line('auth_message_activation_email_sent'), $data['email']));

                /* 
                 * Force a logout here or tank_auth remains 
                 * stuck in the resend mode.
                 */ 
                $this->tank_auth->logout();

            } else {
                $errors = $this->tank_auth->get_error_message();
                foreach ($errors as $k => $v)   $data['errors'][$k] = $this->lang->line($v);
            }
.....

As far as I can tell, this is just hack, but it solved the problem for me. I don't know if the creator of this site changed anything or not in the tank_auth actions.

I hope it works for others.

风筝有风,海豚有海 2024-11-10 22:56:05

嘿,这一直对我有用:

if( !$this->tank_auth->is_logged_in() ){
   // not logged in
} else {
   // logged in
}

注意条件中的爆炸

hey this has always worked for me:

if( !$this->tank_auth->is_logged_in() ){
   // not logged in
} else {
   // logged in
}

notice the bang in the condition

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文