summaryrefslogtreecommitdiffstats
path: root/mdkonline.pm
diff options
context:
space:
mode:
authorDaouda Lo <daouda@mandriva.com>2005-12-02 12:19:13 +0000
committerDaouda Lo <daouda@mandriva.com>2005-12-02 12:19:13 +0000
commit83cc56fffc9a0f1ca05f7baa187255ef096fd869 (patch)
tree248911b8856c26a08d2a42a07ceb25a811c8e772 /mdkonline.pm
parent717ab0ce4bbd33d78d85bee13a21aedf26a0b4f7 (diff)
downloadmgaonline-83cc56fffc9a0f1ca05f7baa187255ef096fd869.tar
mgaonline-83cc56fffc9a0f1ca05f7baa187255ef096fd869.tar.gz
mgaonline-83cc56fffc9a0f1ca05f7baa187255ef096fd869.tar.bz2
mgaonline-83cc56fffc9a0f1ca05f7baa187255ef096fd869.tar.xz
mgaonline-83cc56fffc9a0f1ca05f7baa187255ef096fd869.zip
- make code more robust and more maintainable
Diffstat (limited to 'mdkonline.pm')
-rw-r--r--mdkonline.pm30
1 files changed, 11 insertions, 19 deletions
diff --git a/mdkonline.pm b/mdkonline.pm
index b92651bb..a2400b12 100644
--- a/mdkonline.pm
+++ b/mdkonline.pm
@@ -90,7 +90,7 @@ sub get_site {
sub create_authenticate_account {
my $type = shift;
my @info = @_;
- my ($response, $code);
+ my ($response, $code, $ret);
my $hreturn = {
1 => [ N("Security error"), N("Unsecure invocation: Method available through httpS only") ],
2 => [ N("Database error"), N("Server Database failed\nPlease Try again Later") ],
@@ -108,26 +108,18 @@ sub create_authenticate_account {
};
foreach my $num ([9, 8], [21, 20]) { $hreturn->{$num->[0]} = $hreturn->{$num->[1]} };
my $action = {
- create => sub {
- eval { $response = soap_create_account(@info) };
- if ($response->{status}) {
- return 'OK';
- } else {
- $code = $response->{code} || '99';
- return $hreturn->{$code}->[0] . ' : ' . $hreturn->{$code}->[1];
- }
- },
- authenticate => sub {
- eval { $response = soap_authenticate_user(@info) };
- if ($response->{status}) {
- return 'OK'
- } else {
- $code = $response->{code} || '99';
- return $hreturn->{$code}->[0] . ' : ' . $hreturn->{$code}->[1];
- }
- }
+ create => sub { eval { $response = soap_create_account(@info) }; },
+ authenticate => sub { eval { $response = soap_authenticate_user(@info) }; }
};
$action->{$type}->();
+ $ret = check_server_response($response, $hreturn);
+ $ret;
+}
+
+sub check_server_response {
+ my ($response, $h) = @_;
+ my $code = $response->{code} || '99';
+ return $response->{status} ? 'OK' : $h->{$code}->[0] . ' : ' . $h->{$code}->[1];
}
sub check_valid_email {