59 lines
1.8 KiB
JavaScript
59 lines
1.8 KiB
JavaScript
// Initialize Firebase
|
|
var config = {
|
|
apiKey: "AIzaSyCuvwf78cmSDoZ2yS4XxHZhnjUn7yIHYfw",
|
|
authDomain: "test-667ca.firebaseapp.com",
|
|
databaseURL: "https://test-667ca.firebaseio.com",
|
|
projectId: "test-667ca",
|
|
storageBucket: "test-667ca.appspot.com",
|
|
messagingSenderId: "221332577314"
|
|
};
|
|
firebase.initializeApp(config);
|
|
|
|
|
|
var vue = new Vue({
|
|
el: '#vue-app',
|
|
data: {
|
|
name: "",
|
|
email: "",
|
|
password: ""
|
|
},
|
|
methods: {
|
|
async registerEmail() {
|
|
|
|
|
|
console.log("Start register: ", this.name, this.email, this.password)
|
|
|
|
await firebase.auth().createUserWithEmailAndPassword(this.email, this.password)
|
|
.then(user => {
|
|
console.log("User created: ", user);
|
|
|
|
})
|
|
.catch(function (error) {
|
|
// Handle Errors here.
|
|
var errorCode = error.code;
|
|
var errorMessage = error.message;
|
|
|
|
console.error(error.code + '_' + error.message);
|
|
alert(error.code + '_' + error.message);
|
|
});
|
|
var user = firebase.auth().currentUser;
|
|
if (user != null) {
|
|
await user.updateProfile({
|
|
displayName: this.name,
|
|
photoURL: "http://techfrage.de/upfiles/13547334191038217.png"
|
|
}).then(function () {
|
|
console.log("update name and photo");
|
|
|
|
}).catch(function (error) {
|
|
console.error(error);
|
|
});
|
|
await user.updateEmail(this.email).then(function () {
|
|
console.log("Email");
|
|
}).catch(function (error) {
|
|
console.error(error);
|
|
});
|
|
window.location.href = "/";
|
|
}
|
|
}
|
|
},
|
|
}) |