Merge "Show a warning in edit preview when a template loop is detected"
[lhc/web/wiklou.git] / includes / auth / AbstractSecondaryAuthenticationProvider.php
1 <?php
2 /**
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 * http://www.gnu.org/copyleft/gpl.html
17 *
18 * @file
19 * @ingroup Auth
20 */
21
22 namespace MediaWiki\Auth;
23
24 /**
25 * A base class that implements some of the boilerplate for a SecondaryAuthenticationProvider
26 *
27 * @ingroup Auth
28 * @since 1.27
29 */
30 abstract class AbstractSecondaryAuthenticationProvider extends AbstractAuthenticationProvider
31 implements SecondaryAuthenticationProvider
32 {
33
34 public function continueSecondaryAuthentication( $user, array $reqs ) {
35 throw new \BadMethodCallException( __METHOD__ . ' is not implemented.' );
36 }
37
38 public function postAuthentication( $user, AuthenticationResponse $response ) {
39 }
40
41 public function providerAllowsPropertyChange( $property ) {
42 return true;
43 }
44
45 /**
46 * @inheritDoc
47 * @note Reimplement this if self::getAuthenticationRequests( AuthManager::ACTION_REMOVE )
48 * doesn't return requests that will revoke all access for the user.
49 */
50 public function providerRevokeAccessForUser( $username ) {
51 $reqs = $this->getAuthenticationRequests(
52 AuthManager::ACTION_REMOVE, [ 'username' => $username ]
53 );
54 foreach ( $reqs as $req ) {
55 $req->username = $username;
56 $this->providerChangeAuthenticationData( $req );
57 }
58 }
59
60 public function providerAllowsAuthenticationDataChange(
61 AuthenticationRequest $req, $checkData = true
62 ) {
63 return \StatusValue::newGood( 'ignored' );
64 }
65
66 public function providerChangeAuthenticationData( AuthenticationRequest $req ) {
67 }
68
69 public function testForAccountCreation( $user, $creator, array $reqs ) {
70 return \StatusValue::newGood();
71 }
72
73 public function continueSecondaryAccountCreation( $user, $creator, array $reqs ) {
74 throw new \BadMethodCallException( __METHOD__ . ' is not implemented.' );
75 }
76
77 public function postAccountCreation( $user, $creator, AuthenticationResponse $response ) {
78 }
79
80 public function testUserForCreation( $user, $autocreate, array $options = [] ) {
81 return \StatusValue::newGood();
82 }
83
84 public function autoCreatedAccount( $user, $source ) {
85 }
86 }