Tidy 2FA code
This commit is contained in:
parent
012b41b2b1
commit
c54b89485e
|
@ -380,7 +380,7 @@ sub run {
|
|||
|
||||
# More than 1 2F has been found, display choice
|
||||
$self->logger->debug("Prepare 2F choice");
|
||||
my $tpl = $self->p->sendHtml(
|
||||
my $res = $self->p->sendHtml(
|
||||
$req,
|
||||
'2fchoice',
|
||||
params => {
|
||||
|
@ -403,7 +403,7 @@ sub run {
|
|||
],
|
||||
}
|
||||
);
|
||||
$req->response($tpl);
|
||||
$req->response($res);
|
||||
return PE_SENDRESPONSE;
|
||||
}
|
||||
|
||||
|
@ -480,19 +480,18 @@ sub _redirect {
|
|||
}
|
||||
|
||||
sub _displayRegister {
|
||||
my ( $self, $req, $tpl ) = @_;
|
||||
my ( $self, $req, $prefix ) = @_;
|
||||
|
||||
# After verifying rule:
|
||||
# - display template if $tpl
|
||||
# - display template if $prefix
|
||||
# - else display choice template
|
||||
if ($tpl) {
|
||||
if ($prefix) {
|
||||
my ($m) =
|
||||
grep { $_->{m}->prefix eq $tpl } @{ $self->sfRModules };
|
||||
grep { $_->{m}->prefix eq $prefix } @{ $self->sfRModules };
|
||||
return $self->p->sendError( $req, 'Inexistent register module', 400 )
|
||||
unless $m;
|
||||
return $self->p->sendError( $req, 'Registration not authorized', 403 )
|
||||
unless $m->{r}->( $req, $req->userData );
|
||||
my $prefix = $m->{m}->prefix;
|
||||
return $self->p->sendHtml(
|
||||
$req,
|
||||
$m->{m}->template,
|
||||
|
@ -599,20 +598,20 @@ sub _displayRegister {
|
|||
|
||||
# Check rule and display
|
||||
sub register {
|
||||
my ( $self, $req, $tpl, @args ) = @_;
|
||||
my ( $self, $req, $prefix, @args ) = @_;
|
||||
|
||||
# After verifying rule:
|
||||
# - call register run method if $tpl
|
||||
# - call register run method if $prefix
|
||||
# - else give JSON list of available registers for this user
|
||||
if ($tpl) {
|
||||
if ($prefix) {
|
||||
my ($m) =
|
||||
grep { $_->{m}->prefix eq $tpl } @{ $self->sfRModules };
|
||||
grep { $_->{m}->prefix eq $prefix } @{ $self->sfRModules };
|
||||
unless ($m) {
|
||||
return $self->p->sendError( $req,
|
||||
'Inexistent register module', 400 );
|
||||
}
|
||||
unless ( $m->{r}->( $req, $req->userData ) ) {
|
||||
$self->userLogger->error("$tpl 2F registration refused");
|
||||
$self->userLogger->error("$prefix 2F registration refused");
|
||||
return $self->p->sendError( $req, 'Registration refused', 403 );
|
||||
}
|
||||
return $m->{m}->run( $req, @args );
|
||||
|
|
|
@ -60,7 +60,6 @@ has code_activation => (
|
|||
}
|
||||
);
|
||||
|
||||
|
||||
sub init {
|
||||
my ($self) = @_;
|
||||
|
||||
|
@ -92,7 +91,6 @@ sub run {
|
|||
sub sendCode {
|
||||
my ( $self, $req, $sessionInfo, $code ) = @_;
|
||||
|
||||
|
||||
my $dest = $sessionInfo->{ $self->sessionKey };
|
||||
|
||||
# Build mail content
|
||||
|
@ -142,7 +140,8 @@ sub sendCode {
|
|||
|
||||
sub verify_external {
|
||||
my ( $self, $req, $session, $usercode ) = @_;
|
||||
$self->logger->error("Error in Mail2F: verify_external is not supposed to be invoked");
|
||||
$self->logger->error(
|
||||
"Error in Mail2F: verify_external is not supposed to be invoked");
|
||||
return PE_ERROR;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue