On 10/14/2009 09:52:06 AM, David Silva wrote:

> But now i have other problem =P
> 
> Let's say i have a token to validate a login form. And i have a page
> where
> the user go if the login goes ok. But at this time if i call that 
> page
> without login it shows up. What i want is that the page redirect to
> login if
> i try to "force" and shows only after login.

The way I have done this is to record the user's IP when they log in.  
Then the pages that require you to be logged in have an <%init block%> 
like this:

<%init>
# chat.mhtml called from login with arg name
use NCHIAD;
NCHIAD::fatal("chat.mhtml: Illegal access attempt by \"$ARGS{name}\"") 
unless NCHIAD::CheckList($ARGS{name}, $ENV{REMOTE_ADDR}) {
        NCHIAD::fatal("chat.mhtml: Illegal access attempt by \"$ARGS
{name}\"")
}
</%init>

Notice $ENV{REMOTE_ADDR}.  This is the IP of the client and is 
available in any Mason page.

NCHIAD is just a module for the site.  "CheckList" compares the user 
name and IP address stored in a temporary database.  "fatal" includes a 
redirect:

sub fatal {
        my $mro = HTML::Mason::Request->instance();
        log_msg("FATAL REDIRECT: ".shift);
        $mro->redirect("error.mhtml");
        die;
}

You could redirect back to login.mhtml, too. 



------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Mason-users mailing list
Mason-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mason-users

Reply via email to