account.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. import { User } from "../database/models.js";
  2. const no_auth = process.env.NO_AUTH || false;
  3. export const Account = async (req, res) => {
  4. if (no_auth && req.hostname == 'localhost') {
  5. res.render("account", {
  6. first_name: 'Localhost',
  7. last_name: 'Localhost',
  8. username: 'Localhost',
  9. id: 0,
  10. email: 'admin@localhost',
  11. role: 'admin',
  12. avatar: 'L',
  13. alert: '',
  14. link1: '',
  15. link2: '',
  16. link3: '',
  17. link4: '',
  18. link5: '',
  19. link6: '',
  20. link7: '',
  21. link8: '',
  22. link9: '',
  23. });
  24. return;
  25. }
  26. let user = await User.findOne({ where: { userID: req.session.userID }});
  27. res.render("account", {
  28. first_name: user.name,
  29. last_name: user.name,
  30. username: req.session.username,
  31. id: user.id,
  32. email: user.email,
  33. role: user.role,
  34. avatar: req.session.username.charAt(0).toUpperCase(),
  35. alert: '',
  36. link1: '',
  37. link2: '',
  38. link3: '',
  39. link4: '',
  40. link5: '',
  41. link6: '',
  42. link7: '',
  43. link8: '',
  44. link9: '',
  45. });
  46. }