Guest User

Untitled

a guest
Dec 17th, 2018
240
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.23 KB | None | 0 0
  1. LOGIN ERRORs TypeError: _components_firebase_firebaseInit__WEBPACK_IMPORTED_MODULE_2__.default.collection is not a function
  2. at index.js:193
  3. at e.g (vendors.app.js:440)
  4. at Fb (vendors.app.js:443)
  5. at Bb (vendors.app.js:443)
  6. at A.push../node_modules/@firebase/auth/dist/auth.esm.js.g.Xb (vendors.app.js:442)
  7. at kb (vendors.app.js:436)
  8.  
  9. <template>
  10.  
  11. <v-layout>
  12.  
  13. <v-text-field
  14. v-model="first_name"
  15. :rules="[rules.required]"
  16. label="First Name"
  17. required/>
  18.  
  19.  
  20. <v-text-field
  21. v-model="last_name"
  22. :rules="[rules.required]"
  23. label="Last Name"
  24. required/>
  25. <br>
  26.  
  27. <v-text-field
  28. v-model="email"
  29. :rules="[rules.required]"
  30. label="Email Address"
  31. required/>
  32. <br>
  33.  
  34. <v-text-field
  35. v-model="password"
  36. :append-icon="showPass ? 'visibility_off' : 'visibility'"
  37. :rules="[rules.required]"
  38. :type="showPass ? 'text' : 'password'"
  39. label="Password"
  40. hint="At least 8 characters"
  41. min="8"
  42. counter
  43. @click:append="showPass = !showPass" />
  44. <br>
  45.  
  46. <v-text-field
  47. v-model="confirmation"
  48. :append-icon="showConf ? 'visibility_off' : 'visibility'"
  49. :rules="[rules.required, rules.emailMatch]"
  50. :type="showConf ? 'text' : 'password'"
  51. name="input-10-2"
  52. label="Password (again)"
  53. hint="At least 8 characters"
  54. value="Pa"
  55. @click:append="showConf = !showConf" />
  56. <br>
  57.  
  58. <v-spacer/>
  59. <v-btn
  60. color="pink"
  61. class="color: #FFFFFF"
  62. dark
  63. flat
  64. round
  65. @click="goLogin()">Return to Login Page</v-btn>
  66. <v-btn
  67. color="primary"
  68. class="color: #FFFFFF"
  69. dark
  70. @click="signup()">Register</v-btn>
  71.  
  72.  
  73. </v-layout>
  74. </template>
  75.  
  76. <script>
  77. import fb from '../../components/firebase/firebaseInit'
  78.  
  79. export default {
  80. layout: 'auth',
  81. data () {
  82. return {
  83. email: faker.internet.email(),
  84. password: '11112222',
  85. confirmation: '11112222',
  86. showPass: false,
  87. showConf: false,
  88. rules: {
  89. required: value => !!value || 'Required.',
  90. // min: v => v.length >= 8 || 'Min 8 characters',
  91. emailMatch: this.password == this.confirmation || ('The password and confirmation you entered don't match')
  92. }
  93. }
  94. },
  95.  
  96. // methods: mapActions('auth', ['login']),
  97. methods: {
  98.  
  99. signup: function(email,password) {
  100. let _this = this
  101. console.log("STORE", this.$store);
  102.  
  103. fb.auth.createUserWithEmailAndPassword(this.email, this.password)
  104. .then(function (res) {
  105.  
  106. _this.$store.commit('setCurrentUser', res.user)
  107. console.log("INSIDE with user",res.user.uid);
  108. console.log("INSIDE with this.email",_this.email);
  109.  
  110. // **********************************
  111. // *** THIS IS WHAT"S NOT WORKING ***
  112. // FYI, I even tried to simply hard code in a number and still
  113. // received the error. Also, res.user and res.user.uid are valid
  114. // **********************************
  115. fb.collection('users').doc(res.user.uid).set({
  116. email: _this.email
  117. })
  118. .then(() => {
  119. // SETTING PROFILE
  120. _this.$store.dispatch('fetchUserProfile')
  121. _this.$router.push('/')
  122. }).catch(err => {
  123. console.log(err)
  124. })
  125.  
  126. }).catch(err => {
  127. console.log("LOGIN ERRORs", err)
  128. })
  129. },
  130.  
  131. }
  132. </script>
  133.  
  134. import firebase from 'firebase/app'
  135. import 'firebase/firestore'
  136. import 'firebase/auth'
  137.  
  138. const config = {
  139. // REMOVED THE VALUES FOR SECURITY, but they are correct in the app
  140. apiKey: "",
  141. authDomain: "",
  142. databaseURL: "",
  143. projectId: "",
  144. storageBucket: "",
  145. messagingSenderId: ""
  146. }
  147.  
  148. firebase.initializeApp(config)
  149.  
  150. // firebase utils
  151. const db = firebase.firestore()
  152. const auth = firebase.auth()
  153. const currentUser = auth.currentUser
  154.  
  155. // date issue fix according to firebase
  156. const settings = {
  157. timestampsInSnapshots: true
  158. }
  159. db.settings(settings)
  160.  
  161. export default {
  162. db,
  163. auth,
  164. currentUser
  165. }
Add Comment
Please, Sign In to add comment