getAuthUrl().$login_hint); } else { // when $_GET['code'] is set we assume that the user was redirected from microsoft // back to us, we verify the token and then either forward the information // to the service on srv-ovc-linux that requested the authentication or // just display the contents of the authentication token $tokens = $auth->getToken($_REQUEST['code'], $_REQUEST['state']); $accessToken = $tokens->access_token; $auth->setAccessToken($accessToken); $user = new User; $user_id = NULL; $email = $user->data->getUserPrincipalName(); if (filter_var($email, FILTER_VALIDATE_EMAIL)) { $splitemail = explode('@', $email); if (db_single_field("SELECT user_id FROM users WHERE mail_username = ?", $splitemail[0])) { db_exec(<<data->getDisplayName(), $user->data->getJobTitle(), $user->data->getGivenName(), $user->data->getSurname(), $user->data->getId(), $splitemail[0]); } else { db_exec(<<data->getDisplayName(), $user->data->getJobTitle(), $user->data->getGivenName(), $user->data->getSurname(), $user->data->getId(), $splitemail[1], $user->data->getDisplayName(), $user->data->getJobTitle(), $user->data->getGivenName(), $user->data->getSurname(), $user->data->getId()); } $user_id = db_single_field('SELECT user_id FROM users WHERE mail_username = ?', $splitemail[0]); db_exec('UPDATE attempts SET user_id = ? WHERE attempt_id = ?', $user_id, Session::get('attempt_id')); } if (Session::get('redir')) { $payload = [ 'exp' => time() + 16, 'userPrincipalName' => $user->data->getUserPrincipalName(), 'jobTitle' => $user->data->getJobTitle(), 'state' => Session::get('parentstate'), ]; $jwt = JWT::encode($payload, $privateKey, 'EdDSA'); //echo('Redir: '.Session::get('redir').'jwt='.$jwt."\n"); header('Location: '.Session::get('redir').'jwt='.$jwt); } else { echo('
');
		print_r($user);
		echo('
'); } } ?>