Skip to content

Commit 1a69423

Browse files
Add check that user no longer exists in MediaWiki when approving DPA
1 parent b5a2245 commit 1a69423

File tree

4 files changed

+21
-0
lines changed

4 files changed

+21
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ The main reasoning behind this choice is the software is not built to be extende
1919
- Added a user event when investigation is created from a report, rather than only when it is manually created separately.
2020
- Added validation to require supplying evidence to reports.
2121
- Added the `barryvdh/laravel-dompdf` library for generating PDFs from investigations.
22+
- Added check that a user no longer exists in MediaWiki when approving a DPA.
2223

2324
### Fixed
2425

app/Http/Controllers/DPAController.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
use Illuminate\Contracts\View\View;
1414
use Illuminate\Http\RedirectResponse;
1515
use Illuminate\Http\Request;
16+
use Illuminate\Support\Facades\Http;
1617
use function back;
1718
use function now;
1819
use function redirect;
@@ -99,6 +100,19 @@ public function create(): View
99100
public function update( DPA $dpa, Request $request ): RedirectResponse
100101
{
101102
if ( $request->boolean( 'approve' ) ) {
103+
$response = Http::get( 'https://login.miraheze.org/w/api.php', [
104+
'format' => 'json',
105+
'action' => 'query',
106+
'meta' => 'globaluserinfo',
107+
'guiuser' => $dpa->user->username,
108+
] );
109+
110+
if ( isset( $response['query']['globaluserinfo']['id'] ) ) {
111+
// Username still exists
112+
$request->session()->flash( 'errorFlash', __( 'username-still-exists' ) );
113+
return back();
114+
}
115+
102116
$dpa->update( [ 'completed' => now() ] );
103117
$dpa->user->update( [
104118
'username' => 'MirahezeGDPR ' . $dpa->id,

resources/lang/en.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,7 @@
244244
"username": "Username",
245245
"username-exist": "The username must be a valid Miraheze username.",
246246
"username-not-same": "You are not currently logged in as this user account.",
247+
"username-still-exists": "This user still exists in MediaWiki. It must be processed in MediaWiki before you can approve this request.",
247248
"users": "Users",
248249
"users-list": "List All Users",
249250
"wiki": "Wiki",

resources/views/dpa/view.blade.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44
</x-slot>
55
<x-slot name="content">
66
<h3 class="text-dark mb-4 fw-semibold">{{ __( 'dpa-new' ) }}</h3>
7+
@if ( session( 'errorFlash' ) )
8+
<div class="alert alert-danger text-center shadow-sm border-0">
9+
{{ session( 'errorFlash' ) }}
10+
</div>
11+
@endif
712
<div class="row mb-3">
813
@if ( $dpa->reject )
914
<div role="alert" class="alert alert-danger text-center shadow-sm border-0">

0 commit comments

Comments
 (0)