CAM-UserApp

 view release on metacpan or  search on metacpan

lib/CAM/UserApp.pm  view on Meta::CPAN

         $self->offerChangePassword(error => "Incorrect password");
         return undef;
      }
   }

   if ($args{password1} ne $args{password2})
   {
      $self->offerChangePassword(error => "The passwords you have entered do not match");
      return undef;
   }

   my $password = $args{password1}; # shorthand
   unless ($self->validateNewPassword($password))
   {
      $self->offerChangePassword(error => "Invalid password, please try again");
      return undef;
   }

   unless ($user->can("recordPassword") && $user->recordPassword($password))
   {
      $self->offerChangePassword(error => "Unable to record your new password");
      return undef;
   }

   if ($args{useSession})
   {
      # Note! We DO NOT want to create a new session here, so we don't
      # use the getSession() method.  If there is no session, well, so
      # be it.

      my $session = $self->{session};
      if ($session)
      {
         $session->set(password => $password);
      }
   }

   return $self;
}
#--------------------------------#

=item offerLogin

Display an interactive login.  By default, this method is a no-op.
Interactive subclasses should override this method.  The return value
of this method is not used.  A sample implementation is presented in
the Synopsis above.

Optional arguments:

  error => string

Indicates a reason why this method has been called, like "Login
failure".  On a fresh login, this argument is absent.

  passthru => string

An accumulation of CGI parameters passed to this program, in the form
of '<input type=hidden name=key value=value>' for each parameter.
Implementations are welcome to ignore this, but they should pass it
via an HTML form if they want to make the login be 'transparent',
i.e., if the program should go back to whatever it was doing before
when login is successful login.

Here's an example HTML template file for use with the offerLogin()
implementation in the Synopsis above, using these parameters:

  <html><head><title>Login</title></head><body>
  <form action="::myURL::" method="post">
  ??error?? <span style="color:red">::error::</span> <br> ??error??
  Username: <input type="text" name="username"><br>
  Password: <input type="password" name="password"><br>
  <input type="submit" value="Login">
  ::passthru::
  </form></body></html>

=cut

sub offerLogin
{
   my $self = shift;
   my %args = (@_);

   # do nothing unless subclass overrides
}
#--------------------------------#

=item offerChangePassword

Display an interactive password change screen.  By default, this
method is a no-op, so interactive subclasses should override this
method.  The return value of this method is not used.  A sample
implementation is presented in the Synopsis above.

Optional arguments:

  error => string

Indicates a reason why this method has been called, like "Passwords do
not match".  On first hit, this argument is absent.

Here's an example HTML template file for use with the
offerChangePassword() implementation in the Synopsis above, using
this parameters:

  <html><head><title>Change Password</title></head><body>
  <form action="::myURL::" method="post">
  ??error?? <span style="color:red">::error::</span> <br> ??error??
  Old Password: <input type="password" name="password"><br>
  New Password: <input type="password" name="password1"><br>
  Retype Password: <input type="password" name="password2"><br>
  <input type="submit" value="Submit">
  </form></body></html>

=cut

sub offerChangePassword
{
   my $self = shift;
   my %args = (@_);



( run in 2.288 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )