first_login-dist.php 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * Quick page to react to first login cases.
  5. *
  6. * @package chamilo.custompages
  7. */
  8. require_once api_get_path(SYS_PATH).'main/inc/global.inc.php';
  9. require_once __DIR__.'/language.php';
  10. /**
  11. * Security checks.
  12. */
  13. if (!isset($_SESSION['conditional_login']['uid'])) {
  14. die("Not Authorised");
  15. }
  16. if (isset($_POST['password'])) {
  17. $u = api_get_user_info($_SESSION['conditional_login']['uid']);
  18. if ($_POST['password'] != $_POST['password2']) {
  19. header('Location: '.api_get_self().'?invalid=2');
  20. exit();
  21. }
  22. if (empty($_POST['password'])) { //|| !api_check_password($password)) { //Pass must be at least 5 char long with 2 digits and 3 letters
  23. header('Location: '.api_get_self().'?invalid=1');
  24. exit();
  25. }
  26. $password = $_POST['password'];
  27. $updated = UserManager::update_user(
  28. $u['user_id'],
  29. $u['firstname'],
  30. $u['lastname'],
  31. $u['username'],
  32. $password,
  33. $u['auth_source'],
  34. $u['email'],
  35. $u['status'],
  36. $u['official_code'],
  37. $u['phone'],
  38. $u['picture_uri'],
  39. $u['expiration_date'],
  40. $u['active'],
  41. $u['creator_id'],
  42. $u['hr_dept_id'],
  43. null,
  44. $u['language'],
  45. ''
  46. );
  47. if ($updated !== false) {
  48. UserManager::update_extra_field_value($u['user_id'], 'already_logged_in', 'true');
  49. ConditionalLogin::login();
  50. }
  51. }
  52. if ($_GET['invalid'] == 1) {
  53. $error_message = get_lang('CurrentPasswordEmptyOrIncorrect');
  54. }
  55. if ($_GET['invalid'] == 2) {
  56. $error_message = get_lang('PassTwo');
  57. }
  58. $www = api_get_path('WEB_PATH');
  59. /**
  60. * HTML output.
  61. */
  62. ?>
  63. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  64. <html>
  65. <head>
  66. <title>Custompage - login</title>
  67. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  68. <script type="text/javascript" src="<?php echo $www; ?>web/assets/jquery/dist/jquery.min.js"></script>
  69. <script type="text/javascript">
  70. $(document).ready(function() {
  71. if (top.location != location)
  72. top.location.href = document.location.href ;
  73. // Handler pour la touche retour
  74. $('input').keyup(function(e) {
  75. if (e.keyCode == 13) {
  76. $('#changepassword-form').submit();
  77. }
  78. });
  79. });
  80. </script>
  81. </head>
  82. <body>
  83. <div id="backgroundimage">
  84. <img src="/custompages/images/page-background.png" class="backgroundimage" />
  85. </div>
  86. <div id="wrapper">
  87. <div id="header">
  88. <img src="/custompages/images/header.png" alt="Logo" />
  89. </div> <!-- #header -->
  90. <h2> <?php echo custompages_get_lang('FirstLogin'); ?> </h2>
  91. <div id="changepassword-form-box" class="form-box">
  92. <div class="info"> <?php echo custompages_get_lang('FirstLoginChangePassword'); ?> </div>
  93. <?php if (isset($error_message)) {
  94. echo '<div id="changepassword-form-error" class="form-error">'.$error_message.'</div>';
  95. }?>
  96. <form id="changepassword-form" class="form" method="post">
  97. <div>
  98. <label for="password">*<?php echo custompages_get_lang('Password'); ?></label>
  99. <input name="password" type="password" /><br />
  100. <label for="password2">*<?php echo custompages_get_lang('Password'); ?></label>
  101. <input name="password2" type="password" /><br />
  102. </div>
  103. </form>
  104. <div id="changepassword-form-submit" class="form-submit" onclick="document.forms['changepassword-form'].submit();">
  105. <span><?php echo custompages_get_lang('LoginEnter'); ?></span>
  106. </div> <!-- #form-submit -->
  107. </div> <!-- #form -->
  108. <div id="footer">
  109. <img src="/custompages/images/footer.png" />
  110. </div> <!-- #footer -->
  111. </div> <!-- #wrapper -->
  112. </body>
  113. </html>