Guest User

Untitled

a guest
Mar 9th, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.15 KB | None | 0 0
  1. import {getSchema} from 'graphql-loader';
  2. import {initAccounts} from 'meteor/nicolaslopezj:apollo-accounts';
  3. import {addGraphQLSchema, addGraphQLResolvers, addGraphQLMutation} from 'meteor/vulcan:lib';
  4.  
  5. initAccounts({
  6. loginWithFacebook: false,
  7. loginWithGoogle: false,
  8. loginWithLinkedIn: false,
  9. loginWithPassword: true
  10. });
  11.  
  12. // if we could get graphql-loader's store, we could use it directly without making our own
  13. // definitions. Maybe make a PR?
  14. const accountsSchema = `
  15. type LoginMethodResponse {
  16. # Id of the user logged in user
  17. id: String!
  18. # Token of the connection
  19. token: String!
  20. # Expiration date for the token
  21. tokenExpires: Float!
  22. # The logged in user
  23. user: User
  24.  
  25. }
  26.  
  27. input CreateUserProfileInput {
  28. name: String
  29.  
  30. }
  31.  
  32. type SuccessResponse {
  33. # True if it succeeded
  34. success: Boolean
  35.  
  36. }
  37.  
  38. input HashedPassword {
  39. # The hashed password
  40. digest: String!
  41. # Algorithm used to hash the password
  42. algorithm: String!
  43.  
  44. }
  45. `;
  46.  
  47. const accountsMutations = `
  48. # Log the user in with a password.
  49. loginWithPassword(
  50. username: String,
  51. email: String,
  52. password: HashedPassword,
  53. plainPassword: String
  54. ): LoginMethodResponse
  55.  
  56. # Create a new user.
  57. createUser(
  58. username: String,
  59. email: String,
  60. password: HashedPassword,
  61. plainPassword: String,
  62. profile: CreateUserProfileInput
  63. ): LoginMethodResponse
  64.  
  65. # Change the current user's password. Must be logged in.
  66. changePassword(
  67. oldPassword: HashedPassword!,
  68. newPassword: HashedPassword!
  69. ): SuccessResponse
  70.  
  71. # Request a forgot password email.
  72. forgotPassword (email: String!): SuccessResponse
  73.  
  74. # Reset the password for a user using a token received in email. Logs the user in afterwards.
  75. resetPassword (newPassword: HashedPassword!, token: String!): LoginMethodResponse
  76.  
  77. # Log the user out.
  78. logout (token: String!): SuccessResponse
  79.  
  80. # Marks the user's email address as verified. Logs the user in afterwards.
  81. verifyEmail (token: String!): LoginMethodResponse
  82.  
  83. # Send an email with a link the user can use verify their email address.
  84. resendVerificationEmail (email: String): SuccessResponse
  85. `;
  86.  
  87. const schema = getSchema();
  88. addGraphQLSchema(accountsSchema);
  89. addGraphQLMutation(accountsMutations);
  90. addGraphQLResolvers(schema.resolvers);
Add Comment
Please, Sign In to add comment