Commit 7af9f023 authored by Roman Lacko's avatar Roman Lacko
Browse files

simplify "is_admin" as the flag was added back for administrators

parent f50dc8f7
......@@ -77,6 +77,8 @@ sub new {
croak "GitLab authentication failed: ", $response->message
unless $response->is_success;
$self->{session} = $user unless defined $self->{session};
my $version = $self->version(-immortal => 1);
my $vn = defined $version
......@@ -113,21 +115,7 @@ sub die_on_error {
}
sub is_admin {
my ($self) = @_;
return $self->{is_admin} if $self->{is_admin};
my $sudo = $self->{impersonate};
$self->{is_admin} = 1;
$self->sudo(undef);
$self->{session} = $self->whoami
unless defined $self->{session};
$self->sudo($self->{session}->{username});
my ($user, $response) = $self->whoami(-response => 1, -immortal => 1);
$self->sudo($sudo);
return $self->{session}->{is_admin} = $response->is_success;
return $_[0]->{session}->{is_admin};
}
#===============================================================================
......@@ -153,7 +141,6 @@ sub login {
if ($response->is_success) {
$log->debug("login successful");
$self->{session} = $self->json->decode($response->decoded_content);
$self->{is_admin} = $self->{session}->{is_admin};
$self->{token} = $self->{session}->{private_token};
} else {
$log->fatal("login failed: " . $response->status_line);
......
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