Skip to content

Commit

Permalink
change path and use email as 'username'
Browse files Browse the repository at this point in the history
  • Loading branch information
PandorasActorMS committed Sep 19, 2023
1 parent 7aa5d32 commit 7a12c9f
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions oic_login.php
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
<?php

// use library for dealing with OpenID connect
#$env = parse_ini_file('.env');
$composerpath = getenv("COMPOSER_PATH");

require($composerpath . '/vendor/autoload.php');
require __DIR__ . '/vendor/autoload.php';

use Jumbojett\OpenIDConnectClient;

// Create OpenID connect client
#$env = parse_ini_file('.env');

$oidc = new OpenIDConnectClient(
getenv("OIC_IDP"),
Expand All @@ -23,16 +19,19 @@
$oidc->setHttpUpgradeInsecureRequests(false);
}

$oidc->addScope('profile','email');
$oidc->authenticate();

$_SESSION['oidcClient'] = $oidc;

// Set session variable username
$firstname = $oidc->requestUserInfo('given_name');
$surname = $oidc->requestUserInfo('family_name');
$initials = substr($firstname, 0, 1) . substr($surname, 0, 1);
#$firstname = $oidc->requestUserInfo('given_name');
#$surname = $oidc->requestUserInfo('family_name');
#$initials = substr($firstname, 0, 1) . substr($surname, 0, 1);
#
#$_SESSION['username'] = $initials;

$_SESSION['username'] = $initials;
$_SESSION['username'] = $oidc->requestUserInfo('email');


header("Location: interface.php");
Expand Down

0 comments on commit 7a12c9f

Please sign in to comment.