Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions src/DigiDPartnerSession.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

declare(strict_types=1);

namespace OWC\IdpUserData;

class DigiDPartnerSession extends DigiDSession
{
protected static function get_slot(): string
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kunnen we hier niet een isPartnerSession() function van maken? Of zijn er nog andere type sessies mogelijk?

Dan kan je ook isPartnerLoggedIn() toevoegen.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ik heb in de IdpSession class dit toegevoegd:

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);
}

{
return '2';
}

public static function getUserData(): ?DigiDUserDataInterface
{
return parent::getUserData();
}
}
35 changes: 31 additions & 4 deletions src/IdpSession.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,44 @@ 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
{
$isLoggedIn = apply_filters('owc_idp_is_logged_in', false, static::get_idp());
$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', $isLoggedIn);
return apply_filters('owc_' . static::get_idp() . '_is_logged_in' . $filterSuffix, $isLoggedIn);
}

protected static function getUserData(): ?UserDataInterface
{
$userData = apply_filters('owc_idp_userdata', null, static::get_idp());
$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', $userData);
return apply_filters('owc_' . static::get_idp() . '_userdata' . $filterSuffix, $userData);
}
}
18 changes: 18 additions & 0 deletions src/eHerkenningPartnerSession.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

declare(strict_types=1);

namespace OWC\IdpUserData;

class eHerkenningPartnerSession extends eHerkenningSession
{
protected static function get_slot(): string
{
return '2';
}

public static function getUserData(): ?eHerkenningUserDataInterface
{
return parent::getUserData();
}
}
18 changes: 18 additions & 0 deletions src/eIDASPartnerSession.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

declare(strict_types=1);

namespace OWC\IdpUserData;

class eIDASPartnerSession extends eIDASSession
{
protected static function get_slot(): string
{
return '2';
}

public static function getUserData(): ?eIDASUserDataInterface
{
return parent::getUserData();
}
}