Hi ,

I want to return HTTP Status 401 along with a body indicating
the friendly description from my auto method.


so i have below in my auto:
=====================================================
sub auto :Private {
        my ( $self, $c ) = @_;
        my $path = $c->request->path ;

        if ($path !~ /login.html/ && ! $c->session->{username}) {
                 $c->log->warn('*** Not logged in Authorized ****');
                 $c->response->status(401);
                 $c->response->body(qq{Sorry please login to access this
resource});
                 return 0;
        }
        return 1;
}

======================================================


However the request proceeds to other part of the chain
and does things which are not required.


===========================================================



[info] *** Request 1 (0.003/s) [839042] [Sun Apr 16 05:23:25 2017] ***
[debug] Path is "/api/rest/articlearticle/list_objects"
[debug] "GET" request for "api/rest/zingyhomes/article_article/" from
"127.0.0.1"
[debug] Query Parameters are:
.-------------------------------------+--------------------------------------.
| Parameter                           | Value                             
  |
+-------------------------------------+--------------------------------------+
| _                                   | 1492317689850                     
  |
| callback                            |
jQuery31001955130972547411_14923176- |
|                                     | 89849                             
  |
| list_count                          | 5                                 
  |
| list_offset                         | 0                                 
  |
'-------------------------------------+--------------------------------------'
[debug] Created session "37077cb431fb8502ac220d4c624b1db2b1217de7"
[warn] *** Not logged in Authorized ****
[debug] end subroutine.
[debug] Response Code: 401; Content-Type: unknown; Content-Length: unknown
[info] Request took 0.069336s (14.423/s)
.------------------------------------------------------------+-----------.
| Action                                                     | Time      |
+------------------------------------------------------------+-----------+
| /api/rest/articlearticle/begin                             | 0.057763s |
| /auto                                                      | 0.005666s |
<---- I want to break
| /api/rest/articlearticle/end                               | 0.000543s |
      here :-(
|  -> /api/rest/articlearticle/serialize                     | 0.000162s |
'------------------------------------------------------------+-----------'

=================================================================================


Previous discussions has been there
but it did not help me:

http://grokbase.com/t/sc/catalyst/055r77h11s/returning-false-in-auto-action
http://grokbase.com/t/sc/catalyst/083ev978bd/again-die-in-an-action-chain-does-not-break-the-chain


is there anything to halt the request after the appropriate
HTTP Status  and
Headers      and
Body

as been setup.


Regds
Rajesh Kumar Mallah.














_______________________________________________
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/

Reply via email to