lemonldap-ng/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Main/Request.pm

102 lines
2.4 KiB
Perl
Raw Normal View History

2016-03-30 21:51:15 +02:00
package Lemonldap::NG::Portal::Main::Request;
2016-04-03 08:33:50 +02:00
# Developpers, be careful: new() is never called so default values will not be
# taken in account (see Portal::Run::handler())
2016-03-30 21:51:15 +02:00
use strict;
use Mouse;
2016-04-11 07:00:34 +02:00
use Lemonldap::NG::Portal::Main::Constants;
2016-03-30 21:51:15 +02:00
extends 'Lemonldap::NG::Common::PSGI::Request';
2016-04-02 22:17:39 +02:00
# List of methods to call
2016-04-03 08:33:50 +02:00
has steps => ( is => 'rw' );
2016-04-02 22:17:39 +02:00
# Datas shared between methods
2016-04-03 08:33:50 +02:00
has datas => ( is => 'rw', default => sub { {} } );
2016-04-02 22:17:39 +02:00
# Session datas when created
2016-04-01 12:10:42 +02:00
has id => ( is => 'rw' );
2016-04-01 07:24:27 +02:00
has sessionInfo => ( is => 'rw' );
2016-04-04 07:08:26 +02:00
has user => ( is => 'rw' );
2016-04-02 22:17:39 +02:00
# Response cookies (list of strings built by cookie())
2016-04-01 12:10:42 +02:00
has respCookies => ( is => 'rw' );
2016-03-31 22:08:43 +02:00
2016-04-02 22:17:39 +02:00
# Template to display (if not defined, login or menu)
2016-04-03 08:33:50 +02:00
has template => ( is => 'rw' );
# Boolean to indicate that response must be a redirection
has mustRedirect => ( is => 'rw' );
# Boolean to indicate that url isn't Base64 encoded
has urlNotBase64 => ( is => 'rw' );
2016-04-02 22:17:39 +02:00
2016-04-07 23:31:56 +02:00
# Info to display at login
has info => ( is => 'rw' );
# Menu error
has menuError => ( is => 'rw' );
# Notification
has notification => ( is => 'rw' );
has _authChoice => ( is => 'rw' );
has _openidPortal => ( is => 'rw' );
2016-03-31 22:08:43 +02:00
sub wantJSON {
return $_[0]->accept =~ m#(?:application|text)/json# ? 1 : 0;
}
2016-04-07 23:31:56 +02:00
# Error type
sub error_type {
2016-04-11 07:00:34 +02:00
my $req = shift;
my $code = shift || $req->error;
# Positive errors
return "positive"
if (
scalar(
grep { /^$code$/ } (
PE_REDIRECT, PE_DONE,
PE_OK, PE_PASSWORD_OK,
PE_MAILOK, PE_LOGOUT_OK,
PE_MAILFIRSTACCESS, PE_PASSWORDFIRSTACCESS,
PE_MAILCONFIRMOK, PE_REGISTERFIRSTACCESS,
)
)
);
# Warning errors
return "warning"
if (
scalar(
grep { /^$code$/ } (
PE_INFO, PE_SESSIONEXPIRED,
PE_FORMEMPTY, PE_FIRSTACCESS,
PE_PP_GRACE, PE_PP_EXP_WARNING,
PE_NOTIFICATION, PE_BADURL,
PE_CONFIRM, PE_MAILFORMEMPTY,
PE_MAILCONFIRMATION_ALREADY_SENT, PE_PASSWORDFORMEMPTY,
PE_CAPTCHAEMPTY, PE_REGISTERFORMEMPTY,
)
)
);
# Negative errors (default)
return "negative";
2016-04-07 23:31:56 +02:00
#TODO
}
sub errorString {
#TODO
}
sub loginInfo {
}
# TODO: oldpassword
2016-03-30 21:51:15 +02:00
1;