Skip to content

Commit 1fd30ff

Browse files
Copilotmarpisco
andcommitted
Add OAuth provider customization with $authProvider variable
Co-authored-by: marpisco <162377105+marpisco@users.noreply.github.com>
1 parent 8e1bf60 commit 1fd30ff

2 files changed

Lines changed: 25 additions & 13 deletions

File tree

login/index.php

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -551,20 +551,27 @@
551551
echo "<h1>Iniciar Sessão no ClassLink</h1>";
552552
echo "<p class=\"small\">Para aceder à plataforma, deve autenticar-se com a sua conta institucional.</p>";
553553
echo "<a href=\"/login?redirecttoflow=1\" class=\"login-btn\">";
554-
echo "<svg class=\"ms-logo\" width=\"21\" height=\"21\" viewBox=\"0 0 21 21\" xmlns=\"http://www.w3.org/2000/svg\" style=\"vertical-align: middle; margin-right: 8px;\">";
555-
echo "<rect class=\"ms-rect1\" x=\"1\" y=\"1\" width=\"9\" height=\"9\" fill=\"white\"/>";
556-
echo "<rect class=\"ms-rect2\" x=\"11\" y=\"1\" width=\"9\" height=\"9\" fill=\"white\"/>";
557-
echo "<rect class=\"ms-rect3\" x=\"1\" y=\"11\" width=\"9\" height=\"9\" fill=\"white\"/>";
558-
echo "<rect class=\"ms-rect4\" x=\"11\" y=\"11\" width=\"9\" height=\"9\" fill=\"white\"/>";
559-
echo "</svg>";
560-
echo "Login com Microsoft";
554+
if (isset($authProvider) && $authProvider === 'Microsoft') {
555+
echo "<svg class=\"ms-logo\" width=\"21\" height=\"21\" viewBox=\"0 0 21 21\" xmlns=\"http://www.w3.org/2000/svg\" style=\"vertical-align: middle; margin-right: 8px;\">";
556+
echo "<rect class=\"ms-rect1\" x=\"1\" y=\"1\" width=\"9\" height=\"9\" fill=\"white\"/>";
557+
echo "<rect class=\"ms-rect2\" x=\"11\" y=\"1\" width=\"9\" height=\"9\" fill=\"white\"/>";
558+
echo "<rect class=\"ms-rect3\" x=\"1\" y=\"11\" width=\"9\" height=\"9\" fill=\"white\"/>";
559+
echo "<rect class=\"ms-rect4\" x=\"11\" y=\"11\" width=\"9\" height=\"9\" fill=\"white\"/>";
560+
echo "</svg>";
561+
echo "Iniciar Sessão com Microsoft";
562+
} else {
563+
$providerName = isset($authProvider) ? htmlspecialchars($authProvider, ENT_QUOTES, 'UTF-8') : 'OAuth';
564+
echo "Iniciar Sessão com Fornecedor de Identidade " . $providerName;
565+
}
561566
echo "</a>";
562-
echo "<style>";
563-
echo ".login-btn:hover .ms-rect1 { fill: #f25022; }";
564-
echo ".login-btn:hover .ms-rect2 { fill: #7fba00; }";
565-
echo ".login-btn:hover .ms-rect3 { fill: #00a4ef; }";
566-
echo ".login-btn:hover .ms-rect4 { fill: #ffb900; }";
567-
echo "</style></a>";
567+
if (isset($authProvider) && $authProvider === 'Microsoft') {
568+
echo "<style>";
569+
echo ".login-btn:hover .ms-rect1 { fill: #f25022; }";
570+
echo ".login-btn:hover .ms-rect2 { fill: #7fba00; }";
571+
echo ".login-btn:hover .ms-rect3 { fill: #00a4ef; }";
572+
echo ".login-btn:hover .ms-rect4 { fill: #ffb900; }";
573+
echo "</style>";
574+
}
568575
echo "</div>";
569576
echo "";
570577
echo "<div class=\"notice\">";

src/config.sample.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,9 @@
3939
'clientSecret' => 'clientsecret', // CHANGE THIS and keep it secret
4040
'redirectUri' => 'https://' . $_SERVER['HTTP_HOST'] . '/login'
4141
]);
42+
43+
// OAuth Provider Name
44+
// Set to 'Microsoft' to display Microsoft logo and text on login button
45+
// Set to any other value (e.g., 'Google', 'Authentik', etc.) to display generic text
46+
$authProvider = 'Microsoft';
4247
?>

0 commit comments

Comments
 (0)