# Copyright (c) 2004 bivio Software, Inc. All Rights Reserved. # # Visit http://www.bivio.biz for more info. # # This library is free software; you can redistribute it and/or modify # it under the terms of the GNU Lesser General Public License as # published by the Free Software Foundation; either version 2.1 of the # License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; If not, you may get a copy from: # http://www.opensource.org/licenses/lgpl-license.html # # $Id: ForbiddenForm.pm,v 1.14 2010/04/28 23:59:56 nagler Exp $ package Bivio::Biz::Model::ForbiddenForm; use strict; use Bivio::Base 'Biz.FormModel'; our($VERSION) = sprintf('%d.%02d', q$Revision: 1.14 $ =~ /\d+/g); sub execute_empty { my($self) = @_; my($req) = $self->get_request; my($auth_user, $agent) = $req->get('auth_user', 'Type.UserAgent'); my($reply) = $req->get('reply'); return 'next' unless $agent->is_browser; return { method => 'server_redirect', task_id => 'login_task', # TODO: figure out why this breaks acceptance test login_as() # task_id => $req->get('user_state')->eq_just_visitor # && $req->get('task')->unsafe_get('register_task') # || 'login_task', carry_query => 0, carry_path_info => 0, } unless $auth_user; return 'next'; } sub execute_unwind { my($self) = @_; my($rc) = ($self->unsafe_get('redirect_count') || 0) + 1; $self->internal_put_field(redirect_count => $rc); return $rc < 2 ? $self->internal_redirect_next : 'forbidden_task'; } sub internal_initialize { my($self) = @_; return $self->merge_initialize_info($self->SUPER::internal_initialize, { version => 1, require_context => 1, hidden => [ { name => 'redirect_count', type => 'Integer', constraint => 'NONE', }, ], }); } sub unsafe_realm_name_from_context { return undef unless my $c = shift->unsafe_get_context; return $c->unsafe_get_nested(qw(realm owner name)); } 1;