Skip to content
This repository was archived by the owner on Sep 23, 2023. It is now read-only.

Commit 6007566

Browse files
edg2sMatmaRex
authored andcommitted
Allow admins to bypass V+2 checks
1 parent 96887b1 commit 6007566

1 file changed

Lines changed: 39 additions & 2 deletions

File tree

new.php

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@
3333
$creator = $user ? $user->username : '';
3434
$created = time();
3535

36+
$canAdmin = can_admin();
37+
3638
/**
3739
* Check if the user has dropped their connection and delete the wiki if so
3840
*
@@ -216,14 +218,49 @@ function set_progress( float $pc, string $label ) {
216218

217219
if (
218220
$config[ 'requireVerified' ] &&
219-
( $data[0]['labels']['Verified']['approved']['_account_id'] ?? null ) !== 75
221+
( $data[0]['labels']['Verified']['approved']['_account_id'] ?? null ) !== 75 &&
222+
// Admin override
223+
!( $canAdmin && isset( $_POST['adminVerified'] ) )
220224
) {
221225
// The patch doesn't have V+2, check if the uploader is trusted
222226
$uploaderId = $data[0]['revisions'][$revision]['uploader']['_account_id'];
223227
$uploader = gerrit_query( 'accounts/' . $uploaderId, true );
224228
check_connection();
225229
if ( !is_trusted_user( $uploader['email'] ) ) {
226-
abandon( "Patch must be approved (Verified+2) by jenkins-bot, or uploaded by a trusted user" );
230+
if ( $canAdmin ) {
231+
echo '<form method="POST" action="" id="resubmit-form"><input type="hidden" name="adminVerified" value="1">';
232+
foreach ( $_POST as $k => $v ) {
233+
if ( is_array( $v ) ) {
234+
foreach ( $v as $part ) {
235+
echo '<input type="hidden" name="' . htmlentities( $k ) . '[]" value="' . htmlentities( $part ) . '">';
236+
}
237+
} else {
238+
echo '<input type="hidden" name="' . htmlentities( $k ) . '" value="' . htmlentities( $v ) . '">';
239+
}
240+
}
241+
echo '</form>';
242+
}
243+
abandon(
244+
"Patch must be approved (Verified+2) by jenkins-bot, or uploaded by a trusted user." .
245+
( can_admin() ?
246+
"<p>If you are confident all the patches are safe, as an admin you can bypass these checks:</p>" .
247+
new OOUI\ButtonWidget( [
248+
'classes' => [ 'resubmit-button' ],
249+
'label' => 'Bypass verification',
250+
'icon' => 'unLock',
251+
'flags' => [ 'destructive', 'primary' ],
252+
'infusable' => true,
253+
] ) .
254+
"<script>
255+
$( '.resubmit-button' ).each( function () {
256+
OO.ui.infuse( this ).on( 'click', function () {
257+
document.getElementById( 'resubmit-form' ).submit();
258+
} );
259+
} );
260+
</script>"
261+
: ""
262+
)
263+
);
227264
}
228265
}
229266

0 commit comments

Comments
 (0)