r60613 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r60612‎ | r60613 | r60614 >
Date:19:32, 4 January 2010
Author:ialex
Status:deferred
Tags:
Comment:
Forbid to delete the last OpenID either if the user has no password (because it was created after logging in with an OpenID with no associated account, ...) or because $wgOpenIDOnly is true
Modified paths:
  • /trunk/extensions/OpenID/OpenID.i18n.php (modified) (history)
  • /trunk/extensions/OpenID/SpecialOpenIDConvert.body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/OpenID/OpenID.i18n.php
@@ -102,6 +102,10 @@
103103 'openiddelete-text' => 'By clicking the "{{int:openiddelete-button}}" button, you will remove the OpenID $1 from your account.
104104 You will not be able anymore to login with this OpenID.',
105105 'openiddelete-button' => 'Confirm',
 106+ 'openiddeleteerrornopassword' => 'You cannot delete all your OpenIDs because your account has no password.
 107+You would not able to log in without an OpenID.',
 108+ 'openiddeleteerroropenidonly' => 'You cannot delete all your OpenIDs because your are only allowed to log in with OpenID.
 109+You would not able to log in without an OpenID.',
106110 'openiddelete-sucess' => 'The OpenID has been successfully removed from your account.',
107111 'openiddelete-error' => 'An error occured while removing the OpenID from your account.',
108112
Index: trunk/extensions/OpenID/SpecialOpenIDConvert.body.php
@@ -158,7 +158,7 @@
159159 }
160160
161161 function delete() {
162 - global $wgUser, $wgOut, $wgRequest;
 162+ global $wgUser, $wgOut, $wgRequest, $wgOpenIDOnly;
163163
164164 $openid = $wgRequest->getVal( 'url' );
165165 $user = self::getUser( $openid );
@@ -170,6 +170,18 @@
171171
172172 $wgOut->setPageTitle( wfMsg( 'openiddelete' ) );
173173
 174+ # Check if the user is removing it's last OpenID url
 175+ $urls = self::getUserUrl( $wgUser );
 176+ if ( count( $urls ) == 1 ) {
 177+ if ( $wgUser->mPassword == '' ) {
 178+ $wgOut->showErrorPage( 'openiderror', 'openiddeleteerrornopassword' );
 179+ return;
 180+ } elseif( $wgOpenIDOnly ) {
 181+ $wgOut->showErrorPage( 'openiderror', 'openiddeleteerroropenidonly' );
 182+ return;
 183+ }
 184+ }
 185+
174186 if ( $wgRequest->wasPosted() && $wgUser->matchEditToken( $wgRequest->getVal( 'wpEditToken' ), $openid ) ) {
175187 $ret = self::removeUserUrl( $wgUser, $openid );
176188 $wgOut->addWikiMsg( $ret ? 'openiddelete-sucess' : 'openiddelete-error' );

Status & tagging log