-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIdpSession.php
More file actions
51 lines (38 loc) · 1.43 KB
/
IdpSession.php
File metadata and controls
51 lines (38 loc) · 1.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<?php
declare(strict_types=1);
namespace OWC\IdpUserData;
abstract class IdpSession
{
abstract protected static function get_idp(): string;
/**
* Returns the session slot identifier.
* Empty string means the primary session and '2' means the partner/second login session.
*/
protected static function get_slot(): string
{
return '';
}
public static function isPartnerSession(): bool
{
return static::get_slot() === '2';
}
public static function isPartnerLoggedIn(): bool
{
$isLoggedIn = apply_filters('owc_idp_is_logged_in', false, static::get_idp(), '2');
return apply_filters('owc_' . static::get_idp() . '_is_logged_in_2', $isLoggedIn);
}
public static function isLoggedIn(): bool
{
$slot = static::get_slot();
$filterSuffix = $slot !== '' ? '_' . $slot : '';
$isLoggedIn = apply_filters('owc_idp_is_logged_in', false, static::get_idp(), $slot);
return apply_filters('owc_' . static::get_idp() . '_is_logged_in' . $filterSuffix, $isLoggedIn);
}
protected static function getUserData(): ?UserDataInterface
{
$slot = static::get_slot();
$filterSuffix = $slot !== '' ? '_' . $slot : '';
$userData = apply_filters('owc_idp_userdata', null, static::get_idp(), $slot);
return apply_filters('owc_' . static::get_idp() . '_userdata' . $filterSuffix, $userData);
}
}