Kohana3参考以前的控制器?
Kohana3 中有没有办法引用以前的控制器/操作。
让我更好地解释一下:
我有一个基本控制器,它检查用户是否使用身份验证模块登录系统。
如果用户进入不允许查看的页面,他会被重定向到登录屏幕。
现在我想(当他唱歌时)返回到触发登录控制器的页面。
我想将它作为 URI 段传递,但问题是控制器可以包含“/”字符。
示例:
- 用户访问
mysite.com/user/profile
- 他被重定向到
mysite.com/login
(需要传递 user/profile) - 成功登录后,用户将被重定向回
mysite.com/user/profile
is there a way in Kohana3 to reference the previous controller/action.
Let me explain a little better:
I have a base controller which check if user is logged into the system using the Auth module.
If the user goes to a page which he is not allowed to view, he gets redirected to the logins screen.
Now I would like (when he sings in) to go back to the page which triggered the login controller.
I wanted to pass it as an URI segment, but the problem is that the controller can contain "/" characters.
Example:
- user goes to
mysite.com/user/profile
- he gets redirected to
mysite.com/login
(need to pass user/profile) - after successful login user gets redirected back to
mysite.com/user/profile
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我通过不断更新未登录用户的会话值来做到这一点。
然后,在成功登录后,您可以像这样重定向:
我还没有测试代码,但概念是存在的。如果未设置任何值,则继续重定向到主页。
请务必小心并验证重定向 URL。不应该如此,但由于我们正在处理用户数据,因此总是有可能出现一些不好的情况。您最不想看到的就是在登录后被重定向到受病毒感染的网站。
I do this by constantly updating a session value for users who are not logged in.
Then, after a successful login, you can redirect like this:
I haven't tested the code, but the concept is there. If no value is set then proceed to redirect to the home page.
Please make sure you're careful and validate the redirect URL. It shouldn't be, but since we're dealing with user data there's always a slight chance something bad might come back. The last thing you want is to be redirected to a virus infested website after you've logged in.