Guest User

Untitled

a guest
Jun 16th, 2018
801
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.99 KB | None | 0 0
  1. function logValue(){
  2. var profileConfig = ServiceConfiguration.configurations.findOne({service: 'password'});
  3. var coinConfig = ServiceConfiguration.configurations.findOne({service: 'coinbase'});
  4. var googleConfig = ServiceConfiguration.configurations.findOne({service: 'google'});
  5. if (!Meteor.user())
  6. return 0;
  7. else if (coinConfig && !profileConfig)
  8. return 1;
  9. else if (googleConfig && !profileConfig)
  10. return 2;
  11. else
  12. return 3;
  13. }
  14.  
  15.  
  16. // This is a substitute for {{#if currentUser}}
  17. Template.registerHelper('currentProfile', function(){
  18. if (logValue()!==3)
  19. return false;
  20. else
  21. return true;
  22. });
  23.  
  24. 'submit form': function(event,template){
  25. event.preventDefault();
  26. var nameVar = template.find('#name').value;
  27. var emailVar = template.find('#email').value;
  28. var passVar = template.find('#password').value;
  29. const info = {
  30. id: Meteor.userId(),
  31. prof: {
  32. $set: {
  33. emails : [
  34. {
  35. address : emailVar,
  36. verified : false,
  37. }
  38. ],
  39. profile : {
  40. name : nameVar,
  41. }
  42. },
  43. },
  44. pass: passVar,
  45. };
  46. Meteor.call('updateUser', (info),
  47. (err) => {
  48. if (err) {
  49. alert(err);
  50. }
  51. }
  52. );
  53. }
  54.  
  55. updateUser: (info) => {
  56. var pass = passHash(info.pass);
  57. Meteor.users.update({_id: Meteor.userId()},info.prof);
  58. Meteor.users.update({_id: Meteor.userId()},
  59. {
  60. $set: {
  61. services: {
  62. password: {
  63. bcrypt: pass,
  64. },
  65. },
  66. }
  67. }
  68. );
  69. },
  70.  
  71. Accounts.setPassword(userId, newPassword, [options])
  72.  
  73. // This is right before I update the information. The account made
  74. with the coinbase login similar to other
  75. // packages like accounts-facebook, and accounts-google
  76. {
  77. "_id" : "5dNYmJp9APCgxi8se",
  78. "createdAt" : ISODate("2018-06-15T21:14:38.276Z"),
  79. "services" : {
  80. "coinbase" : {
  81. COINBASE PROVIDED INFO },
  82. "resume" : {
  83. "loginTokens" : [
  84. {
  85. LOGIN STUFF
  86. }
  87. ]
  88. }
  89. },
  90. "profile" : {
  91. COINBASE MADE PROFILE
  92. }
  93. }
  94.  
  95. //This is what happens when I update an account with my registration form submission.
  96.  
  97. {
  98. "_id" : "fxTu4YuhBsAvz2Gey",
  99. "createdAt" : ISODate("2018-06-15T21:21:32.710Z"),
  100. "services" : {
  101. "password" : {some hashed password havnt gotten that working yet}
  102. },
  103. "profile" : {
  104. "name" : "New Reconfimed and updated info"
  105. },
  106. "emails" : [
  107. {
  108. "address" : "sdfsdfsd@sdfsd",
  109. "verified" : false
  110. }
  111. ]
  112. }
Add Comment
Please, Sign In to add comment