first_login-dist.php 3.9 KB

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