impersonatedUsers.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. ImpersonatedUsers = new Mongo.Collection('impersonatedUsers');
  2. /**
  3. * A Impersonated User in wekan
  4. */
  5. ImpersonatedUsers.attachSchema(
  6. new SimpleSchema({
  7. adminId: {
  8. /**
  9. * the admin userid that impersonates
  10. */
  11. type: String,
  12. optional: true,
  13. },
  14. userId: {
  15. /**
  16. * the userId that is impersonated
  17. */
  18. type: String,
  19. optional: true,
  20. },
  21. boardId: {
  22. /**
  23. * the boardId that was exported by anyone that has sometime impersonated
  24. */
  25. type: String,
  26. optional: true,
  27. },
  28. attachmentId: {
  29. /**
  30. * the attachmentId that was exported by anyone that has sometime impersonated
  31. */
  32. type: String,
  33. optional: true,
  34. },
  35. reason: {
  36. /**
  37. * the reason why impersonated, like exportJSON
  38. */
  39. type: String,
  40. optional: true,
  41. },
  42. createdAt: {
  43. /**
  44. * creation date of the impersonation
  45. */
  46. type: Date,
  47. // eslint-disable-next-line consistent-return
  48. autoValue() {
  49. if (this.isInsert) {
  50. return new Date();
  51. } else if (this.isUpsert) {
  52. return {
  53. $setOnInsert: new Date(),
  54. };
  55. } else {
  56. this.unset();
  57. }
  58. },
  59. },
  60. modifiedAt: {
  61. /**
  62. * modified date of the impersonation
  63. */
  64. type: Date,
  65. denyUpdate: false,
  66. // eslint-disable-next-line consistent-return
  67. autoValue() {
  68. if (this.isInsert || this.isUpsert || this.isUpdate) {
  69. return new Date();
  70. } else {
  71. this.unset();
  72. }
  73. },
  74. },
  75. }),
  76. );
  77. export default ImpersonatedUsers;