Guest User

Untitled

a guest
Aug 21st, 2018
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.41 KB | None | 0 0
  1. segue-se o codigo
  2. form#form()
  3. fieldset
  4. legend Account Info
  5. .row
  6. .col-md-6
  7. .form-group
  8. label.control-label Username
  9. input#Username.form-control(type='text',value=locals.user.username,readonly name='Username')
  10. .form-group
  11. label.control-label Email Address
  12. input#email.form-control(type='email', value=locals.user.mail, name='email')
  13. .form-group
  14. label.control-label Old Password
  15. input#oldpassword.form-control(type='password', placeholder='old password', name='oldpassword')
  16. .form-group
  17. label.control-label New Password
  18. input#password.form-control(type='password', placeholder='password', name='password')
  19. .form-group
  20. label.control-label Confirm New Password
  21. input#password_again.form-control(type='password', placeholder='password', name='password_again')
  22. .col-md-6
  23. .row
  24. .form-group
  25. label Image Upload
  26. .fileinput.fileinput-new(data-provides='fileinput')
  27. .fileinput-new.thumbnail
  28. img(src='../images/default-user.png', alt='')
  29. .fileinput-preview.fileinput-exists.thumbnail
  30. .user-edit-image-buttons
  31. span.btn.btn-azure.btn-file
  32. span.fileinput-new
  33. i.fa.fa-picture
  34. | Select image
  35. span.fileinput-exists
  36. i.fa.fa-picture
  37. | Change
  38. input(type='file')
  39. a.btn.fileinput-exists.btn-red(href='#', data-dismiss='fileinput')
  40. i.fa.fa-times
  41. | Remove
  42.  
  43. .row
  44. .col-md-12
  45. div
  46. | Required Fields
  47. hr
  48. .row
  49. .col-md-8
  50. p By clicking UPDATE, you are agreeing to the Policy and Terms & Conditions.
  51. .col-md-4
  52. input#target.btn.btn-primary.pull-right(type='submit', value='Submit', name='target')
  53.  
  54. const AlteraUserpassword = async (connection, req, res) => {
  55. req.body.password = await hashpass(req.body.password)
  56.  
  57.  
  58. const user= await User.AlteraPasswordUser(connection, req.body)
  59. if(!user){
  60. console.log("Nao Deu");
  61. return res.render('Administration/perfil',{error: true})
  62. }else{
  63.  
  64. console.log("Deu");
  65. return res.render('Administration/perfil',{error: false})
  66. }
  67. }
  68.  
  69. const AlteraPasswordUser = (connection, data) => {
  70. return new Promise((resolve, reject) => {
  71. connection.query(`UPDATE user SET password = '${data.password}' WHERE username = '${data.Username}`, (err, result) => {
  72. if(err){
  73. resolve(false)
  74. }else{
  75. resolve(result)
  76. }
  77. })
  78. })
  79. }
  80.  
  81. const express = require('express')
  82. const router = express.Router()
  83. const connection = require('../../Config/database')
  84. const controllerAdmin = require('../../controllers/Administration')
  85. const controlleruser = require('../../controllers/login')
  86. router.get('/Administration/perfil', (req, res) => controllerAdmin.findcidade2(connection, req, res));
  87. router.get('/Administration/Perfil/edit', (req, res) => controlleruser.AlteraUserpassword(connection, req, res));
  88. //router.get('/Administration/Perfil/edit', controlleruser.FormEdit)
  89. //router.get('/Administration/perfil/', (req, res) => res.render('Administration/perfil',{username:res.locals.user.username,email:res.locals.user.mail}))
  90.  
  91. module.exports = app => app.use('/', router)
  92.  
  93. #panel_edit_account.tab-pane.fade
  94. include Perfil/edit.jade
Add Comment
Please, Sign In to add comment