Advertisement
Guest User

Untitled

a guest
May 29th, 2018
314
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.06 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6. <meta name="viewport" content="width=device-width, initial-scale=1">
  7. <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
  8. <title>Social Media</title>
  9.  
  10. <!-- Bootstrap -->
  11. <link href="css/bootstrap.min.css" rel="stylesheet">
  12. <link href="css/custom.css" rel="stylesheet">
  13.  
  14. <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
  15. <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
  16. <!--[if lt IE 9]>
  17. <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
  18. <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
  19. <![endif]-->
  20. </head>
  21. <body>
  22. <div id="app">
  23. <nav class="navbar navbar-inverse navbar-fixed-top">
  24. <div class="container-fluid">
  25. <!-- Brand and toggle get grouped for better mobile display -->
  26. <div class="navbar-header">
  27. <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
  28. <span class="sr-only">Toggle navigation</span>
  29. <span class="icon-bar"></span>
  30. <span class="icon-bar"></span>
  31. <span class="icon-bar"></span>
  32. </button>
  33. <a class="navbar-brand" href="index.html">SocMedia</a>
  34. </div>
  35.  
  36. <!-- Collect the nav links, forms, and other content for toggling -->
  37. <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
  38. <ul class="nav navbar-nav">
  39. <li><a href="messageboard.html">Message Board<span class="sr-only">(current)</span></a></li>
  40. <li><a href="messages.html">Messages</a></li>
  41. <li><a href="users.html">People</a></li>
  42. </ul>
  43. <ul class="nav navbar-nav navbar-right">
  44. <li class="dropdown">
  45. <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">{{ user.name }}<span class="caret"></span></a>
  46. <ul class="dropdown-menu">
  47. <li><a href="profile.html">My Profile</a></li>
  48. <li><a href="myaccount.html">My Account</a></li>
  49. <li class="active"><a href="change_password.html">Change Password</a></li>
  50. <li role="separator" class="divider"></li>
  51. <li><a href="index.html">Logout</a></li>
  52. </ul>
  53. </li>
  54. </ul>
  55. </div><!-- /.navbar-collapse -->
  56. </div><!-- /.container-fluid -->
  57. </nav>
  58.  
  59.  
  60. <div class="container">
  61.  
  62.  
  63. <section class="login-info">
  64. <div class="container">
  65. <div class="row main">
  66. <div class="content-header">
  67. <h3 class="text-center">Change Password</h3>
  68. </div>
  69. <div class="main-content">
  70.  
  71. <div class="input-group">
  72. <span class="input-group-addon"><span class="glyphicon glyphicon-lock" aria-hidden="true"></span></span>
  73. <input v-model="password" id="oldpassword" type="password" class="form-control" name="oldpassword" placeholder="Enter your Old Password">
  74. </div>
  75.  
  76. <div class="input-group">
  77. <span class="input-group-addon"><span class="glyphicon glyphicon-lock" aria-hidden="true"></span></span>
  78. <input v-model="new_password" id="password" type="password" class="form-control" name="password" placeholder="Enter your New Password">
  79. </div>
  80. <div class="input-group">
  81. <span class="input-group-addon"><span class="glyphicon glyphicon-lock" aria-hidden="true"></span></span>
  82. <input v-model="confirmPassword" id="password2" type="password" class="form-control" name="password2" placeholder="Repeat your New Password">
  83. </div>
  84. <div class="form-group ">
  85. <button @click="changePassword" type="button" class="btn btn-primary btn-lg btn-block restricted-button">Sign in</button>
  86. <b><span v-if="success_message != ''">{{success_message}}</span></b>
  87. </div>
  88. </div>
  89. </div>
  90. </div>
  91. </section>
  92.  
  93.  
  94. </div>
  95. </div>
  96. <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
  97. <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
  98. <!-- Include all compiled plugins (below), or include individual files as needed -->
  99. <script src="js/bootstrap.min.js"></script>
  100. <script src="https://cdn.jsdelivr.net/npm/vue@2.5.16/dist/vue.js"></script>
  101. <script src="https://cdnjs.cloudflare.com/ajax/libs/axios/0.18.0/axios.min.js"></script>
  102. <script>
  103. new Vue({
  104. el: '#app',
  105. data: {
  106. user: '',
  107. password: '',
  108. new_password: '',
  109. confirmPassword: '',
  110. errors: { },
  111. success_message: ''
  112. },
  113.  
  114. created(){
  115. this.user = JSON.parse(localStorage.getItem('user'));
  116. },
  117.  
  118. methods: {
  119. validateBeforeSubmit(){
  120. var flag = true;
  121.  
  122. if(this.password.length < 3){
  123. this.errors.password = "A password must have at least 3 characters";
  124. flag = false;
  125. }
  126.  
  127. if(this.new_password !== this.confirmPassword){
  128. this.errors.confirmPassword = "The fields password and confirm password don't match";
  129. flag = false;
  130. }
  131.  
  132. return flag;
  133. },
  134. changePassword(){
  135. let headers = { headers: { 'Authorization': 'Bearer ' + this.user.token} };
  136. let data = {'password': this.password, 'new_password': this.new_password};
  137.  
  138. axios.put('http://localhost:3000/users/' + this.user._id, data, headers)
  139. .then(response => {
  140. this.success_message = response.data.message;
  141. this.password = '';
  142. this.new_password = '';
  143. this.confirmPassword = '';
  144. })
  145. .catch(error => {
  146. console.log(error);
  147. });
  148. }
  149. }
  150. });
  151. </script>
  152. </body>
  153. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement