<legend id='a8Xq2'><style id='a8Xq2'><dir id='a8Xq2'><q id='a8Xq2'></q></dir></style></legend>

  1. <small id='a8Xq2'></small><noframes id='a8Xq2'>

      <tfoot id='a8Xq2'></tfoot>
        <bdo id='a8Xq2'></bdo><ul id='a8Xq2'></ul>

      <i id='a8Xq2'><tr id='a8Xq2'><dt id='a8Xq2'><q id='a8Xq2'><span id='a8Xq2'><b id='a8Xq2'><form id='a8Xq2'><ins id='a8Xq2'></ins><ul id='a8Xq2'></ul><sub id='a8Xq2'></sub></form><legend id='a8Xq2'></legend><bdo id='a8Xq2'><pre id='a8Xq2'><center id='a8Xq2'></center></pre></bdo></b><th id='a8Xq2'></th></span></q></dt></tr></i><div id='a8Xq2'><tfoot id='a8Xq2'></tfoot><dl id='a8Xq2'><fieldset id='a8Xq2'></fieldset></dl></div>

      基本的laravel路由密码保护而不设置数据库?

      Basic laravel route password protection without setting up database?(基本的laravel路由密码保护而不设置数据库?)
        <tbody id='APfLw'></tbody>
      <legend id='APfLw'><style id='APfLw'><dir id='APfLw'><q id='APfLw'></q></dir></style></legend>

        • <bdo id='APfLw'></bdo><ul id='APfLw'></ul>

            <tfoot id='APfLw'></tfoot>

            <small id='APfLw'></small><noframes id='APfLw'>

            1. <i id='APfLw'><tr id='APfLw'><dt id='APfLw'><q id='APfLw'><span id='APfLw'><b id='APfLw'><form id='APfLw'><ins id='APfLw'></ins><ul id='APfLw'></ul><sub id='APfLw'></sub></form><legend id='APfLw'></legend><bdo id='APfLw'><pre id='APfLw'><center id='APfLw'></center></pre></bdo></b><th id='APfLw'></th></span></q></dt></tr></i><div id='APfLw'><tfoot id='APfLw'></tfoot><dl id='APfLw'><fieldset id='APfLw'></fieldset></dl></div>

                本文介绍了基本的laravel路由密码保护而不设置数据库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我正在为域 (example.com/demo) 寻找一个死的简单密码保护解决方案(用户名和密码存储为数组中的键值对).我知道这在生产中是不好的做法,但这只是对某人的快速演示.我目前拥有的代码非常简单:

                I'm looking for a dead simple password protection solution (username and password stored as key-value pair in array) to a domain (example.com/demo). I know this is bad practice in production but this is just a quick demo to someone. The code I have currently is pretty trivial stuff:

                Route::group(['prefix' => 'demo', 'before' => 'auth.basic'], function() {...});
                

                我必须创建自己的过滤器吗?我将如何设置它以使过滤器仅在生产中有效?

                Would I have to create my own filter? How would I set it so the filter only works in production?

                推荐答案

                这很简单:

                Route::filter('auth.verybasic', function()
                {
                    if(Request::getUser() != 'foo' || Request::getPassword() != 'bar'){
                        $headers = array('WWW-Authenticate' => 'Basic');
                        return Response::make('Invalid credentials.', 401, $headers);
                    }
                });
                

                关于环境限制,只需检查 App::environment():

                Regarding the environment restriction, just check with App::environment():

                Route::filter('auth.verybasic', function()
                {
                    if(App::environment() != 'production') return;
                    // check login (same as above)
                });
                

                这篇关于基本的laravel路由密码保护而不设置数据库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                Laravel 4 - Connect to other database(Laravel 4 - 连接到其他数据库)
                Call external API function from controller, LARAVEL 4(从控制器调用外部 API 函数,LARAVEL 4)
                Empty string instead of null values Eloquent(空字符串而不是空值 Eloquent)
                quot;laravel.logquot; could not be opened: failed to open stream(“laravel.log无法打开:无法打开流)
                Displaying the Error Messages in Laravel after being Redirected from controller(从控制器重定向后在 Laravel 中显示错误消息)
                Laravel Creating Dynamic Routes to controllers from Mysql database(Laravel 从 Mysql 数据库创建到控制器的动态路由)

                1. <legend id='i4kD2'><style id='i4kD2'><dir id='i4kD2'><q id='i4kD2'></q></dir></style></legend>

                      <bdo id='i4kD2'></bdo><ul id='i4kD2'></ul>
                        <tbody id='i4kD2'></tbody>

                    • <tfoot id='i4kD2'></tfoot>

                      <small id='i4kD2'></small><noframes id='i4kD2'>

                        <i id='i4kD2'><tr id='i4kD2'><dt id='i4kD2'><q id='i4kD2'><span id='i4kD2'><b id='i4kD2'><form id='i4kD2'><ins id='i4kD2'></ins><ul id='i4kD2'></ul><sub id='i4kD2'></sub></form><legend id='i4kD2'></legend><bdo id='i4kD2'><pre id='i4kD2'><center id='i4kD2'></center></pre></bdo></b><th id='i4kD2'></th></span></q></dt></tr></i><div id='i4kD2'><tfoot id='i4kD2'></tfoot><dl id='i4kD2'><fieldset id='i4kD2'></fieldset></dl></div>