- $hist->{'found'} .= " (already isa $cur)";
- }
-
- $hist->{'response'} = 1;
- return $self;
-}
-
-sub fixup_after_morph {}
-
-sub fixup_before_unmorph {}
-
-###----------------------------------------------------------------###
-### allow for authentication
-
-sub navigate_authenticated {
- my ($self, $args) = @_;
- $self = $self->new($args) if ! ref $self;
-
- if ($self->can('require_auth') != \&CGI::Ex::App::require_auth) {
- require Carp;
- Carp::croak("The default navigate_authenticated method was called but the default require_auth method has been overwritten - aborting");
- }
- $self->require_auth(1);
-
- return $self->navigate;
-}
-
-sub require_auth {
- my $self = shift;
- $self->{'require_auth'} = shift if @_ == 1 && (! defined($_[0]) || ref($_[0]) || $_[0] =~ /^[01]$/);
- return $self->{'require_auth'} || 0;
-}
-
-sub is_authed { shift->auth_data }
-
-sub auth_data {
- my $self = shift;
- $self->{'auth_data'} = shift if @_ == 1;
- return $self->{'auth_data'};
-}
-
-sub get_valid_auth {
- my $self = shift;
- return 1 if $self->is_authed;
-
- my $args = $self->auth_args;
-
- ### allow passed in args
- if (my $extra = shift) {
- $args = {%$args, %$extra};
- }
-
- ### augment the args with sensible defaults
- $args->{'script_name'} ||= $self->script_name;
- $args->{'path_info'} ||= $self->path_info;
- $args->{'cgix'} ||= $self->cgix;
- $args->{'form'} ||= $self->form;
- $args->{'cookies'} ||= $self->cookies;
- $args->{'js_uri_path'} ||= $self->js_uri_path;
- $args->{'get_pass_by_user'} ||= sub { my ($auth, $user) = @_; $self->get_pass_by_user($user, $auth) };
- $args->{'verify_user'} ||= sub { my ($auth, $user) = @_; $self->verify_user( $user, $auth) };
- $args->{'cleanup_user'} ||= sub { my ($auth, $user) = @_; $self->cleanup_user( $user, $auth) };
- $args->{'login_print'} ||= sub {
- my ($auth, $template, $hash) = @_;
- my $step = $self->login_step;
- my $hash_base = $self->run_hook('hash_base', $step) || {};
- my $hash_comm = $self->run_hook('hash_common', $step) || {};
- my $hash_swap = $self->run_hook('hash_swap', $step) || {};
- my $swap = {%$hash_base, %$hash_comm, %$hash_swap, %$hash};
-
- my $out = $self->run_hook('swap_template', $step, $template, $swap);
- $self->run_hook('fill_template', $step, \$out, $hash);
- $self->run_hook('print_out', $step, \$out);
- };
-
- require CGI::Ex::Auth;
- my $obj = CGI::Ex::Auth->new($args);
- my $resp = $obj->get_valid_auth;
-
- my $data = $obj->last_auth_data;
- delete $data->{'real_pass'} if defined $data; # data may be defined but false
- $self->auth_data($data); # failed authentication may still have auth_data
-
- return ($resp && $data) ? 1 : 0;
-}
-
-sub auth_args { {} }
-
-sub get_pass_by_user { die "get_pass_by_user is a virtual method and needs to be overridden for authentication to work" }
-sub cleanup_user { my ($self, $user) = @_; $user }
-sub verify_user { 1 }
-
-###----------------------------------------------------------------###
-### a few standard base accessors
-
-sub script_name { shift->{'script_name'} || $ENV{'SCRIPT_NAME'} || $0 }
-
-sub path_info { shift->{'path_info'} || $ENV{'PATH_INFO'} || '' }
-
-sub cgix {
- my $self = shift;
- $self->{'cgix'} = shift if @_ == 1;
- return $self->{'cgix'} ||= do {
- require CGI::Ex;
- CGI::Ex->new; # return of the do
- };
-}
-
-sub form {
- my $self = shift;
- $self->{'form'} = shift if @_ == 1;
- return $self->{'form'} ||= $self->cgix->get_form;
-}
-
-sub cookies {
- my $self = shift;
- $self->{'cookies'} = shift if @_ == 1;
- return $self->{'cookies'} ||= $self->cgix->get_cookies;
-}
-
-sub vob {
- my $self = shift;
- $self->{'vob'} = shift if @_ == 1;
- return $self->{'vob'} ||= do {
- require CGI::Ex::Validate;
- my $args = $self->vob_args;
- $args->{'cgix'} ||= $self->cgix;
- CGI::Ex::Validate->new($self->vob_args); # return of the do
- };
-}
-
-sub vob_args { shift->{'vob_args'} || {} }
-
-sub vob_path {
- my $self = shift;
- return $self->{'vob_path'} || $self->template_path;
-}
-
-### provide a place for placing variables
-sub stash {
- my $self = shift;
- return $self->{'stash'} ||= {};
-}
-
-sub clear_app {
- my $self = shift;
-
- delete @{ $self }{qw(
- cgix
- vob
- form
- cookies
- stash
- path
- path_i
- history
- _morph_lineage_start_index
- _morph_lineage
- hash_errors
- hash_fill
- hash_swap
- hash_common
- )};
-
- return $self;
-}
-
-###----------------------------------------------------------------###
-### default hook implementations
-
-sub path_info_map { }
-
-sub run_step {
- my $self = shift;
- my $step = shift;
-
- ### if the pre_step exists and returns true, exit the nav_loop
- return 1 if $self->run_hook('pre_step', $step);
-
- ### allow for skipping this step (but stay in the nav_loop)
- return 0 if $self->run_hook('skip', $step);
-
- ### see if we have complete valid information for this step
- ### if so, do the next step
- ### if not, get necessary info and print it out
- if ( ! $self->run_hook('prepare', $step)
- || ! $self->run_hook('info_complete', $step)
- || ! $self->run_hook('finalize', $step)) {
-
- ### show the page requesting the information
- $self->run_hook('prepared_print', $step);
-
- ### a hook after the printing process
- $self->run_hook('post_print', $step);
-
- return 1;