Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8106195
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T00:23:38+00:00 2026-06-06T00:23:38+00:00

I have the following code in my Mojolicious application module. When I run this

  • 0

I have the following code in my Mojolicious application module. When I run this using
Test::Mojo $t->post_ok(‘hosts’, encode_json( $json_string ) )->status_is(200), the application works fine. When I use the Firefox rest client I never get passed the
add_condition route modifier ‘access’. I dumped the result of $can (in the add_condition block) and it’s ‘1’. So, in my mind, that should just continue on to the controller (as it does when I run the test). When using the FF rest client this
returns 404 because nothing happens after the access condition returns 1.

Any idea why the application would operate differently in these two situations?

$self->plugin(
    'json_rpc_dispatcher',
    services => {
        '/auth'      => Package::Controller::Auth->new,
        '/user'      => Package::Controller::User->new,
        '/hosts'     => Package::Controller::Hosts->new,
    }   
);  

$self->app->routes->add_condition(
    access => sub {
        my ($rt, $cntrlr, $stuff) = @_; 
        my $sess = $cntrlr->stash('mojo.session');

        my $path = $cntrlr->req->url->path->parts;

        my $can = $self->can_access({ 
            route => $path->[0],
            args  => $sess,
        }); 

        $can && return 1;


        $cntrlr->render_json({
            error => 'Not Authorized',
            ok    => 0,
        }); 
    }   
); 

$self->hook( before_dispatch => sub {

    my $this = shift;

    my $params = $this->tx->req->json;

    if( !$this->session('auth') ) {
    my $login = $self->login({
            user     => $params->{params}{user},
            password => $params->{params}{password},
    });

        return { error => 'Invalid Username or password' } if $login->{error}; 
        my $access = $self->has_access( 
            $params->{params}{user}, $params->{params}{password}
        );

        return { error => 'Invalid credentials' } unless keys %{ $access };

        $this->session( auth => { dn => $params->{params}{user}, perms => $access } );

    }

    else {
        $r->find('auth' )->over('access');
        $r->find('user' )->over('access');
        $r->find('hosts')->over('access');
    }

} );  # hook
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T00:23:41+00:00Added an answer on June 6, 2026 at 12:23 am

    Sorry. The problem had nothing to do with the application or Mojolicious in anyway (or even perl for that matter). Hostname wasn’t resolving correctly.

    Well, I don’t know where the problem is really. Starting the server using
    morbo script/app daemon -l my.host.name.domain.com wasn’t working.

    When I used
    morbo script/app daemon -l 192.168.1.11 (where 192.168.1.11 is the ip of my.host.name.domain.com). Things began to operate as expected.

    And now neither of those work. 🙁

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have following code in my application: // to set tip - photo in
I have following code in my Application. Comments in my code will specify My
I have following code in my application. [self.navigationController pushViewController:x animated:YES]; It will push a
I have following code snippet that i use to compile class at the run
I have following code in a html form <select name=category class=input onchange=ShowTB(this,'suggest');> <option value=0
i have following code in my php jquery call... <object type=application/x-shockwave-flash data=mysounds/player.swf id=audioplayer1 height=1
I have following code: string date = 13.04.2012; string date2 = (DateTime.Parse(date).AddDays(1)).ToString(); This is
I have following code function Model(onChanged) { this.array = new Array(); this.onChanged = onChanged;
I have following code for 3 DataGridView Controls in my VB.NET winform application. How
I have following code, after five tries (wrong words like dfasfasfb) the application stops.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.