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
f50dc8f7
Commit
f50dc8f7
authored
Jun 08, 2017
by
Roman Lacko
Browse files
get around removed 'is_admin' flag
parent
ea8c295e
Changes
1
Hide whitespace changes
Inline
Side-by-side
GitLab/API.pm
View file @
f50dc8f7
...
...
@@ -77,7 +77,6 @@ sub new {
croak
"
GitLab authentication failed:
",
$response
->
message
unless
$response
->
is_success
;
$self
->
{
user_is_admin
}
=
$user
->
{
is_admin
};
my
$version
=
$self
->
version
(
-
immortal
=>
1
);
my
$vn
=
defined
$version
...
...
@@ -115,7 +114,20 @@ sub die_on_error {
sub
is_admin
{
my
(
$self
)
=
@_
;
return
$self
->
{
user_is_admin
};
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
;
}
#===============================================================================
...
...
@@ -140,7 +152,9 @@ sub login {
if
(
$response
->
is_success
)
{
$log
->
debug
("
login successful
");
$self
->
{
token
}
=
$self
->
json
->
decode
(
$response
->
decoded_content
)
->
{
private_token
};
$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