Unverified Commit 4b53cc44 authored by IKEDA Soji's avatar IKEDA Soji Committed by GitHub
Browse files

Merge pull request #1247 from ikedas/cleanup_report by ikedas

Refactoring: Cleanup reporting on web UI
parents 63a5251b 57fc3e3f
......@@ -368,10 +368,8 @@ Subject: [%"Listmaster: internal server error"|loc(list.name)|qencode%]
[%|loc(who)%] User %1 has encountered an internal server error[%END%]
([%|loc%]Web interface[%END%] - ACTION[%|loc%]:[%END%] [%action%][% IF list.name %] - LIST[%|loc%]:[%END%] [%list.name%]@[%domain%][%END%])[%|loc%]:[%END%]
[%IF error == 'chdir_error' %][%|loc%]Unable to change directory.[%END%]
[%ELSIF error == 'no_authentication_service_name' %][%|loc%]The authentication server name is not defined.[%END%]
[%IF error == 'no_authentication_service_name' %][%|loc%]The authentication server name is not defined.[%END%]
[%ELSIF error == 'auth_conf_no_identified_user' %][%|loc%]auth.conf error: either email_http_header or host/get_email_by_uid_filter entries should be defined.[%END%]
[%ELSIF error == 'unknown_authentication_service' %][%|loc(name)%]Unknown authentication service %1.[%END%]
[%ELSIF error == 'add_user_db_failed' %][%|loc(user)%]Add user '%1' in DB failed.[%END%]
[%ELSIF error == 'update_user_db_failed' %][%|loc(user)%]Update user '%1' in DB failed[%END%][% IF old_email %][%|loc(old_email)%] (old email: %1)[%END%][%END%]
[%ELSIF error == 'add_subscriber_db_failed' %][%|loc(sub)%]Add subscriber '%1' in DB failed.[%END%]
......@@ -395,8 +393,6 @@ Subject: [%"Listmaster: internal server error"|loc(list.name)|qencode%]
[%ELSIF error == 'month_not_found' %][%|loc(month,list.name)%]Unable to find month '%1' for list '%2'[%END%][%IF dir%][%|loc(dir)%]: unable to read '%1'.[%END%][%END%]
[%ELSIF error == 'arc_not_found' %][%|loc(arc_file,list.name,path)%]Unable to find archive '%1' for list '%2'[%END%][%IF path%][%|loc(path)%]: unable to read '%1'.[%END%][%END%]
[%ELSIF error == 'inaccessible_archive' %][%|loc(list.name)%]Unable to find archive for list '%1'[%END%][%IF path%][%|loc(path)%]: unable to read '%1'.[%END%][%END%]
[%ELSIF error == 'may_not_send_me'%][%|loc()%]Unable to send archive: no message id found.[%END%]
[%ELSIF error == 'archive_not_found'%][%|loc(msgid)%]No message found in archives matching Message-ID '%1'.[%END%]
[%ELSIF error == 'cannot_save_config'%][%|loc(list.name)%]Cannot save config file for list '%1'.[%END%]
[%ELSIF error == 'failed_to_install_aliases'%][%|loc%]Failed to install aliases.[%END%]
[%ELSIF error == 'failed_to_remove_aliases'%][%|loc%]Failed to remove aliases.[%END%]
......@@ -416,7 +412,6 @@ Subject: [%"Listmaster: internal server error"|loc(list.name)|qencode%]
[%ELSIF error == 'delete_shared'%][%|loc(list.name)%]Cannot delete shared for list '%1'.[%END%]
[%ELSIF error == 'browse_shared'%][%|loc%]Impossible to browse shared documents for list '%1'.[%END%]
[%ELSIF error == 'cannot_upload'%][%|loc(path)%]Cannot upload file '%1'.[%END%]
[%ELSIF error == 'cannot_unzip' %][%|loc(name)%]Cannot unzip file '%1'.[%END%]
[%ELSIF error == 'error_during_unzip' %][%|loc(name)%]Errors while unzipping file '%1'.[%END%]
[%ELSIF error == 'cannot_send_remind' %][%|loc(from,list.name)%]Unable to send command REMIND from '%1' to list '%2'.[%END%]
[%ELSIF error == 'cannot_send_mail' %][%|loc(from,list.name)%]Unable to send mail from '%1' to list '%2'.[%END%]
......@@ -424,7 +419,6 @@ Subject: [%"Listmaster: internal server error"|loc(list.name)|qencode%]
[%ELSIF error == 'del_sub_request' %][%|loc(sub)%]Unable to delete subscription request for user '%1'.[%END%]
[%ELSIF error == 'add_file_zip' %][%|loc(file)%]Unable to add file '%1' to archives.[%END%]
[%ELSIF error == 'write_file_zip' %][%|loc(zipfile)%]Unable to write zip file '%1'.[%END%]
[%ELSIF error == 'err_404' %][%|loc(zipfile)%]File not found.[%END%]
[%ELSIF error == 'new_document_failed' %][%|loc(path,list.name)%]Unable to create a Shared Document with path '%1' for list '%2'.[%END%]
[%ELSIF error == 'cookie_error' %][%|loc%]Parameter cookie undefined, authentication failure.[%END%]
[%ELSIF error == 'cookie_error_env' %][%|loc(env)%]Cookie error: '%1' undefined, authentication failure.[%END%]
......
......@@ -236,9 +236,6 @@
[% IF report_entry == '' ~%]
[%~ ELSIF report_entry == 'month_not_found' ~%]
[%|loc(report_param.month)%]Unable to find month '%1'[%END%]
[%~ ELSIF report_entry == 'inaccessible_archive' ~%]
[%|loc(report_param.year_month)%]Archives from %1 are not accessible[%END%]
......@@ -272,9 +269,6 @@
[%~ ELSIF report_entry == 'no_identified_user' ~%]
[%|loc%]Failed to get your email address from the authentication service.[%END%]
[%~ ELSIF report_entry == 'err_404' ~%]
[%|loc(report_param.key)%]File not found.[%END%]
[%~ ELSIF report_entry == 'db_error' ~%]
[%|loc%]Database error.[%END%]
......@@ -899,6 +893,30 @@ Warning: this message may already have been sent by one of the list's moderators
[%~ ELSIF report_entry == 'no_classic_session' ~%]
[%|loc()%]You are not authorized to delete your account if you are not using the built-in authentication (i.e. you are using a LDAP authentication, a SSO system, etc.).[%END%]
[%~ ELSIF report_entry == 'unknown_authentication_service' ~%]
[%|loc(report_param.name)%]Unknown authentication service %1.[%END%]
[%~ ELSIF report_entry == 'no_message_id_to_send' ~%]
[%|loc()%]Unable to send archive: no message id found.[%END%]
[%~ ELSIF report_entry == 'no_message_id_to_view' ~%]
[%|loc()%]Unable to view archived message: no message id found.[%END%]
[%~ ELSIF report_entry == 'list_not_configured_for_tracking' ~%]
[%|loc()%]This list is not configured for tracking.[%END%]
[%~ ELSIF report_entry == 'no_message_id_in_archive' ~%]
[%|loc(report_param.msgid)%]No message found in archives matching Message-ID '%1'.[%END%]
[%~ ELSIF report_entry == 'unknown_scenario' ~%]
[%|loc(report_param.msgid)%]Unknown scenario '%1'.[%END%]
[%~ ELSIF report_entry == 'month_not_found' ~%]
[%|loc(report_param.month)%]Unable to find month '%1'[%END%]
[%~ ELSIF report_entry == 'cannot_get_privilege' ~%]
[%|loc()%]You are not allowed to get the privilege of this user.[%END%]
[%~ END ~%]
[%~ END ~%]
......@@ -17,15 +17,6 @@
</br>
[% END %]
[%###################-%]
[%#### SYSTEM ERROR -%]
[%###################-%]
[% FOREACH s_err = system_errors %]
[%|loc(s_err.action)%]SYSTEM ERROR (%1)[%END-%]
[% IF s_err.msg == 'a' %][% END %]
<br />
[% END %]
[%###################-%]
[%#### USER ERROR -%]
[%###################-%]
......
This diff is collapsed.
......@@ -193,7 +193,6 @@ nobase_modules_DATA = \
Sympa/WWW/FastCGI.pm \
Sympa/WWW/Marc.pm \
Sympa/WWW/Marc/Search.pm \
Sympa/WWW/Report.pm \
Sympa/WWW/SharedDocument.pm \
Sympa/WWW/Session.pm \
Sympa/WWW/SOAP.pm \
......
......@@ -40,7 +40,6 @@ use Sympa::Robot;
use Sympa::Tools::Data;
use Sympa::Tools::Text;
use Sympa::User;
use Sympa::WWW::Report;
my $log = Sympa::Log->instance;
......@@ -49,15 +48,18 @@ my $log = Sympa::Log->instance;
## authentication : via email or uid
sub check_auth {
my $robot = shift;
my $auth = shift; ## User email or UID
my $pwd = shift; ## Password
$log->syslog('debug', '(%s)', $auth);
$log->syslog('debug', '(%s, %s, ?, ...)', @_);
my $robot = shift;
my $auth = shift; ## User email or UID
my $pwd = shift; ## Password
my %options = @_;
my $stash_ref = $options{stash} || [];
my ($canonic, $user);
if (Sympa::Tools::Text::valid_email($auth)) {
return authentication($robot, $auth, $pwd);
return authentication($robot, $auth, $pwd, stash => $stash_ref);
} else {
## This is an UID
foreach my $ldap (@{$Conf::Conf{'auth_services'}{$robot}}) {
......@@ -79,9 +81,8 @@ sub check_auth {
};
} else {
Sympa::WWW::Report::reject_report_web('user', 'incorrect_passwd',
{})
unless ($ENV{'SYMPA_SOAP'});
push @$stash_ref, ['user', 'incorrect_passwd']
unless $ENV{'SYMPA_SOAP'};
$log->syslog('err', "Incorrect LDAP password");
return undef;
}
......@@ -117,9 +118,15 @@ sub may_use_sympa_native_auth {
}
sub authentication {
my ($robot, $email, $pwd) = @_;
$log->syslog('debug', '(%s, %s, ?, ...)', @_);
my $robot = shift;
my $email = shift;
my $pwd = shift;
my %options = @_;
my $stash_ref = $options{stash} || [];
my ($user, $canonic);
$log->syslog('debug', '(%s)', $email);
unless ($user = Sympa::User::get_global_user($email)) {
$user = {'email' => $email};
......@@ -133,9 +140,8 @@ sub authentication {
# too many wrong login attemp
Sympa::User::update_global_user($email,
{wrong_login_count => $user->{'wrong_login_count'} + 1});
Sympa::WWW::Report::reject_report_web('user', 'too_many_wrong_login',
{})
unless ($ENV{'SYMPA_SOAP'});
push @$stash_ref, ['user', 'too_many_wrong_login']
unless $ENV{'SYMPA_SOAP'};
$log->syslog('err',
'Login is blocked: too many wrong password submission for %s',
$email);
......@@ -203,7 +209,7 @@ sub authentication {
{wrong_login_count => ($user->{'wrong_login_count'} || 0) + 1});
}
Sympa::WWW::Report::reject_report_web('user', 'incorrect_passwd', {})
push @$stash_ref, ['user', 'incorrect_passwd']
unless $ENV{'SYMPA_SOAP'};
$log->syslog('err', 'Incorrect password for user %s', $email);
......
# -*- indent-tabs-mode: nil; -*-
# vim:ft=perl:et:sw=4
# $Id$
# Sympa - SYsteme de Multi-Postage Automatique
#
# Copyright (c) 1997, 1998, 1999 Institut Pasteur & Christophe Wolfhugel
# Copyright (c) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
# 2006, 2007, 2008, 2009, 2010, 2011 Comite Reseau des Universites
# Copyright (c) 2011, 2012, 2013, 2014, 2015, 2016, 2017 GIP RENATER
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
package Sympa::WWW::Report;
use strict;
use warnings;
use Sympa;
use Sympa::Log;
my $log = Sympa::Log->instance;
### MESSAGE DIFFUSION REPORT ###
# DEPRECATED. Use Sympa::send_dsn().
#sub reject_report_msg;
# No longer used.
#sub _get_msg_as_hash;
# DEPRECATED. Use Sympa::send_file($that, 'message_report').
#sub notice_report_msg;
### MAIL COMMAND REPORT ###
# DEPRECATED: No longer used.
#sub init_report_cmd;
# DEPRECATED: No longer used.
#sub is_there_any_report_cmd;
# DEPRECATED. Use Sympa::Spindle::DoCommand::_send_report().
#sub send_report_cmd;
# DEPRECATED. No longer used.
#sub global_report_cmd;
# DEPRECATED. No longer used.
#sub reject_report_cmd;
# DEPRECATED. No longer used.
#sub notice_report_cmd;
### WEB COMMAND REPORT ###
# for rejected web command because of internal error
my @intern_error_web;
# for rejected web command because of system error
my @system_error_web;
# for rejected web command because of user error
my @user_error_web;
# for rejected web command because of no authorization
my @auth_reject_web;
# for web command notice
my @notice_web;
#########################################################
# init_report_web
#########################################################
# init arrays for web reports :
#
#
# IN : -
#
# OUT : -
#
#########################################################
sub init_report_web {
undef @intern_error_web;
undef @system_error_web;
undef @user_error_web;
undef @auth_reject_web;
undef @notice_web;
}
#########################################################
# is_there_any_reject_report_web
#########################################################
# Look for some web reports in one of web
# arrays reject report
#
# IN : -
#
# OUT : 1 if there are some reports to send
#
#########################################################
sub is_there_any_reject_report_web {
return ( @intern_error_web
|| @system_error_web
|| @user_error_web
|| @auth_reject_web);
}
#########################################################
# get_intern_error_web
#########################################################
# return array of web intern error
#
# IN : -
#
# OUT : ref(ARRAY) - clone of \@intern_error_web
#
#########################################################
sub get_intern_error_web {
my @intern_err;
foreach my $i (@intern_error_web) {
push @intern_err, $i;
}
return \@intern_err;
}
#########################################################
# get_system_error_web
#########################################################
# return array of web system error
#
# IN : -
#
# OUT : ref(ARRAY) - clone of \@system_error_web
#
#########################################################
sub get_system_error_web {
my @system_err;
foreach my $i (@system_error_web) {
push @system_err, $i;
}
return \@system_err;
}
#########################################################
# get_user_error_web
#########################################################
# return array of web user error
#
# IN : -
#
# OUT : ref(ARRAY) - clone of \@user_error_web
#
#########################################################
sub get_user_error_web {
my @user_err;
foreach my $u (@user_error_web) {
push @user_err, $u;
}
return \@user_err;
}
#########################################################
# get_auth_reject_web
#########################################################
# return array of web authorization rejects
#
# IN : -
#
# OUT : ref(ARRAY) - clone of \@auth_reject_web
#
#########################################################
sub get_auth_reject_web {
my @auth_rej;
foreach my $a (@auth_reject_web) {
push @auth_rej, $a;
}
return \@auth_rej;
}
#########################################################
# get_notice_web
#########################################################
# return array of web notice
#
# IN : -
#
# OUT : ref(ARRAY) - clone of \@notice_web
#
#########################################################
sub get_notice_web {
my @notice;
if (@notice_web) {
foreach my $n (@notice_web) {
push @notice, $n;
}
return \@notice;
} else {
return 0;
}
}
#########################################################
# notice_report_web
#########################################################
# puts notices reports of web commands in
# @notice_web used to notice user with template
# web_tt2/notice.tt2
#
# IN : -$msg : $notice.msg to select string in
# web/notice.tt2
# -$data : ref(HASH) - var used in web_tt2/notices.tt2
# -$action : SCALAR - the noticed action $notice.action in
# web_tt2/notices.tt2
#
# OUT : 1
#
#########################################################
sub notice_report_web {
my ($msg, $data, $action) = @_;
$data ||= {};
$data->{'action'} = $action;
$data->{'msg'} = $msg;
push @notice_web, $data;
}
#########################################################
# reject_report_web
#########################################################
# puts errors reports of web commands in
# @intern/user/system_error_web, @auth_reject_web
# used to send message with template web_tt2/error.tt2
# if $type = 'intern'||'system', the listmaster is notified
# (with 'web_intern_error' || 'web_system_error')
#
# IN : -$type (+):
# 'intern'||'intern_quiet||'system'||'system_quiet'||user'||'auth'
# -$error (+): scalar - $u_err.msg in error.tt2 if $type = 'user'
# - $auth.msg in error.tt2 if $type = 'auth'
# - $s_err.msg in error.tt2 if $type =
# 'system'||'system_quiet'
# - $i_err.msg in error.tt2 if $type = 'intern' ||
# 'intern_quiet'
# - $error in listmaster_notification if $type =
# 'system'||'intern'
# -$data : ref(HASH) - var used in web_tt2/error.tt2
# -$action(+) : SCALAR - the rejected action :
# $xx.action in web_tt2/error.tt2
# $action in listmaster_notification.tt2 if needed
# -$list : ref(List) || ''
# -$user : required if $type eq 'intern'||'system'
# scalar - the concerned user to notify listmaster
# -$robot : required if $type eq 'intern'||'system'
# scalar - the robot to notify listmaster
#
# OUT : 1|| undef
#
#########################################################
sub reject_report_web {
my ($type, $error, $data, $action, $list, $user, $robot) = @_;
unless ($type eq 'intern'
|| $type eq 'intern_quiet'
|| $type eq 'system'
|| $type eq 'system_quiet'
|| $type eq 'user'
|| $type eq 'auth') {
$log->syslog(
'err',
'Error to prepare parsing "web_tt2/error.tt2" template to %s: Not a valid error type',
$user
);
return undef;
}
my $listname;
if (ref($list) eq 'Sympa::List') {
$listname = $list->{'name'};
}
## Notify listmaster for internal or system errors
if ($type eq 'intern' || $type eq 'system') {
if ($robot) {
my $param = $data || {};
$param->{'error'} = $error;
$param->{'who'} = $user;
$param->{'action'} ||= 'Command process';
Sympa::send_notify_to_listmaster(($list || $robot),
'web_' . $type . '_error', $param);
} else {
$log->syslog('notice',
'Unable to notify listmaster for error: "%s": (no robot)',
$error);
}
}
$data ||= {};
$data->{'action'} = $action;
$data->{'msg'} = $error;
$data->{'listname'} = $listname;
if ($type eq 'auth') {
push @auth_reject_web, $data;
} elsif ($type eq 'user') {
push @user_error_web, $data;
} elsif ($type eq 'system' || $type eq 'system_quiet') {
push @system_error_web, $data;
} elsif ($type eq 'intern' || $type eq 'intern_quiet') {
push @intern_error_web, $data;
}
}
1;
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment