Passed
Push — master ( a4754c...e0c6ec )
by Nazar
05:32
created

Controller::get_data_by_confirmation_code()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 1
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
1
<?php
2
/**
3
 * @package   HybridAuth
4
 * @category  modules
5
 * @author    Nazar Mokrynskyi <[email protected]>
6
 * @copyright Copyright (c) 2011-2017, Nazar Mokrynskyi
7
 * @license   MIT License, see license.txt
8
 */
9
namespace cs\modules\HybridAuth;
10
use
11
	Exception,
12
	h,
13
	Hybrid_Endpoint,
14
	cs\Config,
15
	cs\Event,
16
	cs\ExitException,
17
	cs\Key,
18
	cs\Language\Prefix,
19
	cs\Mail,
20
	cs\Page,
21
	cs\Request,
22
	cs\Response,
23
	cs\Session,
24
	cs\User;
25
26
/**
27
 * Provides next events:
28
 *  HybridAuth/registration/before
29
 *  [
30
 *   'provider'   => provider   //Provider name
31
 *   'email'      => email      //Email
32
 *   'identifier' => identifier //Identifier given by provider
33
 *   'profile'    => profile    //Profile url
34
 *  ]
35
 *
36
 *  HybridAuth/add_session/before
37
 *  [
38
 *   'adapter'  => $Adapter //instance of Hybrid_Provider_Adapter
39
 *   'provider' => provider //Provider name
40
 *  ]
41
 *
42
 *  HybridAuth/add_session/after
43
 *  [
44
 *   'adapter'  => $Adapter //instance of Hybrid_Provider_Adapter
45
 *   'provider' => provider //Provider name
46
 *  ]
47
 */
48
class Controller {
49
	/**
50
	 * @param Request  $Request
51
	 * @param Response $Response
52
	 *
53
	 * @throws ExitException
54
	 */
55
	public static function index ($Request, $Response) {
56
		$route = $Request->route;
57
		/**
58
		 * This should be present in any case, if not - exit from here
59
		 */
60
		if (!isset($route[0])) {
61
			self::redirect();
62
			return;
63
		}
64
		$Config             = Config::instance();
65
		$Page               = Page::instance();
66
		$User               = User::instance();
67
		$Social_integration = Social_integration::instance();
68
		$L                  = new Prefix('hybridauth_');
69
		/**
70
		 * Confirmation of accounts merging
71
		 */
72
		if ($route[0] == 'merge_confirmation') {
73
			self::merge_confirmation($route, $Page, $L);
74
			return;
75
		}
76
		$provider = $route[0];
77
		/**
78
		 * Authenticated users are not allowed to sign in, also provider should exist and be enabled
79
		 */
80
		if (
81
			$User->user() ||
82
			!@$Config->module('HybridAuth')->providers[$provider]['enabled']
0 ignored issues
show
Bug Best Practice introduced by
The property providers does not exist on cs\Config\Module_Properties. Since you implemented __get, consider adding a @property annotation.
Loading history...
83
		) {
84
			self::redirect();
85
			return;
86
		}
87
		$referer = $Request->header('referer');
88
		/**
89
		 * If referer is internal website address, but not HybridAuth module - save referer to cookie
90
		 */
91
		if (
92
			strpos($referer, $Config->base_url()) === 0 &&
93
			strpos($referer, $Config->base_url().'/HybridAuth') === false
94
		) {
95
			$Response->cookie('HybridAuth_referer', $referer, 0, true);
96
		}
97
		require_once __DIR__.'/Hybrid/Auth.php';
98
		require_once __DIR__.'/Hybrid/Endpoint.php';
99
		/**
100
		 * Handle authentication endpoint
101
		 */
102
		if (isset($route[1]) && $route[1] == 'endpoint') {
103
			/**
104
			 * `$rc[2]` should be present and contain special hash for security reasons (this is called as callback from provider)
105
			 */
106
			if (
107
				!isset($route[2]) ||
108
				strpos($route[2], md5($provider.Session::instance()->get_id())) !== 0
0 ignored issues
show
Bug introduced by
Are you sure cs\Session::instance()->get_id() of type false|string can be used in concatenation? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

108
				strpos($route[2], md5($provider./** @scrutinizer ignore-type */ Session::instance()->get_id())) !== 0
Loading history...
109
			) {
110
				self::redirect();
111
				return;
112
			}
113
			Hybrid_Endpoint::process($_REQUEST);
114
			return;
115
		}
116
		/**
117
		 * If user did not specified email
118
		 */
119
		if (!isset($_POST['email'])) {
120
			self::email_not_specified($Config, $provider, $Social_integration, $User, $Page, $L);
121
			return;
122
		}
123
		/**
124
		 * If user specified email
125
		 */
126
		self::email_was_specified($provider, $Social_integration, $User, $Page, $L, $Config, $Response);
127
	}
128
	/**
129
	 * Redirect to referer or home page
130
	 *
131
	 * @param bool $with_delay If `true` - redirect will be made in 5 seconds after page load
132
	 *
133
	 * @throws ExitException
134
	 */
135
	protected static function redirect ($with_delay = false) {
136
		$Response    = Response::instance();
137
		$redirect_to = Request::instance()->cookie('HybridAuth_referer') ?: Config::instance()->base_url();
138
		$Response->cookie('HybridAuth_referer', '');
0 ignored issues
show
Bug introduced by
The method cookie() does not exist on cs\False_class. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

138
		$Response->/** @scrutinizer ignore-call */ 
139
             cookie('HybridAuth_referer', '');
Loading history...
139
		if ($with_delay) {
140
			$Response->header('refresh', "5; url=$redirect_to");
0 ignored issues
show
Bug introduced by
The method header() does not exist on cs\False_class. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

140
			$Response->/** @scrutinizer ignore-call */ 
141
              header('refresh', "5; url=$redirect_to");
Loading history...
141
		} else {
142
			$Response->redirect($redirect_to, 301);
0 ignored issues
show
Bug introduced by
The method redirect() does not exist on cs\False_class. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

142
			$Response->/** @scrutinizer ignore-call */ 
143
              redirect($redirect_to, 301);
Loading history...
143
			Page::instance()->interface = false;
144
			throw new ExitException;
145
		}
146
	}
147
	/**
148
	 * @param string[] $route
149
	 * @param Page     $Page
150
	 * @param Prefix   $L
151
	 *
152
	 * @throws ExitException
153
	 */
154
	protected static function merge_confirmation ($route, $Page, $L) {
155
		if (!isset($route[1])) {
156
			self::redirect();
157
		}
158
		/**
159
		 * Check confirmation code
160
		 */
161
		$data = self::get_data_by_confirmation_code($route[1]);
162
		if (!$data) {
0 ignored issues
show
introduced by
The condition ! $data can never be false.
Loading history...
163
			$Page->warning($L->merge_confirm_code_invalid);
0 ignored issues
show
Bug Best Practice introduced by
The property merge_confirm_code_invalid does not exist on cs\Language\Prefix. Since you implemented __get, consider adding a @property annotation.
Loading history...
164
			return;
165
		}
166
		/**
167
		 * If confirmation key is valid  - merge social profile with main account
168
		 */
169
		self::add_integration_create_session(
170
			$data['id'],
171
			$data['provider'],
172
			$data['identifier'],
173
			$data['profile']
174
		);
175
		self::save_hybridauth_session();
176
		$Page->success(
177
			$L->merging_confirmed_successfully($L->{$data['provider']})
178
		);
179
	}
180
	/**
181
	 * @param int    $id
182
	 * @param string $provider
183
	 * @param string $identifier
184
	 * @param string $profile
185
	 */
186
	protected static function add_integration_create_session ($id, $provider, $identifier, $profile) {
187
		Social_integration::instance()->add($id, $provider, $identifier, $profile);
188
		$User = User::instance();
189
		/**
190
		 * If user was not activated before - activate him
191
		 */
192
		if ($User->get('status', $id) == User::STATUS_NOT_ACTIVATED) {
193
			$User->set('status', User::STATUS_ACTIVE, $id);
194
		}
195
		self::add_session_and_update_data($id, $provider, true);
196
	}
197
	/**
198
	 * Save HybridAuth session in user's data in order to restore it next time when calling `get_hybridauth_instance()`
199
	 */
200
	protected static function save_hybridauth_session () {
201
		$User = User::instance();
202
		$User->set_data(
203
			'HybridAuth_session',
204
			array_merge(
205
				$User->get_data('HybridAuth_session') ?: [],
206
				unserialize(get_hybridauth_instance()->getSessionData())
207
			)
208
		);
209
	}
210
	/**
211
	 * @param string $code
212
	 *
213
	 * @return false|array
214
	 */
215
	protected static function get_data_by_confirmation_code ($code) {
216
		return Key::instance()->get(
217
			Config::instance()->module('HybridAuth')->db('integration'),
218
			$code,
219
			true
220
		);
221
	}
222
	/**
223
	 * @param Config             $Config
224
	 * @param string             $provider
225
	 * @param Social_integration $Social_integration
226
	 * @param User               $User
227
	 * @param Page               $Page
228
	 * @param Prefix             $L
229
	 *
230
	 * @throws ExitException
231
	 */
232
	protected static function email_not_specified ($Config, $provider, $Social_integration, $User, $Page, $L) {
233
		$profile = self::authenticate_hybridauth($provider);
234
		/**
235
		 * Check whether this account was already registered in system. If registered - make login
236
		 */
237
		$user = $Social_integration->find_integration($provider, $profile->identifier);
238
		if (
239
			$user &&
240
			$User->get('status', $user) == User::STATUS_ACTIVE
241
		) {
242
			self::add_session_and_update_data($user, $provider);
243
			return;
244
		}
245
		if (!Config::instance()->core['allow_user_registration']) {
246
			Page::instance()
247
				->title($L->registration_prohibited)
0 ignored issues
show
Bug Best Practice introduced by
The property registration_prohibited does not exist on cs\Language\Prefix. Since you implemented __get, consider adding a @property annotation.
Loading history...
248
				->warning($L->registration_prohibited);
249
			return;
250
		}
251
		$email = strtolower($profile->emailVerified ?: $profile->email);
252
		/**
253
		 * If integrated service does not returns email - ask user for email
254
		 */
255
		if (!$email) {
256
			self::email_form($Page, $L);
257
			return;
258
		}
259
		/**
260
		 * Search for user with such email
261
		 */
262
		$user = $User->get_id(hash('sha224', $email));
263
		/**
264
		 * If email is already registered - merge social profile with main account
265
		 */
266
		if ($user) {
267
			self::add_integration_create_session($user, $provider, $profile->identifier, $profile->profileURL);
268
			return;
269
		}
270
		/**
271
		 * If user doesn't exists - try to register user
272
		 */
273
		$result = self::try_to_register($provider, $email, false);
274
		if (!$result) {
275
			return;
276
		}
277
		$Social_integration->add($result['id'], $provider, $profile->identifier, $profile->profileURL);
278
		/**
279
		 * Registration is successful, confirmation is not needed
280
		 */
281
		self::finish_registration_send_email($Config, $result['id'], $result['password'], $provider);
282
	}
283
	/**
284
	 * Returns profile
285
	 *
286
	 * @param string $provider
287
	 *
288
	 * @return \Hybrid_User_Profile
289
	 *
290
	 * @throws ExitException
291
	 */
292
	protected static function authenticate_hybridauth ($provider) {
293
		try {
294
			return get_hybridauth_instance($provider)::authenticate($provider)->getUserProfile();
295
		} catch (ExitException $e) {
296
			throw $e;
297
		} catch (Exception $e) {
298
			trigger_error($e->getMessage());
299
			self::redirect(true);
300
			throw new ExitException;
301
		}
302
	}
303
	/**
304
	 * @throws ExitException
305
	 *
306
	 * @param string $provider
307
	 * @param string $email
308
	 * @param bool   $email_from_user
309
	 *
310
	 * @return array|false|string
311
	 */
312
	protected static function try_to_register ($provider, $email, $email_from_user) {
313
		$profile = self::authenticate_hybridauth($provider);
314
		if (!Event::instance()->fire(
315
			'HybridAuth/registration/before',
316
			[
317
				'provider'   => $provider,
318
				'email'      => $email,
319
				'identifier' => $profile->identifier,
320
				'profile'    => $profile->profileURL
321
			]
322
		)
323
		) {
324
			return false;
325
		}
326
		$L      = new Prefix('hybridauth_');
327
		$Page   = Page::instance();
328
		$User   = User::instance();
329
		$result = $email_from_user ? $User->registration($email) : $User->registration($email, false, false);
330
		if (!$result && $email_from_user) {
331
			$Page
332
				->title($L->please_type_correct_email)
0 ignored issues
show
Bug Best Practice introduced by
The property please_type_correct_email does not exist on cs\Language\Prefix. Since you implemented __get, consider adding a @property annotation.
Loading history...
333
				->warning($L->please_type_correct_email);
334
			self::email_form($Page, $L);
335
			return false;
336
		}
337
		if (!$result || $result == 'error') {
338
			$Page
339
				->title($L->registration_server_error)
0 ignored issues
show
Bug Best Practice introduced by
The property registration_server_error does not exist on cs\Language\Prefix. Since you implemented __get, consider adding a @property annotation.
Loading history...
340
				->warning($L->registration_server_error);
341
			self::redirect(true);
342
			return false;
343
		}
344
		return $result;
345
	}
346
	/**
347
	 * @param Page   $Page
348
	 * @param Prefix $L
349
	 */
350
	protected static function email_form ($Page, $L) {
351
		$Page->content(
352
			h::{'cs-form form'}(
353
				h::{'p.cs-text-center'}(
354
					$L->please_type_your_email.':'.
0 ignored issues
show
Bug Best Practice introduced by
The property please_type_your_email does not exist on cs\Language\Prefix. Since you implemented __get, consider adding a @property annotation.
Loading history...
355
					h::{'input[name=email]'}(
356
						isset($_POST['email']) ? $_POST['email'] : ''
357
					)
358
				).
359
				h::{'cs-button button[type=submit]'}(
360
					$L->submit
0 ignored issues
show
Bug Best Practice introduced by
The property submit does not exist on cs\Language\Prefix. Since you implemented __get, consider adding a @property annotation.
Loading history...
361
				)
362
			)
363
		);
364
	}
365
	/**
366
	 * @param string             $provider
367
	 * @param Social_integration $Social_integration
368
	 * @param User               $User
369
	 * @param Page               $Page
370
	 * @param Prefix             $L
371
	 * @param Config             $Config
372
	 * @param Response           $Response
373
	 *
374
	 * @throws ExitException
375
	 */
376
	protected static function email_was_specified ($provider, $Social_integration, $User, $Page, $L, $Config, $Response) {
377
		$profile = self::authenticate_hybridauth($provider);
378
		/**
379
		 * Try to register user
380
		 */
381
		$result = self::try_to_register($provider, $_POST['email'], true);
382
		if (!$result) {
383
			return;
384
		}
385
		$core_url = $Config->core_url();
386
		/**
387
		 * If email is already registered
388
		 */
389
		if ($result == 'exists') {
390
			/**
391
			 * Send merging confirmation email
392
			 */
393
			$id                    = $User->get_id(hash('sha224', strtolower($_POST['email'])));
394
			$HybridAuth_data['id'] = $id;
395
			$confirmation_code     = self::set_data_generate_confirmation_code($HybridAuth_data);
396
			$title                 = $L->merge_confirmation_mail_title($Config->core['site_name']);
0 ignored issues
show
Bug introduced by
The method merge_confirmation_mail_title() does not exist on cs\Language\Prefix. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

396
			/** @scrutinizer ignore-call */ 
397
   $title                 = $L->merge_confirmation_mail_title($Config->core['site_name']);
Loading history...
397
			$body                  = $L->merge_confirmation_mail_body(
0 ignored issues
show
Bug introduced by
The method merge_confirmation_mail_body() does not exist on cs\Language\Prefix. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

397
			/** @scrutinizer ignore-call */ 
398
   $body                  = $L->merge_confirmation_mail_body(
Loading history...
398
				$User->username($id) ?: strstr($_POST['email'], '@', true),
399
				$Config->core['site_name'],
400
				$L->$provider,
401
				"$core_url/HybridAuth/merge_confirmation/$confirmation_code",
402
				$L->time($Config->core['registration_confirmation_time'], 'd')
403
			);
404
			if (self::send_registration_mail($_POST['email'], $title, $body)) {
405
				$Response->cookie('HybridAuth_referer', '');
406
				$Page->content(
407
					h::p(
0 ignored issues
show
Bug introduced by
The method p() does not exist on h. Since you implemented __callStatic, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

407
					h::/** @scrutinizer ignore-call */ 
408
        p(
Loading history...
408
						$L->merge_confirmation($L->$provider)
0 ignored issues
show
Bug introduced by
The method merge_confirmation() does not exist on cs\Language\Prefix. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

408
						$L->/** @scrutinizer ignore-call */ 
409
          merge_confirmation($L->$provider)
Loading history...
409
					)
410
				);
411
			}
412
			return;
413
		}
414
		/**
415
		 * Registration is successful and confirmation is not required
416
		 */
417
		if ($result['reg_key'] === true) {
418
			$Social_integration->add($result['id'], $provider, $profile->identifier, $profile->profileURL);
419
			self::finish_registration_send_email($Config, $result['id'], $result['password'], $provider);
420
			return;
421
		}
422
		/**
423
		 * Registration is successful, but confirmation is needed
424
		 */
425
		$title = $L->registration_need_confirmation_mail($Config->core['site_name']);
0 ignored issues
show
Bug introduced by
The method registration_need_confirmation_mail() does not exist on cs\Language\Prefix. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

425
		/** @scrutinizer ignore-call */ 
426
  $title = $L->registration_need_confirmation_mail($Config->core['site_name']);
Loading history...
426
		$body  = $L->registration_need_confirmation_mail_body(
0 ignored issues
show
Bug introduced by
The method registration_need_confirmation_mail_body() does not exist on cs\Language\Prefix. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

426
		/** @scrutinizer ignore-call */ 
427
  $body  = $L->registration_need_confirmation_mail_body(
Loading history...
427
			self::get_adapter($provider)->getUserProfile()->displayName ?: strstr($result['email'], '@', true),
428
			$Config->core['site_name'],
429
			"$core_url/profile/registration_confirmation/$result[reg_key]",
430
			$L->time($Config->core['registration_confirmation_time'], 'd')
431
		);
432
		if (self::send_registration_mail($_POST['email'], $title, $body)) {
433
			self::update_data($provider);
434
			$Response->cookie('HybridAuth_referer', '');
435
			$Page->content($L->registration_confirmation);
0 ignored issues
show
Bug Best Practice introduced by
The property registration_confirmation does not exist on cs\Language\Prefix. Since you implemented __get, consider adding a @property annotation.
Loading history...
436
		}
437
	}
438
	/**
439
	 * @param string $email
440
	 * @param string $title
441
	 * @param string $body
442
	 *
443
	 * @return bool
444
	 *
445
	 * @throws ExitException
446
	 */
447
	protected static function send_registration_mail ($email, $title, $body) {
448
		$result = Mail::instance()->send_to($email, $title, $body);
449
		/**
450
		 * If mail sending failed - cancel registration, show error message and redirect to referrer page
451
		 */
452
		if (!$result) {
453
			User::instance()->registration_cancel();
454
			$L = new Prefix('hybridauth_');
455
			Page::instance()
456
				->title($L->registration_mail_sending_error_title)
0 ignored issues
show
Bug Best Practice introduced by
The property registration_mail_sending_error_title does not exist on cs\Language\Prefix. Since you implemented __get, consider adding a @property annotation.
Loading history...
457
				->warning($L->registration_mail_sending_error);
0 ignored issues
show
Bug Best Practice introduced by
The property registration_mail_sending_error does not exist on cs\Language\Prefix. Since you implemented __get, consider adding a @property annotation.
Loading history...
458
			self::redirect(true);
459
		}
460
		return $result;
461
	}
462
	/**
463
	 * @param array $data
464
	 *
465
	 * @return false|string
466
	 *
467
	 * @throws ExitException
468
	 */
469
	protected static function set_data_generate_confirmation_code ($data) {
470
		$code = Key::instance()->add(
471
			Config::instance()->module('HybridAuth')->db('integration'),
472
			false,
473
			$data,
474
			time() + Config::instance()->core['registration_confirmation_time'] * 86400
475
		);
476
		if (!$code) {
477
			throw new ExitException(500);
478
		}
479
		return $code;
480
	}
481
	/**
482
	 * @param int    $user_id
483
	 * @param string $provider
484
	 * @param bool   $redirect_with_delay
485
	 *
486
	 * @throws ExitException
487
	 */
488
	protected static function add_session_and_update_data ($user_id, $provider, $redirect_with_delay = false) {
489
		$adapter = self::get_adapter($provider);
490
		Event::instance()->fire(
491
			'HybridAuth/add_session/before',
492
			[
493
				'adapter'  => $adapter,
494
				'provider' => $provider
495
			]
496
		);
497
		Session::instance()->add($user_id);
498
		self::save_hybridauth_session();
499
		Event::instance()->fire(
500
			'HybridAuth/add_session/after',
501
			[
502
				'adapter'  => $adapter,
503
				'provider' => $provider
504
			]
505
		);
506
		self::update_data($provider);
507
		self::redirect($redirect_with_delay);
508
	}
509
	/**
510
	 * @param string $provider
511
	 */
512
	protected static function update_data ($provider) {
513
		$User    = User::instance();
514
		$user_id = $User->id;
515
		if ($user_id != User::GUEST_ID) {
516
			$adapter       = self::get_adapter($provider);
517
			$profile       = $adapter->getUserProfile();
518
			$profile_info  = [
519
				'username' => $profile->displayName,
520
				'avatar'   => $profile->photoURL
521
			];
522
			$profile_info  = array_filter($profile_info);
523
			$existing_data = $User->get(array_keys($profile_info), $user_id);
524
			foreach ($profile_info as $item => $value) {
525
				if (!$existing_data[$item] || $existing_data[$item] != $value) {
526
					$User->set($item, $value, $user_id);
527
				}
528
			}
529
		}
530
	}
531
	/**
532
	 * @param Config $Config
533
	 * @param int    $user_id
534
	 * @param string $password
535
	 * @param string $provider
536
	 */
537
	protected static function finish_registration_send_email ($Config, $user_id, $password, $provider) {
538
		$L         = new Prefix('hybridauth_');
539
		$User      = User::instance();
540
		$user_data = $User->$user_id;
541
		$base_url  = Config::instance()->base_url();
542
		$title     = $L->registration_success_mail($Config->core['site_name']);
0 ignored issues
show
Bug introduced by
The method registration_success_mail() does not exist on cs\Language\Prefix. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

542
		/** @scrutinizer ignore-call */ 
543
  $title     = $L->registration_success_mail($Config->core['site_name']);
Loading history...
543
		$body      = $L->registration_success_mail_body(
0 ignored issues
show
Bug introduced by
The method registration_success_mail_body() does not exist on cs\Language\Prefix. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

543
		/** @scrutinizer ignore-call */ 
544
  $body      = $L->registration_success_mail_body(
Loading history...
544
			self::get_adapter($provider)->getUserProfile()->displayName ?: $user_data->username(),
545
			$Config->core['site_name'],
546
			"$base_url/profile/settings",
547
			$user_data->login,
548
			$password
549
		);
550
		/**
551
		 * Send notification email
552
		 */
553
		if (self::send_registration_mail($user_data->email, $title, $body)) {
554
			self::add_session_and_update_data($user_id, $provider);
555
		}
556
	}
557
	/**
558
	 * @param string $provider
559
	 *
560
	 * @return \Hybrid_Provider_Adapter
561
	 *
562
	 * @throws ExitException
563
	 */
564
	protected static function get_adapter ($provider) {
565
		try {
566
			return get_hybridauth_instance($provider)::getAdapter($provider);
567
		} catch (ExitException $e) {
568
			throw $e;
569
		} catch (Exception $e) {
570
			trigger_error($e->getMessage());
571
			throw new ExitException(500);
572
		}
573
	}
574
}
575