Single-sign-on and self-serve account management. https://netsyms.biz/apps/accounthub
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

index.php 2.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <?php
  2. /*
  3. * This Source Code Form is subject to the terms of the Mozilla Public
  4. * License, v. 2.0. If a copy of the MPL was not distributed with this
  5. * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  6. */
  7. require_once __DIR__ . "/required.php";
  8. // if we're logged in, we don't need to be here.
  9. if (!empty($_SESSION['loggedin']) && $_SESSION['loggedin'] === true && !isset($_GET['permissionerror'])) {
  10. header('Location: app.php');
  11. }
  12. if (!empty($_GET['logout'])) {
  13. // Show a logout message instead of immediately redirecting to login flow
  14. ?>
  15. <!DOCTYPE html>
  16. <meta charset="UTF-8">
  17. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  18. <meta name="viewport" content="width=device-width, initial-scale=1">
  19. <title><?php echo $SETTINGS['site_title']; ?></title>
  20. <link rel="icon" href="static/img/logo.svg">
  21. <link href="static/css/bootstrap.min.css" rel="stylesheet">
  22. <link href="static/css/svg-with-js.min.css" rel="stylesheet">
  23. <link href="static/css/login.css" rel="stylesheet">
  24. <div class="container mt-4">
  25. <div class="row justify-content-center">
  26. <div class="col-12 text-center">
  27. <img class="banner-image" src="./static/img/logo.svg" />
  28. </div>
  29. <div class="col-12 text-center">
  30. <h1 class="display-5 mb-4"><?php $Strings->get("You have been logged out.") ?></h1>
  31. </div>
  32. <div class="col-12 col-sm-8 col-lg-6">
  33. <div class="card mt-4">
  34. <div class="card-body">
  35. <a href="./index.php" class="btn btn-primary btn-block"><?php $Strings->get("Log in again"); ?></a>
  36. </div>
  37. </div>
  38. </div>
  39. </div>
  40. </div>
  41. <script src="static/js/fontawesome-all.min.js"></script>
  42. <?php
  43. die();
  44. }
  45. if (empty($_SESSION["login_code"])) {
  46. $redirecttologin = true;
  47. } else {
  48. try {
  49. $uid = LoginKey::getuid($_SESSION["login_code"]);
  50. $user = new User($uid);
  51. Session::start($user);
  52. $_SESSION["login_code"] = null;
  53. header('Location: app.php');
  54. die("Logged in, go to app.php");
  55. } catch (Exception $ex) {
  56. $redirecttologin = true;
  57. }
  58. }
  59. if ($redirecttologin) {
  60. try {
  61. $code = LoginKey::generate($SETTINGS["site_title"], "../static/img/logo.svg");
  62. $_SESSION["login_code"] = $code;
  63. header("Location: ./login/?code=" . htmlentities($code) . "&redirect=" . htmlentities($_SERVER["REQUEST_URI"]));
  64. } catch (Exception $ex) {
  65. sendError($ex->getMessage());
  66. }
  67. }