Wikinaut has uploaded a new change for review.
https://gerrit.wikimedia.org/r/95076
Change subject: Bug 54677: Do account creation checks when creating users
......................................................................
Bug 54677: Do account creation checks when creating users
Change-Id: I4f8786c674b78277158b40d259e61ebdc39e696a
---
M SpecialOpenIDLogin.body.php
M SpecialOpenIDServer.body.php
2 files changed, 38 insertions(+), 14 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/OpenID
refs/changes/76/95076/1
diff --git a/SpecialOpenIDLogin.body.php b/SpecialOpenIDLogin.body.php
index e32e51e..bd93d6c 100644
--- a/SpecialOpenIDLogin.body.php
+++ b/SpecialOpenIDLogin.body.php
@@ -628,18 +628,26 @@
$user = self::getUserFromUrl( $openid );
if ( $user instanceof User ) {
+
$this->updateUser( $user, $sreg, $ax ); #
update from server
$wgUser = $user;
$this->displaySuccessLogin( $openid );
+
} else {
+
// if we are hardcoding nickname, and a valid
e-mail address was returned, create a user with this name
if ( $wgOpenIDUseEmailAsNickname ) {
+
$name = $this->getNameFromEmail(
$openid, $sreg, $ax );
+
if ( !empty( $name ) &&
$this->userNameOk( $name ) ) {
+
$wgUser = $this->createUser(
$openid, $sreg, $ax, $name );
$this->displaySuccessLogin(
$openid );
return;
+
}
+
}
$this->saveValues( $openid, $sreg, $ax );
@@ -671,27 +679,33 @@
if ( $this->updateOption( 'email', $user, $force ) ) {
// first check SREG, then AX; if both, AX takes higher
priority
$email = false;
- if ( array_key_exists( 'email', $sreg ) ) {
+
+ if ( array_key_exists( 'email', $sreg )
+ && Sanitizer::validateEmail( $sreg['email'] ) )
{
$email = $sreg['email'];
}
- if ( isset (
$ax['http://axschema.org/contact/email'][0] ) ) {
+
+ if ( isset (
$ax['http://axschema.org/contact/email'][0] )
+ && Sanitizer::validateEmail(
$ax['http://axschema.org/contact/email'][0] ) ) {
$email =
$ax['http://axschema.org/contact/email'][0];
}
+
if ( $email ) {
- // If email changed, then email a confirmation
mail
+
+ // send a confirmation mail if email has changed
+
if ( $email != $user->getEmail() ) {
- $user->setEmail( $email );
+
if ( $wgOpenIDTrustEmailAddress ) {
+ $user->setEmail( $email );
$user->confirmEmail();
} else {
- $user->invalidateEmail();
- if ( $wgEmailAuthentication &&
$email != '' ) {
- $result =
$user->sendConfirmationMail();
- if (
WikiError::isError( $result ) ) {
-
$wgOut->addWikiMsg( 'mailerror', $result->getMessage() );
- }
+ $status =
$user->setEmailWithConfirmation( $email );
+ if ( !$status->isOK() ) {
+ $wgOut->addWikiMsg(
'mailerror', $result->getMessage() );
}
}
+
}
}
}
@@ -915,18 +929,25 @@
# return the part before the @ in the e-mail address;
# look first at SREG, then AX
- if ( array_key_exists( 'email', $sreg ) ) {
+ if ( array_key_exists( 'email', $sreg )
+ && Sanitizer::validateEmail( $sreg['email'] ) ) {
+
$addr = explode( "@", $sreg['email'] );
if ( $addr ) {
return $addr[0];
}
+
}
- if ( isset( $ax['http://axschema.org/contact/email'][0] ) ) {
+ if ( isset( $ax['http://axschema.org/contact/email'][0] )
+ && Sanitizer::validateEmail(
$ax['http://axschema.org/contact/email'][0] ) ) {
+
$addr = explode( "@",
$ax['http://axschema.org/contact/email'][0] );
+
if ( $addr ) {
return $addr[0];
}
+
}
}
diff --git a/SpecialOpenIDServer.body.php b/SpecialOpenIDServer.body.php
index 5ccc771..2d9723a 100644
--- a/SpecialOpenIDServer.body.php
+++ b/SpecialOpenIDServer.body.php
@@ -635,8 +635,11 @@
$user->setRealName( $value );
return true;
case 'email':
- # FIXME: deal with validation
- $user->setEmail( $value );
+ if ( Sanitizer::validateEmail( $value ) ) {
+ $user->setEmail( $value );
+ } else {
+ $user->setEmail( "" );
+ }
return true;
case 'language':
$user->setOption( 'language', $value );
--
To view, visit https://gerrit.wikimedia.org/r/95076
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I4f8786c674b78277158b40d259e61ebdc39e696a
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/OpenID
Gerrit-Branch: master
Gerrit-Owner: Wikinaut <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits