@@ -46,6 +46,41 @@ function footer()
4646 echo '</div></form> ' ;
4747}
4848
49+ function enableDefaultLogin ()
50+ {
51+ echo '<div class="login"><p> ' ;
52+ echo '<strong> ' . $ GLOBALS ['I18N ' ]->get ('Having trouble with SSO login? ' ) . '</strong><br> ' ;
53+ echo $ GLOBALS ['I18N ' ]->get ('You can still use default login by clicking on the button ' ) . ' ' ;
54+ echo '<a href="?page=enablelogin" class="submit"> ' . $ GLOBALS ['I18N ' ]->get ('Enable default login ' ) . '</a> ' ;
55+ echo '</p><div class="clear"></div></div> ' ;
56+ }
57+
58+
59+ function renderSSO ()
60+ {
61+ if (!empty ($ GLOBALS ['ssoplugin ' ])) {
62+ echo '<form method="post" id="forgotpassword-form" action=""> ' ;
63+ echo '<div style="display: flex; justify-content: space-around; align-items: center;"> ' ;
64+
65+ foreach ($ GLOBALS ['ssoplugin ' ] as $ plugin ) {
66+ if (isset ($ GLOBALS ['plugins ' ][$ plugin ])) {
67+ $ pluginInstance = $ GLOBALS ['plugins ' ][$ plugin ];
68+ $ ssoUrl = $ pluginInstance ->autUrl ;
69+ $ buttonText = 'Login with ' . getConfig ($ pluginInstance ->name );
70+
71+ echo '<a href="? ' . $ ssoUrl . '"
72+ style="display: inline-block; padding: 8px 15px; background-color: #3c3c3c; color: #fff;
73+ text-decoration: none; border-radius: 5px; font-size: 16px; text-align: center;
74+ min-width: 120px;">
75+ ' . $ buttonText . '
76+ </a> ' ;
77+ }
78+ }
79+
80+ echo '</div> ' ;
81+ echo '</form> ' ;
82+ }
83+ }
4984//Delete from the DB every token older than certain elapsed time.
5085function deleteOldTokens ()
5186{
@@ -116,16 +151,24 @@ function deleteOldTokens()
116151 exit ;
117152 }
118153} else {
119- echo "<form method= \"post \" id= \"login-form \" action= \"\"> \n" ;
120- echo " <input type= \"hidden \" name= \"page \" value= \"$ page \" /> \n" ;
121- echo " <table class= \"loginPassUpdate \" width= \"100% \" border= \"0 \" cellpadding= \"2 \" cellspacing= \"0 \"> \n" ;
122- echo ' <tr><td><span class="general"> ' .$ GLOBALS ['I18N ' ]->get ('Name ' ).":</span></td></tr> \n" ;
123- echo ' <tr><td><input type="text" name="login" value="" size="30" autofocus="autofocus" /></td></tr> ' ;
124- echo ' <tr><td><span class="general"> ' .$ GLOBALS ['I18N ' ]->get ('Password ' ).':</span></td></tr> ' ;
125- echo ' <tr><td><input type="password" name="password" value="" size="30" /></td></tr> ' ;
126- echo ' <tr><td><input class="submit" type="submit" name="process" value=" ' .$ GLOBALS ['I18N ' ]->get ('Continue ' ).'" /></td></tr> ' ;
127- echo ' </table> ' ;
128- echo '</form> ' ;
129- footer ();
154+ $ showDefaultLogin = !isset ($ GLOBALS ['ssoplugin ' ]) || !getConfig ('hide_default_login ' );
155+ if ($ showDefaultLogin ) {
156+ echo "<form method= \"post \" id= \"login-form \" action= \"\"> \n" ;
157+ echo " <input type= \"hidden \" name= \"page \" value= \"$ page \" /> \n" ;
158+ echo " <table class= \"loginPassUpdate \" width= \"100% \" border= \"0 \" cellpadding= \"2 \" cellspacing= \"0 \"> \n" ;
159+ echo ' <tr><td><span class="general"> ' .$ GLOBALS ['I18N ' ]->get ('Name ' ).":</span></td></tr> \n" ;
160+ echo ' <tr><td><input type="text" name="login" value="" size="30" autofocus="autofocus" /></td></tr> ' ;
161+ echo ' <tr><td><span class="general"> ' .$ GLOBALS ['I18N ' ]->get ('Password ' ).':</span></td></tr> ' ;
162+ echo ' <tr><td><input type="password" name="password" value="" size="30" /></td></tr> ' ;
163+ echo ' <tr><td><input class="submit" type="submit" name="process" value=" ' .$ GLOBALS ['I18N ' ]->get ('Continue ' ).'" /></td></tr> ' ;
164+ echo ' </table> ' ;
165+ echo '</form> ' ;
166+ footer ();
167+ }
168+ renderSSO ();
169+
170+ if (!$ showDefaultLogin ) {
171+ enableDefaultLogin ();
172+ }
130173}
131174?>
0 commit comments