B
Size: a a a
B
B
B
B
B
p
B
F
F
B
p
DE
methods: {
signup () {
const auth = firebase.auth()
const name = this.name
const email = this.email
const password = this.password
auth.createUserWithEmailAndPassword(email, password)
.then(async res => {
console.log('res', res)
await firebase.firestore().collection('users')
.add({
name,
id: res.user.uid,
email,
password,
URL: '',
description: ''
}).then(ref => {
localStorage.setItem('id', res.user.uid),
localStorage.setItem('name', name),
localStorage.setItem('email', email),
localStorage.setItem('password', password),
localStorage.setItem('photoURL', ''),
localStorage.setItem('description', ''),
localStorage.setItem('firebaseDocumentId', ref.id),
this.name = '',
this.email = '',
this.password = '',
this.$router.push('/chat')
}).catch(err => console.log(err))
}).catch(err => {
const errorCode = err.code
const errorMessage = err.message
if (errorCode === 'auth/weak-password') {
this.$toasted.show('Password too weak').goAway(3000)
} else {
this.$toasted.show(errorMessage).goAway(3000)
}
})
}
}
methods: {
async signup () {
const auth = firebase.auth()
const vm = this
const { name, email, password } = vm
const res = await auth.createUserWithEmailAndPassword(email, password)
.catch((error) => console.log(error))
const id = res.user.uid
const data = { id, name, email, password, URL: '', description: '' }
console.log(res)
const ref = await firebase.firestore().collection('users').add(data)
.catch((error) => {
error.message = error.code === 'auth/weak-password'
? 'Password too weak'
: error.message
this.$toasted.show(error.message).goAway(3000)
})
Object.entries(data)
.forEach((args) => localStorage.setItem(...args))
.map(([key]) => [key, ''])
.forEach((args) => Vue.set(vm, ...args))
this.$router.push('/chat')
}
}
S
methods: {
async signup () {
const auth = firebase.auth()
const vm = this
const { name, email, password } = vm
const res = await auth.createUserWithEmailAndPassword(email, password)
.catch((error) => console.log(error))
const id = res.user.uid
const data = { id, name, email, password, URL: '', description: '' }
console.log(res)
const ref = await firebase.firestore().collection('users').add(data)
.catch((error) => {
error.message = error.code === 'auth/weak-password'
? 'Password too weak'
: error.message
this.$toasted.show(error.message).goAway(3000)
})
Object.entries(data)
.forEach((args) => localStorage.setItem(...args))
.map(([key]) => [key, ''])
.forEach((args) => Vue.set(vm, ...args))
this.$router.push('/chat')
}
}
В
methods: {
signup () {
const auth = firebase.auth()
const name = this.name
const email = this.email
const password = this.password
auth.createUserWithEmailAndPassword(email, password)
.then(async res => {
console.log('res', res)
await firebase.firestore().collection('users')
.add({
name,
id: res.user.uid,
email,
password,
URL: '',
description: ''
}).then(ref => {
localStorage.setItem('id', res.user.uid),
localStorage.setItem('name', name),
localStorage.setItem('email', email),
localStorage.setItem('password', password),
localStorage.setItem('photoURL', ''),
localStorage.setItem('description', ''),
localStorage.setItem('firebaseDocumentId', ref.id),
this.name = '',
this.email = '',
this.password = '',
this.$router.push('/chat')
}).catch(err => console.log(err))
}).catch(err => {
const errorCode = err.code
const errorMessage = err.message
if (errorCode === 'auth/weak-password') {
this.$toasted.show('Password too weak').goAway(3000)
} else {
this.$toasted.show(errorMessage).goAway(3000)
}
})
}
}
signup() {
const { name, email, password } = this;
const record = {
name, email, password,
URL: '',
description: ''
};
const store = {
name, email, password,
id: '',
photoURL: '',
description: '',
firebaseDocumentId: ''
};
const messages = {
'auth/weak-password': 'Password too weak'
};
const save = () => Object.keys(store).forEach((key) => localStorage.setItem(key, store[key]));
const toast = (message) => this.$toasted.show(message).goAway(3000);
const flush = () => [ 'name', 'email', 'password' ].forEach((key) => this[key] = '');
const toChat = () => this.$router.push('/chat');
firebase.auth().createUserWithEmailAndPassword(email, password)
.then(({ user: { uid: id } }) => store.id = id)
.then(() => firebase.firestore().collection('users').add(record))
.then(({ id }) => store.firebaseDocumentId = id)
.then(() => save())
.then(() => flush())
.then(() => toChat())
.catch(({ code, message }) => toast(messages[code] || message));
}
S
signup() {
const { name, email, password } = this;
const record = {
name, email, password,
URL: '',
description: ''
};
const store = {
name, email, password,
id: '',
photoURL: '',
description: '',
firebaseDocumentId: ''
};
const messages = {
'auth/weak-password': 'Password too weak'
};
const save = () => Object.keys(store).forEach((key) => localStorage.setItem(key, store[key]));
const toast = (message) => this.$toasted.show(message).goAway(3000);
const flush = () => [ 'name', 'email', 'password' ].forEach((key) => this[key] = '');
const toChat = () => this.$router.push('/chat');
firebase.auth().createUserWithEmailAndPassword(email, password)
.then(({ user: { uid: id } }) => store.id = id)
.then(() => firebase.firestore().collection('users').add(record))
.then(({ id }) => store.firebaseDocumentId = id)
.then(() => save())
.then(() => flush())
.then(() => toChat())
.catch(({ code, message }) => toast(messages[code] || message));
}
В
В
В
В
В
methods: {
signup () {
const auth = firebase.auth()
const name = this.name
const email = this.email
const password = this.password
auth.createUserWithEmailAndPassword(email, password)
.then(async res => {
console.log('res', res)
await firebase.firestore().collection('users')
.add({
name,
id: res.user.uid,
email,
password,
URL: '',
description: ''
}).then(ref => {
localStorage.setItem('id', res.user.uid),
localStorage.setItem('name', name),
localStorage.setItem('email', email),
localStorage.setItem('password', password),
localStorage.setItem('photoURL', ''),
localStorage.setItem('description', ''),
localStorage.setItem('firebaseDocumentId', ref.id),
this.name = '',
this.email = '',
this.password = '',
this.$router.push('/chat')
}).catch(err => console.log(err))
}).catch(err => {
const errorCode = err.code
const errorMessage = err.message
if (errorCode === 'auth/weak-password') {
this.$toasted.show('Password too weak').goAway(3000)
} else {
this.$toasted.show(errorMessage).goAway(3000)
}
})
}
}
methods: {
signup() {
const { name, email, password } = this;
const record = {
name, email, password,
URL: '',
description: ''
};
const store = {
name, email, password,
id: '',
photoURL: '',
description: '',
firebaseDocumentId: ''
};
const messages = {
'auth/weak-password': 'Password too weak'
};
const save = () => (
Object
.keys(store)
.forEach((key) => localStorage.setItem(key, store[key]))
);
const toast = (message) => this.$toasted.show(message).goAway(3000);
const flush = () => (
[ 'name', 'email', 'password' ].forEach((key) => this[key] = '')
);
const toChat = () => this.$router.push('/chat');
firebase.auth().createUserWithEmailAndPassword(email, password)
.then(({ user: { uid: id } }) => store.id = id)
.then(() => firebase.firestore().collection('users').add(record))
.then(({ id }) => store.firebaseDocumentId = id)
.then(() => save())
.then(() => flush())
.then(() => toChat())
.catch(({ code, message }) => toast(messages[code] || message));
}
}