first_login.php 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <?php
  2. require_once('language.php');
  3. require_once(dirname(__FILE__).'/../main/inc/global.inc.php');
  4. require_once (api_get_path(LIBRARY_PATH).'conditionallogin.lib.php');
  5. require_once (api_get_path(LIBRARY_PATH).'usermanager.lib.php');
  6. if (! isset($_SESSION['conditional_login']['uid']))
  7. die("Not Authorised");
  8. if (isset($_POST['password'])){
  9. $u = UserManager::get_user_info_by_id($_SESSION['conditional_login']['uid']);
  10. if ($_POST['password'] != $_POST['password2']) {
  11. header('Location: '. api_get_self().'?invalid=2');
  12. exit();
  13. }
  14. if (empty($_POST['password'])){ //|| !api_check_password($password)) { //Pass must be at least 5 char long with 2 digits and 3 letters
  15. header('Location: '. api_get_self().'?invalid=1');
  16. exit();
  17. }
  18. $password = $_POST['password'];
  19. $updated = UserManager::update_user($u['user_id'], $u['firstname'], $u['lastname'], $u['username'], $password, $u['auth_source'], $u['email'], $u['status'], $u['official_code'], $u['phone'], $u['picture_uri'], $u['expiration_date'], $u['active'], $u['creator_id'], $u['hr_dept_id'], $u['extra'], $u['language'],'');
  20. if ($updated) {
  21. UserManager::update_extra_field_value($u['user_id'], 'already_logged_in', 'true');
  22. ConditionalLogin::login();
  23. }
  24. }
  25. if ($_GET['invalid'] == 1) {
  26. $error_message = get_lang('CurrentPasswordEmptyOrIncorrect');
  27. }
  28. if ($_GET['invalid'] == 2) {
  29. $error_message = get_lang('PassTwo');
  30. }
  31. ?>
  32. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  33. <html>
  34. <head>
  35. <title>Custompage - login</title>
  36. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  37. <!--[if !IE 6]><!-->
  38. <link rel="stylesheet" type="text/css" href="/custompages/style.css" />
  39. <!--<![endif]-->
  40. <!--[if IE 6]>
  41. <link rel="stylesheet" type="text/css" href="/custompages/style-ie6.css" />
  42. <![endif]-->
  43. <script type="text/javascript" src="/custompages/jquery-1.5.1.min.js"></script>
  44. <script type="text/javascript">
  45. $(document).ready(function() {
  46. if (top.location != location)
  47. top.location.href = document.location.href ;
  48. // Handler pour la touche retour
  49. $('input').keyup(function(e) {
  50. if (e.keyCode == 13) {
  51. $('#changepassword-form').submit();
  52. }
  53. });
  54. });
  55. </script>
  56. </head>
  57. <body>
  58. <div id="backgroundimage">
  59. <img src="/custompages/images/page-background.png" class="backgroundimage" />
  60. </div>
  61. <div id="wrapper">
  62. <div id="header">
  63. <img src="/custompages/images/header.png" alt="Logo" />
  64. </div> <!-- #header -->
  65. <div id="changepassword-form-box" class="form-box">
  66. <?php if (isset($error_message)) {
  67. echo '<div id="changepassword-form-error" class="form-error">'.$error_message.'</div>';
  68. }?>
  69. <form id="changepassword-form" class="form" method="post">
  70. <div>
  71. <label for="password">*<?php echo cblue_get_lang('langPass');?></label>
  72. <input name="password" type="password" /><br />
  73. <label for="password2">*<?php echo cblue_get_lang('langPass');?></label>
  74. <input name="password2" type="password" /><br />
  75. </div>
  76. </form>
  77. <div id="changepassword-form-submit" class="form-submit" onclick="document.forms['changepassword-form'].submit();">
  78. <span><?php echo cblue_get_lang('LoginEnter');?></span>
  79. </div> <!-- #form-submit -->
  80. </div> <!-- #form -->
  81. <div id="footer">
  82. <img src="/custompages/images/footer.png" />
  83. </div> <!-- #footer -->
  84. </div> <!-- #wrapper -->
  85. </body>
  86. </html>