douou8954 2012-02-11 06:02
浏览 28
已采纳

如何将CodeIgniter的/ TankAuth的注册表和登录表单放在同一页面上?

I'm using CodeIgniter for my php framework and TankAuth for my authorization/registration. By default, TankAuth places the registration and login forms on separate pages. I would like to place the log-in form in the navigation bar that occurs on every page. There is also a sign-up page that will have the registration form occurring simultaneously as the log-in form (located in the navbar).

I am currently using this in controllers/signup.php .index()...

            $this -> load -> view('templates/header');
            $this -> login();
            $this -> register();
            $this -> load -> view('templates/footer');

This displays correctly but I have two issues:

1 Will I have to redefine TankAuth's methods in every controller that will have the log-in form?

2 When I try to register it tells me that the log-in form should be filled out as well. That's obviously a catch-22.

(I apologize if this is too domain specific or vague; I hope it makes sense to those who have worked with the framework.)

  • 写回答

2条回答 默认 最新

  • dongyi0114 2012-02-11 14:56
    关注

    I'm not sure what you are trying to achieve by just combining login & register views, they were not designed to work together, so you definetly need to do some modifications to the base tank auth structure.

    This really shouldn't be a confusing issue as its just a problem you created for yourself by combining two very similar forms.

    To simply walk through this, (and I don't know what code changes if any you made) first you must create your own login (html), set the form action="/auth/login".

    The login will submit, IF it is all clear the user is logged in and you handle it like that, HOWEVER if they fail to login, they will be brought to a single page login (default/or modified) where they can re-try again.

    The same should follow for registration, set the form action="/auth/register" and let it submit against tank auth controller. Again, if registration is successfull, they will just get shuttled through wherever, otherwise brought to a single registration page.

    Use the original login and registration views as a start to what you need to change / update.

    Tank Auth is really a plugin, that you need to modify to suit your needs, its code is clean and clear, so just go through it so you understand what happens at login, what happens at registration, activation etc, otherwise mashing things together will not get you anywhere. In my personal experience with the library, I have ALWAYS modified it beyond the initial setup, just because it is simple to do.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?