summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xmdkapplet-add-media-helper18
-rw-r--r--mdkonline.pm8
2 files changed, 15 insertions, 11 deletions
diff --git a/mdkapplet-add-media-helper b/mdkapplet-add-media-helper
index e0b04847..af710799 100755
--- a/mdkapplet-add-media-helper
+++ b/mdkapplet-add-media-helper
@@ -127,7 +127,7 @@ sub run_authentication_dialog {
"additional package medium");
mdkapplet_gui::run_ask_credentials_dialog($title,
$description,
- \&add_restricted_medium);
+ \&authenticate_callback);
ugtk2::exit(0);
}
@@ -155,22 +155,18 @@ sub run_no_rights_dialog() {
mdkapplet_gui::fill_n_run_portable_dialog($w, \@widgets);
}
-sub add_restricted_medium {
+sub authenticate_callback {
my ($email, $passwd) = @_;
my $product = $product{$up_product};
- my $my_profile = mdkonline::xml2perl(
- mdkonline::get_from("https://my.mandriva.com/rest/authenticate",
- [ 'username', $email,
- 'password', $passwd,
- 'return', 'userdata' ]
- ));
- if ($my_profile->{code} != 0) {
+ my $profile = mdkonline::get_my_mdv_profile();
+
+ if ($profile->{code} != 0) {
my $in = interactive->vnew;
$in->ask_warn(N("Error"),
- N("An error occurred") . "\n" . $my_profile->{message});
+ N("An error occurred") . "\n" . $profile->{message});
goto &run_authentication_dialog;
}
- elsif (!$product->{has_rights}->($my_profile)) {
+ elsif (!$product->{has_rights}->($profile)) {
run_no_rights_dialog();
}
else {
diff --git a/mdkonline.pm b/mdkonline.pm
index 6c67b54c..02399a66 100644
--- a/mdkonline.pm
+++ b/mdkonline.pm
@@ -50,6 +50,7 @@ our @EXPORT = qw(find_current_distro
$config_file
$product_id
$root);
+our @EXPORT_OK = qw(get_my_mdv_profile);
our (%config, $product_id, $root);
our $version = 1;
@@ -211,6 +212,13 @@ sub get_from {
$response;
}
+sub get_my_mdv_profile {
+ my ($email, $password) = @_;
+ xml2perl(mdkonline::get_from('https://my.mandriva.com/rest/authenticate',
+ [ 'username', $email, 'password', $password,
+ 'return', 'userdata' ]));
+}
+
# callers need to require XML::Simple
sub xml2perl {
my ($res) = @_;