Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Roman Lacko
gitlab_api
Commits
7af9f023
Commit
7af9f023
authored
Aug 28, 2017
by
Roman Lacko
Browse files
simplify "is_admin" as the flag was added back for administrators
parent
f50dc8f7
Changes
1
Show whitespace changes
Inline
Side-by-side
GitLab/API.pm
View file @
7af9f023
...
...
@@ -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
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment