MWX/Invite/notes: Difference between revisions
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
==Notes== | ==Notes== | ||
===MW API: selectively enabling account request=== | ===MW API: selectively enabling account request=== | ||
====dead end==== | |||
The tricky part of this is the interface with MediaWiki to selectively allow a visitor (i.e. one who has a valid invite code) to request an account when visitors are not generally allowed to access that page. | The tricky part of this is the interface with MediaWiki to selectively allow a visitor (i.e. one who has a valid invite code) to request an account when visitors are not generally allowed to access that page. | ||
Line 6: | Line 7: | ||
The ''actual'' class for handling account requests appears to be [https://doc.wikimedia.org/mediawiki-core/master/php/classSpecialCreateAccount.html SpecialCreateAccount]. Tentatively, I am descending my page from that, and overriding its methods when a valid invite has not been received. | The ''actual'' class for handling account requests appears to be [https://doc.wikimedia.org/mediawiki-core/master/php/classSpecialCreateAccount.html SpecialCreateAccount]. Tentatively, I am descending my page from that, and overriding its methods when a valid invite has not been received. | ||
====hook interception==== | |||
* '''2020-09-07''' [https://www.mediawiki.org/w/index.php?title=Topic:Vtk1jmnjcfz71wq1&action=history in desperation]... | |||
===MW API: checking for permission=== | ===MW API: checking for permission=== | ||
This bit was easier, but I did find several ways to do it. There's an obvious best way, but the others may be useful in future. | This bit was easier, but I did find several ways to do it. There's an obvious best way, but the others may be useful in future. |
Revision as of 01:18, 8 September 2020
Notes
MW API: selectively enabling account request
dead end
The tricky part of this is the interface with MediaWiki to selectively allow a visitor (i.e. one who has a valid invite code) to request an account when visitors are not generally allowed to access that page.
The class for creating pages based on the "Create account" page is apparently LoginSignupSpecialPage... except the documentation says "This feature was removed completely in version 1.33." (...and yet the file is still present in 1.34.2)
The actual class for handling account requests appears to be SpecialCreateAccount. Tentatively, I am descending my page from that, and overriding its methods when a valid invite has not been received.
hook interception
- 2020-09-07 in desperation...
MW API: checking for permission
This bit was easier, but I did find several ways to do it. There's an obvious best way, but the others may be useful in future.
First you get the object for the current User. SpecialPages have a built-in function so you don't have to use the $wgUser global:
$mwoUser = $this->getUser();
The obvious best way to find out if the user has permission to create other accounts:
$mwoUser->isAllowedToCreateAccount();
Other ways:
// 1. get groups for user, then get perms for those groups
$arGroups = $mwoUser->getEffectiveGroups();
$arPerms = \User::getGroupPermissions($arGroups);
// 2. get perms for user
$arPerms = $mwoUser->getRights();
// 3. get flag for whether the user has the "create account" permission
$canMakeUsers = $mwoUser->isAllowed('createaccount');