create user after login

This commit is contained in:
Lukas Nowy 2019-02-20 20:34:05 +01:00
parent 4bfe8ce31a
commit 9f8c0d3985
4 changed files with 6 additions and 17 deletions

View File

@ -6,19 +6,8 @@ const stringSimilarity = require('string-similarity');
async function updateUser(uid, mid) {
try {
let exists = await query('SELECT row_to_json("User") AS obj FROM "User" WHERE username = $1;', [uid]);
console.log(exists);
//existiert
if(exists != undefined) {
await nonQuery('UPDATE "User" SET message_id = $1 WHERE username = $2', [mid, uid]);
}
//existiert nicht
else {
await nonQuery('INSERT INTO "User" (username, message_id) VALUES ($1, $2);', [uid, mid]);
}
await nonQuery('INSERT INTO "User" (username, message_id) VALUES ($1, $2);', [uid, mid]);
}
catch (error) {

View File

@ -72,7 +72,7 @@ var vue = new Vue({
},
mounted() {
axios.post('/user', {
/*axios.post('/user', {
message_id: 'test',
})
.then(function (response) {
@ -80,6 +80,6 @@ var vue = new Vue({
})
.catch(function (error) {
console.log(error);
});
});*/
}
});

View File

@ -44,7 +44,7 @@ var config = {
firebase.initializeApp(config);
getAllShoppinglists();
//updateUser();
updateUser();
displayShoppinglist();
function movePurchases(text) {

View File

@ -8,7 +8,7 @@
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.5.0/css/all.css" integrity="sha384-B4dIYHKNBt8Bc12p+WXckhzcICo0wtJAoU8YZTY5qE0Id1GSseTk6S+L3BlXeVIU" crossorigin="anonymous">
<link rel='stylesheet' href='/bootstrap/dist/css/bootstrap.min.css'>
<script src="https://www.gstatic.com/firebasejs/5.7.0/firebase.js"></script>
</head>
<body id="vue-app">