Commit ca55ce9 1 parent 7ac3389 commit ca55ce9 Copy full SHA for ca55ce9
File tree 6 files changed +92
-1
lines changed
t/lib/t/MusicBrainz/Server/Controller
6 files changed +92
-1
lines changed Original file line number Diff line number Diff line change @@ -239,6 +239,28 @@ sub locked_username_search : Path('/admin/locked-usernames/search') Args(0) Requ
239
239
);
240
240
}
241
241
242
+ sub unlock_username : Path(' /admin/locked-usernames/unlock' ) Args(1) RequireAuth(account_admin) HiddenOnSlaves {
243
+ my ($self , $c , $username ) = @_ ;
244
+
245
+ my $form = $c -> form(form => ' SecureConfirm' );
246
+
247
+ if ($c -> form_posted_and_valid($form )) {
248
+ $c -> model(' MB' )-> with_transaction(sub {
249
+ $c -> model(' Editor' )-> unlock_old_editor_name($username );
250
+ });
251
+ $c -> response-> redirect($c -> uri_for_action(' /admin/locked_username_search' ));
252
+ }
253
+
254
+ $c -> stash(
255
+ current_view => ' Node' ,
256
+ component_path => ' admin/LockedUsernameUnlock' ,
257
+ component_props => {
258
+ form => $form -> TO_JSON,
259
+ username => $username ,
260
+ },
261
+ );
262
+ }
263
+
242
264
1;
243
265
244
266
=head1 COPYRIGHT AND LICENSE
Original file line number Diff line number Diff line change @@ -274,6 +274,14 @@ sub search_old_editor_names {
274
274
@{ $self -> sql-> select_single_column_array($query , $name ) };
275
275
}
276
276
277
+ sub unlock_old_editor_name {
278
+ my ($self , $name ) = @_ ;
279
+
280
+ my $query = " DELETE FROM old_editor_name WHERE name = ?" ;
281
+
282
+ $self -> sql-> do($query , $name );
283
+ }
284
+
277
285
sub update_email
278
286
{
279
287
my ($self , $editor , $email ) = @_ ;
Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ import FormRowText from '../components/FormRowText';
14
14
import FormSubmit from '../components/FormSubmit' ;
15
15
import Layout from '../layout' ;
16
16
import expand2react from '../static/scripts/common/i18n/expand2react' ;
17
+ import bracketed from '../static/scripts/common/utility/bracketed' ;
17
18
18
19
type Props = {
19
20
+ form : FormT < {
@@ -71,7 +72,15 @@ const LockedUsernameSearch = ({
71
72
{ results ?. length ? (
72
73
< ul >
73
74
{ results . map ( result => (
74
- < li key = { result } > { result } </ li >
75
+ < li key = { result } >
76
+ { result }
77
+ { ' ' }
78
+ { bracketed (
79
+ < a href = { `/admin/locked-usernames/unlock/${ result } ` } >
80
+ { 'unlock' }
81
+ </ a > ,
82
+ ) }
83
+ </ li >
75
84
) ) }
76
85
</ ul >
77
86
) : (
Original file line number Diff line number Diff line change
1
+ /*
2
+ * @flow strict-local
3
+ * Copyright (C) 2021 MetaBrainz Foundation
4
+ *
5
+ * This file is part of MusicBrainz, the open internet music database,
6
+ * and is licensed under the GPL version 2, or (at your option) any
7
+ * later version: http://www.gnu.org/licenses/gpl-2.0.txt
8
+ */
9
+
10
+ import * as React from 'react' ;
11
+
12
+ import FormCsrfToken from '../components/FormCsrfToken' ;
13
+ import FormSubmit from '../components/FormSubmit' ;
14
+ import Layout from '../layout' ;
15
+ import expand2text from '../static/scripts/common/i18n/expand2text' ;
16
+
17
+ type Props = {
18
+ + $c : CatalystContextT ,
19
+ + form : SecureConfirmFormT ,
20
+ + username : string ,
21
+ } ;
22
+
23
+ const LockedUsernameUnlock = ( {
24
+ $c,
25
+ form,
26
+ username,
27
+ } : Props ) : React . Element < typeof Layout > => (
28
+ < Layout fullWidth title = "Unlock username" >
29
+ < div id = "content" >
30
+ < h1 > { 'Unlock username' } </ h1 >
31
+ < p >
32
+ { expand2text (
33
+ `Are you sure you wish to unlock
34
+ the username “{username}” for reuse?` ,
35
+ { username : username } ,
36
+ ) }
37
+ </ p >
38
+ < form action = { $c . req . uri } method = "post" name = "confirm" >
39
+ < FormCsrfToken form = { form } />
40
+ < FormSubmit
41
+ label = "Yes, I’m sure"
42
+ name = "confirm.submit"
43
+ value = "1"
44
+ />
45
+ </ form >
46
+ </ div >
47
+ </ Layout >
48
+ ) ;
49
+
50
+ export default LockedUsernameUnlock ;
Original file line number Diff line number Diff line change @@ -39,6 +39,7 @@ module.exports = {
39
39
'admin/EmailSearch' : require ( '../admin/EmailSearch' ) ,
40
40
'admin/IpLookup' : require ( '../admin/IpLookup' ) ,
41
41
'admin/LockedUsernameSearch' : require ( '../admin/LockedUsernameSearch' ) ,
42
+ 'admin/LockedUsernameUnlock' : require ( '../admin/LockedUsernameUnlock' ) ,
42
43
'admin/attributes/Attribute' : require ( '../admin/attributes/Attribute' ) ,
43
44
'admin/attributes/CannotRemoveAttribute' : require ( '../admin/attributes/CannotRemoveAttribute' ) ,
44
45
'admin/attributes/Index' : require ( '../admin/attributes/Index' ) ,
Original file line number Diff line number Diff line change @@ -91,6 +91,7 @@ test 'Paths that allow browsing without a confirmed email address' => sub {
91
91
' Controller::Admin::email_search' ,
92
92
' Controller::Admin::ip_lookup' ,
93
93
' Controller::Admin::locked_username_search' ,
94
+ ' Controller::Admin::unlock_username' ,
94
95
' Controller::Ajax::filter_artist_recordings_form' ,
95
96
' Controller::Ajax::filter_artist_release_groups_form' ,
96
97
' Controller::Ajax::filter_artist_releases_form' ,
You can’t perform that action at this time.
0 commit comments