Movatterモバイル変換


[0]ホーム

URL:


MediaWiki master
SpecialCreateAccount.php
Go to the documentation of this file.
1<?php
7namespaceMediaWiki\Specials;
8
9useMediaWiki\Auth\AuthManager;
10useMediaWiki\Context\RequestContext;
11useMediaWiki\Exception\ErrorPageError;
12useMediaWiki\Language\FormatterFactory;
13useMediaWiki\Logger\LoggerFactory;
14useMediaWiki\SpecialPage\LoginSignupSpecialPage;
15useMediaWiki\Title\Title;
16useMediaWiki\User\UserIdentity;
17useMediaWiki\User\UserIdentityUtils;
18useStatusValue;
19
26classSpecialCreateAccountextendsLoginSignupSpecialPage {
28protectedstatic$allowedActions = [
29 AuthManager::ACTION_CREATE,
30 AuthManager::ACTION_CREATE_CONTINUE
31 ];
32
34protectedstatic$messages = [
35'authform-newtoken' =>'nocookiesfornew',
36'authform-notoken' =>'sessionfailure',
37'authform-wrongtoken' =>'sessionfailure',
38 ];
39
40privateFormatterFactory $formatterFactory;
41
42privateUserIdentityUtils $identityUtils;
43
44publicfunction__construct(
45AuthManager $authManager,
46FormatterFactory $formatterFactory,
47UserIdentityUtils $identityUtils
48 ) {
49 parent::__construct('CreateAccount','createaccount' );
50
51 $this->setAuthManager( $authManager );
52 $this->formatterFactory = $formatterFactory;
53 $this->identityUtils = $identityUtils;
54 }
55
57publicfunctiondoesWrites() {
58returntrue;
59 }
60
61publicfunctioncheckPermissions() {
62 parent::checkPermissions();
63
64 $performer = $this->getAuthority();
65 $authManager = $this->getAuthManager();
66
67 $status = $this->mPosted ?
68 $authManager->authorizeCreateAccount( $performer ) :
69 $authManager->probablyCanCreateAccount( $performer );
70
71if ( !$status->isGood() ) {
72 $formatter = $this->formatterFactory->getStatusFormatter( $this->getContext() );
73$messages = [];
74foreach ( $status->getMessages() as $message ) {
75$messages[] = $message->getKey();
76 }
77 $this->logAuthResult(
78false, $performer->getUser(),
79 implode('|',$messages )
80 );
81thrownewErrorPageError(
82'createacct-error',
83 $formatter->getMessage( $status )
84 );
85 }
86 }
87
89protectedfunctiongetLoginSecurityLevel() {
90returnfalse;
91 }
92
94protectedfunctiongetDefaultAction($subPage ) {
95return AuthManager::ACTION_CREATE;
96 }
97
99publicfunctiongetDescription() {
100return $this->msg('createaccount' );
101 }
102
104protectedfunctionisSignup() {
105returntrue;
106 }
107
115protectedfunctionsuccessfulAction( $direct =false, $extraMessages =null ) {
116 $session = $this->getRequest()->getSession();
117 $user = $this->targetUser ?: $this->getUser();
118
119 $injected_html ='';
120if ( $direct ) {
121 # Only save preferences if the user is not creating an account for someone else.
122if ( !$this->proxyAccountCreation ) {
123 $this->getHookRunner()->onAddNewAccount( $user,false );
124 }else {
125 $byEmail =false;// FIXME no way to set this
126
127 $this->getHookRunner()->onAddNewAccount( $user, $byEmail );
128
129 $out = $this->getOutput();
130// @phan-suppress-next-line PhanImpossibleCondition
131 $out->setPageTitleMsg( $this->msg( $byEmail ?'accmailtitle' :'accountcreated' ) );
132// @phan-suppress-next-line PhanImpossibleCondition
133if ( $byEmail ) {
134 $out->addWikiMsg('accmailtext', $user->getName(), $user->getEmail() );
135 }else {
136 $out->addWikiMsg('accountcreatedtext', $user->getName() );
137 }
138
139 $rt = Title::newFromText( $this->mReturnTo );
140 $out->addReturnTo(
141 ( $rt && !$rt->isExternal() ) ? $rt : $this->getPageTitle(),
142wfCgiToArray( $this->mReturnToQuery )
143 );
144return;
145 }
146 $this->getHookRunner()->onUserLoginComplete( $user, $injected_html, $direct );
147 }
148
149 $this->clearToken();
150
151 # Run any hooks; display injected HTML
152 $welcome_creation_msg ='welcomecreation-msg';
158 $this->getHookRunner()->onBeforeWelcomeCreation( $welcome_creation_msg, $injected_html );
159
160 $this->showSuccessPage('signup',
161// T308471: ensure username is plaintext (aka escaped)
162 $this->msg('welcomeuser' )->plaintextParams( $this->getUser()->getName() ),
163 $welcome_creation_msg, $injected_html, $extraMessages );
164 }
165
167protectedfunctiongetToken() {
168return $this->getRequest()->getSession()->getToken('','createaccount' );
169 }
170
171protectedfunctionclearToken() {
172 $this->getRequest()->getSession()->resetToken('createaccount' );
173 }
174
176protectedfunctiongetTokenName() {
177return'wpCreateaccountToken';
178 }
179
181protectedfunctiongetGroupName() {
182return'users';
183 }
184
186protectedfunctionlogAuthResult($success,UserIdentity $performer, $status =null ) {
187 LoggerFactory::getInstance('authevents' )->info('Account creation attempt', [
188'event' =>'accountcreation',
189'successful' =>$success,
190'accountType' => $this->identityUtils->getShortUserTypeInternal( $performer ),
191'status' => strval( $status )
192 ] + RequestContext::getMain()->getRequest()->getSecurityLogContext( $performer ) );
193 }
194}
195
197class_alias( SpecialCreateAccount::class,'SpecialCreateAccount' );
wfCgiToArray
wfCgiToArray( $query)
This is the logical opposite of wfArrayToCgi(): it accepts a query string as its argument and returns...
DefinitionGlobalFunctions.php:381
$success
$success
DefinitionNoLocalSettings.php:31
MediaWiki\Auth\AuthManager
AuthManager is the authentication system in MediaWiki and serves entry point for authentication.
DefinitionAuthManager.php:107
MediaWiki\Context\RequestContext
Group all the pieces relevant to the context of a request into one instance.
DefinitionRequestContext.php:53
MediaWiki\Exception\ErrorPageError
An error page which can definitely be safely rendered using the OutputPage.
DefinitionErrorPageError.php:21
MediaWiki\Language\FormatterFactory
Factory for formatters of common complex objects.
DefinitionFormatterFactory.php:19
MediaWiki\Logger\LoggerFactory
Create PSR-3 logger objects.
DefinitionLoggerFactory.php:32
MediaWiki\SpecialPage\AuthManagerSpecialPage\$subPage
string $subPage
Subpage of the special page.
DefinitionAuthManagerSpecialPage.php:59
MediaWiki\SpecialPage\AuthManagerSpecialPage\getRequest
getRequest()
Get the WebRequest being used for this instance.WebRequest 1.18
DefinitionAuthManagerSpecialPage.php:96
MediaWiki\SpecialPage\LoginSignupSpecialPage
Holds shared logic for login and account creation pages.
DefinitionLoginSignupSpecialPage.php:47
MediaWiki\SpecialPage\LoginSignupSpecialPage\showSuccessPage
showSuccessPage( $type, $title, $msgname, $injected_html, $extraMessages)
Show the success page.
DefinitionLoginSignupSpecialPage.php:522
MediaWiki\SpecialPage\SpecialPage\getUser
getUser()
Shortcut to get the User executing this instance.
DefinitionSpecialPage.php:884
MediaWiki\SpecialPage\SpecialPage\setAuthManager
setAuthManager(AuthManager $authManager)
Set the injected AuthManager from the special page constructor.
DefinitionSpecialPage.php:561
MediaWiki\SpecialPage\SpecialPage\getPageTitle
getPageTitle( $subpage=false)
Get a self-referential title object.
DefinitionSpecialPage.php:828
MediaWiki\SpecialPage\SpecialPage\getContext
getContext()
Gets the context this SpecialPage is executed in.
DefinitionSpecialPage.php:848
MediaWiki\SpecialPage\SpecialPage\msg
msg( $key,... $params)
Wrapper around wfMessage that sets the current context.
DefinitionSpecialPage.php:985
MediaWiki\SpecialPage\SpecialPage\getOutput
getOutput()
Get the OutputPage being used for this instance.
DefinitionSpecialPage.php:874
MediaWiki\SpecialPage\SpecialPage\getAuthManager
getAuthManager()
DefinitionSpecialPage.php:571
MediaWiki\SpecialPage\SpecialPage\getAuthority
getAuthority()
Shortcut to get the Authority executing this instance.
DefinitionSpecialPage.php:894
MediaWiki\SpecialPage\SpecialPage\getName
getName()
Get the canonical, unlocalized name of this special page without namespace.
DefinitionSpecialPage.php:211
MediaWiki\SpecialPage\SpecialPage\getHookRunner
getHookRunner()
DefinitionSpecialPage.php:1194
MediaWiki\Specials\SpecialCreateAccount
Implements Special:CreateAccount.
DefinitionSpecialCreateAccount.php:26
MediaWiki\Specials\SpecialCreateAccount\getTokenName
getTokenName()
string
DefinitionSpecialCreateAccount.php:176
MediaWiki\Specials\SpecialCreateAccount\logAuthResult
logAuthResult( $success, UserIdentity $performer, $status=null)
Logs to the authmanager-stats channel.
DefinitionSpecialCreateAccount.php:186
MediaWiki\Specials\SpecialCreateAccount\getToken
getToken()
Returns the CSRF token.to override Token
DefinitionSpecialCreateAccount.php:167
MediaWiki\Specials\SpecialCreateAccount\$messages
static $messages
DefinitionSpecialCreateAccount.php:34
MediaWiki\Specials\SpecialCreateAccount\$allowedActions
static $allowedActions
DefinitionSpecialCreateAccount.php:28
MediaWiki\Specials\SpecialCreateAccount\getDefaultAction
getDefaultAction( $subPage)
Get the default action for this special page if none is given via URL/POST data.Subclasses should ove...
DefinitionSpecialCreateAccount.php:94
MediaWiki\Specials\SpecialCreateAccount\isSignup
isSignup()
bool
DefinitionSpecialCreateAccount.php:104
MediaWiki\Specials\SpecialCreateAccount\getLoginSecurityLevel
getLoginSecurityLevel()
to override bool|string
DefinitionSpecialCreateAccount.php:89
MediaWiki\Specials\SpecialCreateAccount\getDescription
getDescription()
Returns the name that goes in the <h1> in the special page itself, and also the name that will be l...
DefinitionSpecialCreateAccount.php:99
MediaWiki\Specials\SpecialCreateAccount\__construct
__construct(AuthManager $authManager, FormatterFactory $formatterFactory, UserIdentityUtils $identityUtils)
DefinitionSpecialCreateAccount.php:44
MediaWiki\Specials\SpecialCreateAccount\getGroupName
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
DefinitionSpecialCreateAccount.php:181
MediaWiki\Specials\SpecialCreateAccount\clearToken
clearToken()
DefinitionSpecialCreateAccount.php:171
MediaWiki\Specials\SpecialCreateAccount\checkPermissions
checkPermissions()
Checks if userCanExecute, and if not throws a PermissionsError.
DefinitionSpecialCreateAccount.php:61
MediaWiki\Specials\SpecialCreateAccount\successfulAction
successfulAction( $direct=false, $extraMessages=null)
Run any hooks registered for logins, then display a message welcoming the user.
DefinitionSpecialCreateAccount.php:115
MediaWiki\Specials\SpecialCreateAccount\doesWrites
doesWrites()
Indicates whether POST requests to this special page require write access to the wiki....
DefinitionSpecialCreateAccount.php:57
MediaWiki\Title\Title
Represents a title within MediaWiki.
DefinitionTitle.php:69
MediaWiki\User\UserIdentityUtils
Convenience functions for interpreting UserIdentity objects using additional services or config.
DefinitionUserIdentityUtils.php:13
StatusValue
Generic operation result class Has warning/error list, boolean status and arbitrary value.
DefinitionStatusValue.php:41
MediaWiki\User\UserIdentity
Interface for objects representing user identity.
DefinitionUserIdentity.php:24
MediaWiki\Specials

[8]ページ先頭

©2009-2025 Movatter.jp