PageRenderTime 40ms CodeModel.GetById 13ms RepoModel.GetById 0ms app.codeStats 0ms

/app/user/newpassword.php

https://gitlab.com/CORP-RESELLER/rest-api-sample-app-php
PHP | 77 lines | 69 code | 4 blank | 4 comment | 10 complexity | 3f6c6b37b528fb8f7406a01dfd42c14c MD5 | raw file
  1. <?php
  2. /*
  3. * User Forget Password page.
  4. */
  5. require_once __DIR__ . '/../bootstrap.php';
  6. session_start();
  7. $newPassword = null;
  8. // Forget Password form postback
  9. if ($_SERVER['REQUEST_METHOD'] == 'POST') {
  10. if (trim($_POST['user']['email']) == '') {
  11. $errorMessage = "You must enter a email address to generate new password.";
  12. } else {
  13. try {
  14. $newPassword = uniqid();
  15. $userId = updateUser($_POST['user']['email'], $newPassword, null);
  16. } catch (Exception $ex) {
  17. $newPassword = null;
  18. $errorMessage = $ex->getMessage();
  19. }
  20. }
  21. }
  22. ?>
  23. <!DOCTYPE html>
  24. <html lang='en'>
  25. <head>
  26. <meta charset='utf-8'>
  27. <meta content='IE=Edge,chrome=1' http-equiv='X-UA-Compatible'>
  28. <meta content='width=device-width, initial-scale=1.0' name='viewport'>
  29. <title>PizzaShop</title>
  30. <!-- Le HTML5 shim, for IE6-8 support of HTML elements -->
  31. <!--[if lt IE 9]>
  32. <script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.6.1/html5shiv.js" type="text/javascript"></script>
  33. <![endif]-->
  34. <link href="../../public/css/application.css" media="all" rel="stylesheet" type="text/css"/>
  35. <link href="../../public/images/favicon.ico" rel="shortcut icon" type="image/vnd.microsoft.icon"/>
  36. </head>
  37. <body>
  38. <?php include '../navbar.php'; ?>
  39. <div class='container' id='content'>
  40. <h2>Forgot Password</h2>
  41. <p>Generate New Password for an existing PizzaShop account.</p>
  42. <?php if (isset($errorMessage)) { ?>
  43. <div class="alert fade in alert-error">
  44. <button class="close" data-dismiss="alert">&times;</button>
  45. <?php echo $errorMessage; ?>
  46. </div>
  47. <?php } ?>
  48. <?php if ($newPassword) { ?>
  49. <h3>Your new password is: <?= $newPassword ?></h3>
  50. <?php } else { ?>
  51. <form accept-charset="UTF-8" action="./newpassword.php" autocomplete="off"
  52. class="simple_form form-horizontal generate_password" id="generate_password" method="post"
  53. novalidate="novalidate">
  54. <div style="margin:0;padding:0;display:inline"><input name="utf8" type="hidden" value="&#x2713;"/><input
  55. name="authenticity_token" type="hidden" value="vpVuNuIt9fRZzLm0eE0gk4h249k0nZPB/WEXWn9ETwg="/></div>
  56. <div class="control-group email required"><label class="email required control-label" for="user_email"><abbr
  57. title="required">*</abbr> Email</label>
  58. <div class="controls"><input autofocus="autofocus" class="string email required" id="user_email"
  59. name="user[email]" size="50" type="email" value=""
  60. placeholder="dummy@email.com"/></div>
  61. </div>
  62. <div class='form-actions'>
  63. <input class="btn btn btn-primary" name="commit" type="submit" value="Generate New Password" />
  64. </div>
  65. </form>
  66. <?php } ?>
  67. <a href="sign_up.php">Sign Up</a><br />
  68. <a href="sign_in.php">Sign In</a><br />
  69. </div>
  70. <?php include '../footer.php';?>
  71. <script src="../../public/js/application.js" type="text/javascript"></script>
  72. </body>
  73. </html>