diff --git a/bin/account-manager.pl.in b/bin/account-manager.pl.in index 7fafebb46868c02dfa14f1b5d3b42fa69becd2d3..c75a0febb37330edc82dc92d42dd170d1cff512c 100755 --- a/bin/account-manager.pl.in +++ b/bin/account-manager.pl.in @@ -129,12 +129,12 @@ sub list_accounts { foreach my $account (@$accounts) { $account->print(); - next unless $options{delete}; - die "failed to delete test account\n" - unless $account->delete(); } if ($options{delete}) { + foreach my $account (@$accounts) { + $account->delete() or die "failed to delete test account\n"; + } printf "%d accounts removed\n", @$accounts; die "failed to update simpleSAMLphp configuration file\n" @@ -250,12 +250,12 @@ sub list_tokens { foreach my $token (@$tokens) { $token->print(); - next unless $options{delete}; - die "failed to delete authentication token\n" - unless $token->delete(); } if ($options{delete}) { + foreach my $token (@$tokens) { + $token->delete() or die "failed to delete authentication token\n"; + } printf "%d tokens removed\n", @$tokens; } @@ -269,19 +269,18 @@ sub get_token { $args{token} = $options{token}; } - my $authentication_token = + my $token = IdPAccountManager::AuthenticationToken->new(db => $db, %args); die "No corresponding token found in DB\n" - unless $authentication_token->load(); + unless $token->load(); if ($options{sp_entityid}) { die "Authentication token cannot be used for this SP\n" - unless $authentication_token->get('sp_entityid') - eq $options{sp_entityid}; + unless $token->get('sp_entityid') eq $options{sp_entityid}; } - $authentication_token->print(); + $token->print(); } @@ -297,33 +296,31 @@ sub add_token { -verbose => 0 ) unless $options{sp_entityid}; - my $authentication_token = IdPAccountManager::Data::AuthenticationToken->new( + my $token = IdPAccountManager::Data::AuthenticationToken->new( db => $db, email_address => $options{email_address}, sp_entityid => $options{sp_entityid} ); die "failed to create authentication token\n" - unless $authentication_token; + unless $token; ## First remove token if on exist for this email+SP - if ($authentication_token->load(speculative => 1)) { - die "failed to delete authentication token\n" - unless $authentication_token->delete(); + if ($token->load(speculative => 1)) { + $token->delete() or die "failed to delete authentication token\n"; - $authentication_token = IdPAccountManager::Data::AuthenticationToken->new( + $token = IdPAccountManager::Data::AuthenticationToken->new( db => $db, email_address => $options{email_address}, sp_entityid => $options{sp_entityid} ); die "failed to create authentication token\n" - unless $authentication_token; + unless $token; } - die "failed to save authentication token\n" - unless $authentication_token->save(); + $token->save() or die "failed to save authentication token\n"; - $authentication_token->print(); + $token->print(); }