Email Login
This commit is contained in:
parent
f853a2bf0f
commit
3baf79e8f6
@ -15,7 +15,9 @@ app.set('view engine', 'ejs');
|
|||||||
|
|
||||||
app.use(logger('dev'));
|
app.use(logger('dev'));
|
||||||
app.use(express.json());
|
app.use(express.json());
|
||||||
app.use(express.urlencoded({ extended: false }));
|
app.use(express.urlencoded({
|
||||||
|
extended: false
|
||||||
|
}));
|
||||||
app.use(express.static(path.join(__dirname, 'public')));
|
app.use(express.static(path.join(__dirname, 'public')));
|
||||||
|
|
||||||
app.use('/', indexRouter);
|
app.use('/', indexRouter);
|
||||||
@ -23,14 +25,14 @@ app.use(axios);
|
|||||||
app.use('/users', usersRouter);
|
app.use('/users', usersRouter);
|
||||||
|
|
||||||
// catch 404 and forward to error handler
|
// catch 404 and forward to error handler
|
||||||
app.use(function(req, res, next) {
|
app.use(function (req, res, next) {
|
||||||
var err = new Error('Not Found');
|
var err = new Error('Not Found');
|
||||||
err.status = 404;
|
err.status = 404;
|
||||||
next(err);
|
next(err);
|
||||||
});
|
});
|
||||||
|
|
||||||
// error handler
|
// error handler
|
||||||
app.use(function(err, req, res, next) {
|
app.use(function (err, req, res, next) {
|
||||||
// set locals, only providing error in development
|
// set locals, only providing error in development
|
||||||
res.locals.message = err.message;
|
res.locals.message = err.message;
|
||||||
res.locals.error = req.app.get('env') === 'development' ? err : {};
|
res.locals.error = req.app.get('env') === 'development' ? err : {};
|
||||||
@ -40,4 +42,4 @@ app.use(function(err, req, res, next) {
|
|||||||
res.render('error');
|
res.render('error');
|
||||||
});
|
});
|
||||||
|
|
||||||
module.exports = app;
|
module.exports = app;
|
@ -1,9 +1,9 @@
|
|||||||
module.exports ={
|
module.exports = {
|
||||||
postgresSQL:{
|
postgresSQL: {
|
||||||
user:"smartshopper-user",
|
user: "smartshopper-user",
|
||||||
host:"188.166.124.80",
|
host: "188.166.124.80",
|
||||||
database:"smartshopperdb",
|
database: "smartshopperdb",
|
||||||
password:"jW^v#&LjNY_b3-k*jYj!U4Xz?T??m_D6249XAeWZ#7C^FRbKm!c_Dt+qj@4&a-Hs",
|
password: "jW^v#&LjNY_b3-k*jYj!U4Xz?T??m_D6249XAeWZ#7C^FRbKm!c_Dt+qj@4&a-Hs",
|
||||||
port:"5432"
|
port: "5432"
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,45 +1,44 @@
|
|||||||
const { Client } = require ("pg");
|
const {
|
||||||
const {postgresSQL} = require("./keys")
|
Client
|
||||||
|
} = require("pg");
|
||||||
|
const {
|
||||||
|
postgresSQL
|
||||||
|
} = require("./keys")
|
||||||
|
|
||||||
const client = new Client(postgresSQL);
|
const client = new Client(postgresSQL);
|
||||||
|
|
||||||
async function connect() {
|
async function connect() {
|
||||||
try{
|
try {
|
||||||
await client.connect();
|
await client.connect();
|
||||||
console.log("Database connected!");
|
console.log("Database connected!");
|
||||||
}
|
} catch (error) {
|
||||||
catch(error)
|
|
||||||
{
|
|
||||||
console.error(error)
|
console.error(error)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
connect();
|
connect();
|
||||||
|
|
||||||
async function query(queryString,param)
|
async function query(queryString, param) {
|
||||||
{
|
|
||||||
try {
|
try {
|
||||||
let result = await client.query(queryString,param);
|
let result = await client.query(queryString, param);
|
||||||
let resultarray = [];
|
let resultarray = [];
|
||||||
for(let row of result.rows)
|
for (let row of result.rows) {
|
||||||
{
|
resultarray.push(row.obj);
|
||||||
resultarray.push(row.obj);
|
}
|
||||||
}
|
return resultarray;
|
||||||
return resultarray;
|
} catch (error) {
|
||||||
}
|
|
||||||
catch(error)
|
|
||||||
{
|
|
||||||
console.log(error)
|
console.log(error)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function nonQuery(queryString,param) {
|
async function nonQuery(queryString, param) {
|
||||||
try {
|
try {
|
||||||
await client.query(queryString,param);
|
await client.query(queryString, param);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error)
|
console.error(error)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
query, nonQuery
|
query,
|
||||||
|
nonQuery
|
||||||
}
|
}
|
@ -1,4 +1,7 @@
|
|||||||
const { query, nonQuery } = require("../db-config/postgresql-common");
|
const {
|
||||||
|
query,
|
||||||
|
nonQuery
|
||||||
|
} = require("../db-config/postgresql-common");
|
||||||
|
|
||||||
const stringSimilarity = require('string-similarity');
|
const stringSimilarity = require('string-similarity');
|
||||||
|
|
||||||
@ -7,12 +10,10 @@ const stringSimilarity = require('string-similarity');
|
|||||||
//Create User Info
|
//Create User Info
|
||||||
|
|
||||||
async function updateUser(uid, mid, name, picture, email) {
|
async function updateUser(uid, mid, name, picture, email) {
|
||||||
try {
|
try {
|
||||||
await nonQuery('INSERT INTO "User" (username, message_id, name, picture, email) VALUES ($1, $2, $3, $4, $5);', [uid, mid, name, picture, email]);
|
await nonQuery('INSERT INTO "User" (username, message_id, name, picture, email) VALUES ($1, $2, $3, $4, $5);', [uid, mid, name, picture, email]);
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
catch (error) {
|
} catch (error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -22,10 +23,8 @@ async function getmessageids(sl_id) {
|
|||||||
let members = query('SELECT * FROM "Shoppinglist_member" WHERE sl_id = $1;', [sl_id]);
|
let members = query('SELECT * FROM "Shoppinglist_member" WHERE sl_id = $1;', [sl_id]);
|
||||||
let admin = query('SELECT * FROM "Shoppinglist_admin" WHERE sl_id = $1;', [sl_id]);
|
let admin = query('SELECT * FROM "Shoppinglist_admin" WHERE sl_id = $1;', [sl_id]);
|
||||||
return users_to_array(admin, members);
|
return users_to_array(admin, members);
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
catch(error) {
|
} catch (error) {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -35,13 +34,13 @@ async function getmessageids(sl_id) {
|
|||||||
async function searchUsers(searchstring) {
|
async function searchUsers(searchstring) {
|
||||||
try {
|
try {
|
||||||
let users = await query('SELECT row_to_json("User") AS obj FROM "User";');
|
let users = await query('SELECT row_to_json("User") AS obj FROM "User";');
|
||||||
return users.filter(function(obj) {return obj.name.toUpperCase().includes(searchstring.toUpperCase())});
|
return users.filter(function (obj) {
|
||||||
}
|
return obj.name.toUpperCase().includes(searchstring.toUpperCase())
|
||||||
|
});
|
||||||
catch(error) {
|
} catch (error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -49,14 +48,12 @@ async function searchUsers(searchstring) {
|
|||||||
//SELECT own shopping lists
|
//SELECT own shopping lists
|
||||||
async function getShoppinglistsAdmin(username) {
|
async function getShoppinglistsAdmin(username) {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
let result = await query('SELECT row_to_json("Shoppinglist") AS obj FROM "Shoppinglist" JOIN "Shoppinglist_admin" USING (sl_id) WHERE \
|
let result = await query('SELECT row_to_json("Shoppinglist") AS obj FROM "Shoppinglist" JOIN "Shoppinglist_admin" USING (sl_id) WHERE \
|
||||||
username = $1', [username]);
|
username = $1', [username]);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
} catch (error) {
|
||||||
|
|
||||||
catch (error) {
|
|
||||||
console.error(error);
|
console.error(error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -67,9 +64,7 @@ async function getShoppinglistsByLink(link) {
|
|||||||
console.log("PPPPP LIIINK:", link)
|
console.log("PPPPP LIIINK:", link)
|
||||||
let result = await query('SELECT row_to_json("Shoppinglist") AS obj FROM "Shoppinglist" WHERE invitelink = $1', [link]);
|
let result = await query('SELECT row_to_json("Shoppinglist") AS obj FROM "Shoppinglist" WHERE invitelink = $1', [link]);
|
||||||
return result;
|
return result;
|
||||||
}
|
} catch (error) {
|
||||||
|
|
||||||
catch (error) {
|
|
||||||
console.error(error);
|
console.error(error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -81,9 +76,7 @@ async function getShoppinglistsShared(username) {
|
|||||||
let result = await query('SELECT row_to_json("Shoppinglist") AS obj FROM "Shoppinglist" JOIN "Shoppinglist_member" USING (sl_id) WHERE username = $1;', [username]);
|
let result = await query('SELECT row_to_json("Shoppinglist") AS obj FROM "Shoppinglist" JOIN "Shoppinglist_member" USING (sl_id) WHERE username = $1;', [username]);
|
||||||
console.log(result);
|
console.log(result);
|
||||||
return result;
|
return result;
|
||||||
}
|
} catch (error) {
|
||||||
|
|
||||||
catch (error) {
|
|
||||||
console.error(error);
|
console.error(error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -100,27 +93,21 @@ async function newShoppinglist(name, description, username, color) {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
await nonQuery('INSERT INTO "User" (username) VALUES ($1);', [username]);
|
await nonQuery('INSERT INTO "User" (username) VALUES ($1);', [username]);
|
||||||
}
|
} catch (error) {
|
||||||
|
|
||||||
catch (error) {
|
|
||||||
console.error(error);
|
console.error(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
//insert shoppinglist
|
//insert shoppinglist
|
||||||
try {
|
try {
|
||||||
await nonQuery('INSERT INTO "Shoppinglist" (sl_id, name, description, color) VALUES ($1, $2, $3, $4);', [sl_id, name, description, color]);
|
await nonQuery('INSERT INTO "Shoppinglist" (sl_id, name, description, color) VALUES ($1, $2, $3, $4);', [sl_id, name, description, color]);
|
||||||
}
|
} catch (error) {
|
||||||
|
|
||||||
catch (error) {
|
|
||||||
console.error(error);
|
console.error(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
//insert admin
|
//insert admin
|
||||||
try {
|
try {
|
||||||
await nonQuery('INSERT INTO "Shoppinglist_admin" (username, sl_id) VALUES ($1, $2);', [username, sl_id]);
|
await nonQuery('INSERT INTO "Shoppinglist_admin" (username, sl_id) VALUES ($1, $2);', [username, sl_id]);
|
||||||
}
|
} catch (error) {
|
||||||
|
|
||||||
catch (error) {
|
|
||||||
console.error(error);
|
console.error(error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -131,21 +118,19 @@ async function newShoppinglist(name, description, username, color) {
|
|||||||
async function editShoppinglist(sl_id, newname, newdescription, newcolor) {
|
async function editShoppinglist(sl_id, newname, newdescription, newcolor) {
|
||||||
try {
|
try {
|
||||||
let shoppinglist = await query('SELECT row_to_json("Shoppinglist") AS obj FROM "Shoppinglist" WHERE sl_id = $1;', [sl_id]);
|
let shoppinglist = await query('SELECT row_to_json("Shoppinglist") AS obj FROM "Shoppinglist" WHERE sl_id = $1;', [sl_id]);
|
||||||
|
|
||||||
if(shoppinglist.name != newname && newname != undefined) {
|
if (shoppinglist.name != newname && newname != undefined) {
|
||||||
await nonQuery('UPDATE "Shoppinglist" SET name = $1 WHERE sl_id = $2;', [newname, sl_id]);
|
await nonQuery('UPDATE "Shoppinglist" SET name = $1 WHERE sl_id = $2;', [newname, sl_id]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(shoppinglist.description != newdescription && newdescription != undefined) {
|
if (shoppinglist.description != newdescription && newdescription != undefined) {
|
||||||
await nonQuery('UPDATE "Shoppinglist" SET description = $1 WHERE sl_id = $2;', [newdescription, sl_id]);
|
await nonQuery('UPDATE "Shoppinglist" SET description = $1 WHERE sl_id = $2;', [newdescription, sl_id]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(shoppinglist.color != newcolor && newcolor != undefined) {
|
if (shoppinglist.color != newcolor && newcolor != undefined) {
|
||||||
await nonQuery('UPDATE "Shoppinglist" SET color = $1 WHERE sl_id = $2;', [newcolor, sl_id]);
|
await nonQuery('UPDATE "Shoppinglist" SET color = $1 WHERE sl_id = $2;', [newcolor, sl_id]);
|
||||||
}
|
}
|
||||||
}
|
} catch (error) {
|
||||||
|
|
||||||
catch (error) {
|
|
||||||
console.error(error);
|
console.error(error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -173,9 +158,7 @@ async function displayShoppinglist(sl_id) {
|
|||||||
let admin = await query('SELECT row_to_json("User") as obj FROM "User" JOIN "Shoppinglist_admin" USING (username) WHERE sl_id = $1', [sl_id]);
|
let admin = await query('SELECT row_to_json("User") as obj FROM "User" JOIN "Shoppinglist_admin" USING (username) WHERE sl_id = $1', [sl_id]);
|
||||||
|
|
||||||
return items_in_groups(groups, items, sl_id, admin[0].username, admin[0].message_id, members, shoppinglist[0].name, shoppinglist[0].description);
|
return items_in_groups(groups, items, sl_id, admin[0].username, admin[0].message_id, members, shoppinglist[0].name, shoppinglist[0].description);
|
||||||
}
|
} catch (error) {
|
||||||
|
|
||||||
catch (error) {
|
|
||||||
console.error(error);
|
console.error(error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -188,9 +171,7 @@ async function deleteShoppinglist(sl_id) {
|
|||||||
await nonQuery('DELETE FROM "Shoppinglist_admin" WHERE sl_id = $1', [sl_id]);
|
await nonQuery('DELETE FROM "Shoppinglist_admin" WHERE sl_id = $1', [sl_id]);
|
||||||
await nonQuery('DELETE FROM "Shoppinglist_member" WHERE sl_id = $1', [sl_id]);
|
await nonQuery('DELETE FROM "Shoppinglist_member" WHERE sl_id = $1', [sl_id]);
|
||||||
await nonQuery('DELETE FROM "Shoppinglist" WHERE sl_id = $1', [sl_id]);
|
await nonQuery('DELETE FROM "Shoppinglist" WHERE sl_id = $1', [sl_id]);
|
||||||
}
|
} catch (error) {
|
||||||
|
|
||||||
catch (error) {
|
|
||||||
console.error(error);
|
console.error(error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -201,9 +182,7 @@ async function addGroup(sl_id, name, color, hidden) {
|
|||||||
try {
|
try {
|
||||||
let grid = generate_group_id();
|
let grid = generate_group_id();
|
||||||
await nonQuery('INSERT INTO "Group" (group_id, sl_id, name, color, hidden) VALUES ($1, $2, $3, $4, $5);', [grid, sl_id, name, color, hidden]);
|
await nonQuery('INSERT INTO "Group" (group_id, sl_id, name, color, hidden) VALUES ($1, $2, $3, $4, $5);', [grid, sl_id, name, color, hidden]);
|
||||||
}
|
} catch (error) {
|
||||||
|
|
||||||
catch (error) {
|
|
||||||
console.error(error);
|
console.error(error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -214,9 +193,7 @@ async function addItem(group_id, sl_id, name, count) {
|
|||||||
try {
|
try {
|
||||||
let itid = generate_item_id();
|
let itid = generate_item_id();
|
||||||
await nonQuery('INSERT INTO "Item" VALUES ($1, $2, $3, $4, $5);', [itid, group_id, sl_id, name, count]);
|
await nonQuery('INSERT INTO "Item" VALUES ($1, $2, $3, $4, $5);', [itid, group_id, sl_id, name, count]);
|
||||||
}
|
} catch (error) {
|
||||||
|
|
||||||
catch (error) {
|
|
||||||
console.error(error);
|
console.error(error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -224,23 +201,21 @@ async function addItem(group_id, sl_id, name, count) {
|
|||||||
//Edit Group
|
//Edit Group
|
||||||
async function editGroup(sl_id, group_id, name, color, hidden) {
|
async function editGroup(sl_id, group_id, name, color, hidden) {
|
||||||
try {
|
try {
|
||||||
let group = await query('SELECT row_to_json("Group") AS obj FROM "Group" WHERE group_id = $1 AND sl_id = $2', [sl_id, group_id]);
|
let group = await query('SELECT row_to_json("Group") AS obj FROM "Group" WHERE group_id = $1 AND sl_id = $2', [sl_id, group_id]);
|
||||||
|
|
||||||
if(group.name != name && name != undefined) {
|
if (group.name != name && name != undefined) {
|
||||||
await nonQuery('UPDATE "Group" SET name = $1 WHERE group_id = $2 AND sl_id = $3;', [name, group_id, sl_id]);
|
await nonQuery('UPDATE "Group" SET name = $1 WHERE group_id = $2 AND sl_id = $3;', [name, group_id, sl_id]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(group.color != color && color != undefined) {
|
if (group.color != color && color != undefined) {
|
||||||
await nonQuery('UPDATE "Group" SET color = $1 WHERE group_id = $2 AND sl_id = $3;', [color, group_id, sl_id]);
|
await nonQuery('UPDATE "Group" SET color = $1 WHERE group_id = $2 AND sl_id = $3;', [color, group_id, sl_id]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(group.hidden != hidden && hidden != undefined) {
|
if (group.hidden != hidden && hidden != undefined) {
|
||||||
await nonQuery('UPDATE "Group" SET hidden = $1 WHERE group_id = $2 AND sl_id = $3;', [hidden, group_id, sl_id]);
|
await nonQuery('UPDATE "Group" SET hidden = $1 WHERE group_id = $2 AND sl_id = $3;', [hidden, group_id, sl_id]);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} catch (error) {
|
||||||
|
|
||||||
catch (error) {
|
|
||||||
console.error(error);
|
console.error(error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -252,16 +227,14 @@ async function editItem(sl_id, group_id, item_id, name, count) {
|
|||||||
try {
|
try {
|
||||||
let item = query('SELECT row_to_json("Item") FROM "Item" WHERE item_id = $1 AND group_id = $2 AND sl_id = $3', [item_id, group_id, sl_id]);
|
let item = query('SELECT row_to_json("Item") FROM "Item" WHERE item_id = $1 AND group_id = $2 AND sl_id = $3', [item_id, group_id, sl_id]);
|
||||||
|
|
||||||
if(item.name != name && name != undefined) {
|
if (item.name != name && name != undefined) {
|
||||||
await nonQuery('UPDATE "Item" SET name = $1 WHERE item_id = $2 AND group_id = $3 AND sl_id = $4', [name, item_id, group_id, sl_id]);
|
await nonQuery('UPDATE "Item" SET name = $1 WHERE item_id = $2 AND group_id = $3 AND sl_id = $4', [name, item_id, group_id, sl_id]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(item.count != count && count != undefined) {
|
if (item.count != count && count != undefined) {
|
||||||
await nonQuery('UPDATE "Item" SET count = $1 WHERE item_id = $2 AND group_id = $3 AND sl_id = $4', [count, item_id, group_id, sl_id]);
|
await nonQuery('UPDATE "Item" SET count = $1 WHERE item_id = $2 AND group_id = $3 AND sl_id = $4', [count, item_id, group_id, sl_id]);
|
||||||
}
|
}
|
||||||
}
|
} catch (error) {
|
||||||
|
|
||||||
catch (error) {
|
|
||||||
console.error(error);
|
console.error(error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -275,9 +248,7 @@ async function deleteGroup(group_id, sl_id) {
|
|||||||
|
|
||||||
//Leere Gruppe löschen
|
//Leere Gruppe löschen
|
||||||
nonQuery('DELETE FROM "Group" WHERE group_id = $1 AND sl_id = $2', [group_id, sl_id]);
|
nonQuery('DELETE FROM "Group" WHERE group_id = $1 AND sl_id = $2', [group_id, sl_id]);
|
||||||
}
|
} catch (error) {
|
||||||
|
|
||||||
catch (error) {
|
|
||||||
console.error(error);
|
console.error(error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -287,9 +258,7 @@ async function deleteGroup(group_id, sl_id) {
|
|||||||
async function deleteItem(item_id, group_id, sl_id) {
|
async function deleteItem(item_id, group_id, sl_id) {
|
||||||
try {
|
try {
|
||||||
nonQuery('DELETE FROM "Item" WHERE item_id = $1 AND group_id = $2 AND sl_id = $3;', [item_id, group_id, sl_id]);
|
nonQuery('DELETE FROM "Item" WHERE item_id = $1 AND group_id = $2 AND sl_id = $3;', [item_id, group_id, sl_id]);
|
||||||
}
|
} catch (error) {
|
||||||
|
|
||||||
catch(error) {
|
|
||||||
console.error(error);
|
console.error(error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -304,35 +273,33 @@ async function moveDoneItems(uid, sl_id, billcontent) {
|
|||||||
|
|
||||||
var today = new Date();
|
var today = new Date();
|
||||||
var dd = today.getDate();
|
var dd = today.getDate();
|
||||||
var mm = today.getMonth()+1;
|
var mm = today.getMonth() + 1;
|
||||||
var yyyy = today.getFullYear();
|
var yyyy = today.getFullYear();
|
||||||
|
|
||||||
if(dd<10) {
|
if (dd < 10) {
|
||||||
dd = '0'+dd
|
dd = '0' + dd
|
||||||
}
|
}
|
||||||
|
|
||||||
if(mm<10) {
|
if (mm < 10) {
|
||||||
mm = '0'+mm
|
mm = '0' + mm
|
||||||
}
|
}
|
||||||
|
|
||||||
today = mm + '/' + dd + '/' + yyyy;
|
today = mm + '/' + dd + '/' + yyyy;
|
||||||
|
|
||||||
for(let item of removeableItems) {
|
for (let item of removeableItems) {
|
||||||
await nonQuery('INSERT INTO "Done_Purchase" (purchased_item_id, username, name, date, count) VALUES($1,$2,$3,$4,$5);',
|
await nonQuery('INSERT INTO "Done_Purchase" (purchased_item_id, username, name, date, count) VALUES($1,$2,$3,$4,$5);',
|
||||||
[generate_item_id(), uid, item.name, today, 1]);
|
[generate_item_id(), uid, item.name, today, 1]);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for(let item of removeableItems) {
|
for (let item of removeableItems) {
|
||||||
await nonQuery('DELETE FROM "Item" WHERE item_id = $1 AND group_id = $2 AND sl_id = $3;', [item.item_id, item.group_id, item.sl_id]);
|
await nonQuery('DELETE FROM "Item" WHERE item_id = $1 AND group_id = $2 AND sl_id = $3;', [item.item_id, item.group_id, item.sl_id]);
|
||||||
console.log(item);
|
console.log(item);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return "done"
|
return "done"
|
||||||
}
|
} catch (error) {
|
||||||
|
|
||||||
catch(error) {
|
|
||||||
console.error(error);
|
console.error(error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -343,9 +310,7 @@ async function getDonePurchases(uid) {
|
|||||||
try {
|
try {
|
||||||
let result = await query('SELECT row_to_json("Done_Purchase") AS obj FROM "Done_Purchase" WHERE username = $1;', [uid]);
|
let result = await query('SELECT row_to_json("Done_Purchase") AS obj FROM "Done_Purchase" WHERE username = $1;', [uid]);
|
||||||
return result;
|
return result;
|
||||||
}
|
} catch (error) {
|
||||||
|
|
||||||
catch(error) {
|
|
||||||
console.error(error);
|
console.error(error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -366,9 +331,7 @@ async function verifyInvite(link, user_id) {
|
|||||||
let sl_id = result[0].sl_id;
|
let sl_id = result[0].sl_id;
|
||||||
console.log("!!! SL ID: ", sl_id);
|
console.log("!!! SL ID: ", sl_id);
|
||||||
await nonQuery('INSERT INTO "Shoppinglist_member" (username, sl_id) VALUES ($1, $2);', [user_id, sl_id]);
|
await nonQuery('INSERT INTO "Shoppinglist_member" (username, sl_id) VALUES ($1, $2);', [user_id, sl_id]);
|
||||||
}
|
} catch (error) {
|
||||||
|
|
||||||
catch (error) {
|
|
||||||
console.error(error);
|
console.error(error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -377,9 +340,7 @@ async function createInvite(sl_id) {
|
|||||||
try {
|
try {
|
||||||
let link = generateInviteLink();
|
let link = generateInviteLink();
|
||||||
await nonQuery('UPDATE "Shoppinglist" SET invitelink = $1 WHERE sl_id = $2;', [link, sl_id]);
|
await nonQuery('UPDATE "Shoppinglist" SET invitelink = $1 WHERE sl_id = $2;', [link, sl_id]);
|
||||||
}
|
} catch (error) {
|
||||||
|
|
||||||
catch (error) {
|
|
||||||
console.error(error);
|
console.error(error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -388,9 +349,7 @@ async function createInvite(sl_id) {
|
|||||||
async function manInvite(sl_id, uid) {
|
async function manInvite(sl_id, uid) {
|
||||||
try {
|
try {
|
||||||
await nonQuery('INSERT INTO "Shoppinglist_member" (username, sl_id) VALUES ($1, $2);', [uid, sl_id]);
|
await nonQuery('INSERT INTO "Shoppinglist_member" (username, sl_id) VALUES ($1, $2);', [uid, sl_id]);
|
||||||
}
|
} catch (error) {
|
||||||
|
|
||||||
catch(error) {
|
|
||||||
console.error(error);
|
console.error(error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -400,9 +359,7 @@ async function manInvite(sl_id, uid) {
|
|||||||
async function removeMember(uid, sl_id) {
|
async function removeMember(uid, sl_id) {
|
||||||
try {
|
try {
|
||||||
await nonQuery('DELETE FROM "Shoppinglist_member" WHERE username = $1 AND sl_id = $2', [uid, sl_id]);
|
await nonQuery('DELETE FROM "Shoppinglist_member" WHERE username = $1 AND sl_id = $2', [uid, sl_id]);
|
||||||
}
|
} catch (error) {
|
||||||
|
|
||||||
catch(error) {
|
|
||||||
console.error(error);
|
console.error(error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -417,7 +374,7 @@ function generate_sl_id() {
|
|||||||
var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
||||||
var output = "";
|
var output = "";
|
||||||
|
|
||||||
for(let i = 0; i < 8; i++) {
|
for (let i = 0; i < 8; i++) {
|
||||||
output += possible.charAt(Math.floor(Math.random() * possible.length));
|
output += possible.charAt(Math.floor(Math.random() * possible.length));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -429,7 +386,7 @@ function generate_group_id() {
|
|||||||
var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
||||||
var output = "";
|
var output = "";
|
||||||
|
|
||||||
for(let i = 0; i < 8; i++) {
|
for (let i = 0; i < 8; i++) {
|
||||||
output += possible.charAt(Math.floor(Math.random() * possible.length));
|
output += possible.charAt(Math.floor(Math.random() * possible.length));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -441,7 +398,7 @@ function generate_item_id() {
|
|||||||
var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
||||||
var output = "";
|
var output = "";
|
||||||
|
|
||||||
for(let i = 0; i < 8; i++) {
|
for (let i = 0; i < 8; i++) {
|
||||||
output += possible.charAt(Math.floor(Math.random() * possible.length));
|
output += possible.charAt(Math.floor(Math.random() * possible.length));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -462,17 +419,19 @@ function items_in_groups(groups, items, sl_id, admin_uid, admin_mid, members, na
|
|||||||
groups: []
|
groups: []
|
||||||
};
|
};
|
||||||
|
|
||||||
for(let item of groups) {
|
for (let item of groups) {
|
||||||
|
|
||||||
result.groups.push({
|
result.groups.push({
|
||||||
group_id: item.group_id,
|
group_id: item.group_id,
|
||||||
name: item.name,
|
name: item.name,
|
||||||
color: item.color,
|
color: item.color,
|
||||||
content: items.filter(function(obj) {return obj.group_id == item.group_id})
|
content: items.filter(function (obj) {
|
||||||
|
return obj.group_id == item.group_id
|
||||||
|
})
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
for(let item of members) {
|
for (let item of members) {
|
||||||
|
|
||||||
result.members.push({
|
result.members.push({
|
||||||
uid: item.username,
|
uid: item.username,
|
||||||
@ -488,7 +447,7 @@ function generateInviteLink() {
|
|||||||
var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
||||||
var output = "";
|
var output = "";
|
||||||
|
|
||||||
for(let i = 0; i < 50; i++) {
|
for (let i = 0; i < 50; i++) {
|
||||||
output += possible.charAt(Math.floor(Math.random() * possible.length));
|
output += possible.charAt(Math.floor(Math.random() * possible.length));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -500,7 +459,7 @@ function users_to_array(admin, members) {
|
|||||||
|
|
||||||
users.push(admin.username);
|
users.push(admin.username);
|
||||||
|
|
||||||
for(let item of members) {
|
for (let item of members) {
|
||||||
users.push(item.username);
|
users.push(item.username);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -513,28 +472,18 @@ function compareData(listitems, doneitems) {
|
|||||||
|
|
||||||
let output = [];
|
let output = [];
|
||||||
|
|
||||||
for(let item of listitems) {
|
for (let item of listitems) {
|
||||||
if(doneitems.includes(item.name)) {
|
if (doneitems.includes(item.name)) {
|
||||||
output.push(item);
|
output.push(item);
|
||||||
}
|
} else if (doneitems.toUpperCase().includes(item.name.toUpperCase())) {
|
||||||
|
|
||||||
else if(doneitems.toUpperCase().includes(item.name.toUpperCase())) {
|
|
||||||
output.push(item);
|
output.push(item);
|
||||||
}
|
} else if (doneitems.toLowerCase().includes(item.name.toLowerCase())) {
|
||||||
|
|
||||||
else if(doneitems.toLowerCase().includes(item.name.toLowerCase())) {
|
|
||||||
output.push(item);
|
output.push(item);
|
||||||
}
|
} else if (probability(item.name, doneitems) > 0.6) {
|
||||||
|
|
||||||
else if(probability(item.name, doneitems) > 0.6) {
|
|
||||||
output.push(item);
|
output.push(item);
|
||||||
}
|
} else if (probability(item.name.toUpperCase(), doneitems.toUpperCase()) > 0.6) {
|
||||||
|
|
||||||
else if(probability(item.name.toUpperCase(), doneitems.toUpperCase()) > 0.6) {
|
|
||||||
output.push(item);
|
output.push(item);
|
||||||
}
|
} else if (probability(item.name.toLowerCase(), doneitems.toLowerCase()) > 0.6) {
|
||||||
|
|
||||||
else if(probability(item.name.toLowerCase(), doneitems.toLowerCase()) > 0.6) {
|
|
||||||
output.push(item);
|
output.push(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -546,11 +495,11 @@ function probability(cur_item, data) {
|
|||||||
|
|
||||||
let best = 0;
|
let best = 0;
|
||||||
|
|
||||||
for(let i = 0; i < data.length; i++) {
|
for (let i = 0; i < data.length; i++) {
|
||||||
|
|
||||||
let prob = stringSimilarity.compareTwoStrings(cur_item, data.slice(i, i + cur_item.length));
|
let prob = stringSimilarity.compareTwoStrings(cur_item, data.slice(i, i + cur_item.length));
|
||||||
|
|
||||||
if(prob > best) {
|
if (prob > best) {
|
||||||
best = prob;
|
best = prob;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -561,7 +510,25 @@ function probability(cur_item, data) {
|
|||||||
|
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
getShoppinglistsAdmin, getShoppinglistsShared, newShoppinglist, displayShoppinglist, deleteShoppinglist, addGroup,
|
getShoppinglistsAdmin,
|
||||||
addItem, verifyInvite, createInvite, editShoppinglist, editGroup, editItem, deleteGroup, deleteItem, manInvite, updateUser,
|
getShoppinglistsShared,
|
||||||
moveDoneItems, getDonePurchases, getShoppinglistsByLink, searchUsers, removeMember
|
newShoppinglist,
|
||||||
}
|
displayShoppinglist,
|
||||||
|
deleteShoppinglist,
|
||||||
|
addGroup,
|
||||||
|
addItem,
|
||||||
|
verifyInvite,
|
||||||
|
createInvite,
|
||||||
|
editShoppinglist,
|
||||||
|
editGroup,
|
||||||
|
editItem,
|
||||||
|
deleteGroup,
|
||||||
|
deleteItem,
|
||||||
|
manInvite,
|
||||||
|
updateUser,
|
||||||
|
moveDoneItems,
|
||||||
|
getDonePurchases,
|
||||||
|
getShoppinglistsByLink,
|
||||||
|
searchUsers,
|
||||||
|
removeMember
|
||||||
|
}
|
@ -10,28 +10,34 @@ var greenlock = Greenlock.create({
|
|||||||
// Let's Encrypt v2 is ACME draft 11
|
// Let's Encrypt v2 is ACME draft 11
|
||||||
version: 'draft-11'
|
version: 'draft-11'
|
||||||
|
|
||||||
, server: 'https://acme-v02.api.letsencrypt.org/directory'
|
,
|
||||||
// Note: If at first you don't succeed, stop and switch to staging
|
server: 'https://acme-v02.api.letsencrypt.org/directory'
|
||||||
// https://acme-staging-v02.api.letsencrypt.org/directory
|
// Note: If at first you don't succeed, stop and switch to staging
|
||||||
|
// https://acme-staging-v02.api.letsencrypt.org/directory
|
||||||
|
|
||||||
// You MUST change this to a valid email address
|
// You MUST change this to a valid email address
|
||||||
, email: 'jon@example.com'
|
,
|
||||||
|
email: 'jon@example.com'
|
||||||
|
|
||||||
// You MUST NOT build clients that accept the ToS without asking the user
|
// You MUST NOT build clients that accept the ToS without asking the user
|
||||||
, agreeTos: true
|
,
|
||||||
|
agreeTos: true
|
||||||
|
|
||||||
// You MUST change these to valid domains
|
// You MUST change these to valid domains
|
||||||
// NOTE: all domains will validated and listed on the certificate
|
// NOTE: all domains will validated and listed on the certificate
|
||||||
, approvedDomains: [ 'example.com', 'www.example.com' ]
|
,
|
||||||
|
approvedDomains: ['example.com', 'www.example.com']
|
||||||
|
|
||||||
// You MUST have access to write to directory where certs are saved
|
// You MUST have access to write to directory where certs are saved
|
||||||
// ex: /home/foouser/acme/etc
|
// ex: /home/foouser/acme/etc
|
||||||
, configDir: '~/.config/acme/'
|
,
|
||||||
|
configDir: '~/.config/acme/'
|
||||||
|
|
||||||
// Get notified of important updates and help me make greenlock better
|
// Get notified of important updates and help me make greenlock better
|
||||||
, communityMember: true
|
,
|
||||||
|
communityMember: true
|
||||||
|
|
||||||
//, debug: true
|
//, debug: true
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -45,8 +51,8 @@ var greenlock = Greenlock.create({
|
|||||||
var redirectHttps = require('redirect-https')();
|
var redirectHttps = require('redirect-https')();
|
||||||
var acmeChallengeHandler = greenlock.middleware(function (req, res) {
|
var acmeChallengeHandler = greenlock.middleware(function (req, res) {
|
||||||
res.setHeader('Content-Type', 'text/html; charset=utf-8');
|
res.setHeader('Content-Type', 'text/html; charset=utf-8');
|
||||||
res.end('<h1>Hello, ⚠️ Insecure World!</h1><a>Visit Secure Site</a>'
|
res.end('<h1>Hello, ⚠️ Insecure World!</h1><a>Visit Secure Site</a>' +
|
||||||
+ '<script>document.querySelector("a").href=window.location.href.replace(/^http/i, "https");</script>'
|
'<script>document.querySelector("a").href=window.location.href.replace(/^http/i, "https");</script>'
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
require('http').createServer(acmeChallengeHandler).listen(80, function () {
|
require('http').createServer(acmeChallengeHandler).listen(80, function () {
|
||||||
@ -61,7 +67,10 @@ require('http').createServer(acmeChallengeHandler).listen(80, function () {
|
|||||||
|
|
||||||
// spdy is a drop-in replacement for the https API
|
// spdy is a drop-in replacement for the https API
|
||||||
var spdyOptions = Object.assign({}, greenlock.tlsOptions);
|
var spdyOptions = Object.assign({}, greenlock.tlsOptions);
|
||||||
spdyOptions.spdy = { protocols: [ 'h2', 'http/1.1' ], plain: false };
|
spdyOptions.spdy = {
|
||||||
|
protocols: ['h2', 'http/1.1'],
|
||||||
|
plain: false
|
||||||
|
};
|
||||||
var server = require('spdy').createServer(spdyOptions, require('express')().use('/', function (req, res) {
|
var server = require('spdy').createServer(spdyOptions, require('express')().use('/', function (req, res) {
|
||||||
res.setHeader('Content-Type', 'text/html; charset=utf-8');
|
res.setHeader('Content-Type', 'text/html; charset=utf-8');
|
||||||
res.end('<h1>Hello, 🔐 Secure World!</h1>');
|
res.end('<h1>Hello, 🔐 Secure World!</h1>');
|
||||||
@ -72,4 +81,4 @@ server.on('error', function (err) {
|
|||||||
server.on('listening', function () {
|
server.on('listening', function () {
|
||||||
console.log("Listening for SPDY/http2/https requests on", this.address());
|
console.log("Listening for SPDY/http2/https requests on", this.address());
|
||||||
});
|
});
|
||||||
server.listen(443);
|
server.listen(443);
|
@ -6,24 +6,31 @@ require('../').create({
|
|||||||
// Let's Encrypt v2 is ACME draft 11
|
// Let's Encrypt v2 is ACME draft 11
|
||||||
version: 'draft-11'
|
version: 'draft-11'
|
||||||
|
|
||||||
, server: 'https://acme-v02.api.letsencrypt.org/directory'
|
,
|
||||||
// Note: If at first you don't succeed, stop and switch to staging
|
server: 'https://acme-v02.api.letsencrypt.org/directory'
|
||||||
// https://acme-staging-v02.api.letsencrypt.org/directory
|
// Note: If at first you don't succeed, stop and switch to staging
|
||||||
|
// https://acme-staging-v02.api.letsencrypt.org/directory
|
||||||
|
|
||||||
, email: 'john.doe@example.com'
|
,
|
||||||
|
email: 'john.doe@example.com'
|
||||||
|
|
||||||
, agreeTos: true
|
,
|
||||||
|
agreeTos: true
|
||||||
|
|
||||||
, approvedDomains: [ 'example.com', 'www.example.com' ]
|
,
|
||||||
|
approvedDomains: ['example.com', 'www.example.com']
|
||||||
|
|
||||||
, app: require('express')().use('/', function (req, res) {
|
,
|
||||||
res.end('Hello, World!');
|
app: require('express')().use('/', function (req, res) {
|
||||||
})
|
res.end('Hello, World!');
|
||||||
|
})
|
||||||
|
|
||||||
, renewWithin: (91 * 24 * 60 * 60 * 1000)
|
,
|
||||||
, renewBy: (90 * 24 * 60 * 60 * 1000)
|
renewWithin: (91 * 24 * 60 * 60 * 1000),
|
||||||
|
renewBy: (90 * 24 * 60 * 60 * 1000)
|
||||||
|
|
||||||
// Get notified of important updates and help me make greenlock better
|
// Get notified of important updates and help me make greenlock better
|
||||||
, communityMember: true
|
,
|
||||||
, debug: true
|
communityMember: true,
|
||||||
}).listen(80, 443);
|
debug: true
|
||||||
|
}).listen(80, 443);
|
@ -8,28 +8,34 @@ var greenlock = Greenlock.create({
|
|||||||
// Let's Encrypt v2 is ACME draft 11
|
// Let's Encrypt v2 is ACME draft 11
|
||||||
version: 'draft-11'
|
version: 'draft-11'
|
||||||
|
|
||||||
, server: 'https://acme-v02.api.letsencrypt.org/directory'
|
,
|
||||||
// Note: If at first you don't succeed, stop and switch to staging
|
server: 'https://acme-v02.api.letsencrypt.org/directory'
|
||||||
// https://acme-staging-v02.api.letsencrypt.org/directory
|
// Note: If at first you don't succeed, stop and switch to staging
|
||||||
|
// https://acme-staging-v02.api.letsencrypt.org/directory
|
||||||
|
|
||||||
// You MUST change this to a valid email address
|
// You MUST change this to a valid email address
|
||||||
, email: 'jon@example.com'
|
,
|
||||||
|
email: 'jon@example.com'
|
||||||
|
|
||||||
// You MUST NOT build clients that accept the ToS without asking the user
|
// You MUST NOT build clients that accept the ToS without asking the user
|
||||||
, agreeTos: true
|
,
|
||||||
|
agreeTos: true
|
||||||
|
|
||||||
// You MUST change these to valid domains
|
// You MUST change these to valid domains
|
||||||
// NOTE: all domains will validated and listed on the certificate
|
// NOTE: all domains will validated and listed on the certificate
|
||||||
, approvedDomains: [ 'example.com', 'www.example.com' ]
|
,
|
||||||
|
approvedDomains: ['example.com', 'www.example.com']
|
||||||
|
|
||||||
// You MUST have access to write to directory where certs are saved
|
// You MUST have access to write to directory where certs are saved
|
||||||
// ex: /home/foouser/acme/etc
|
// ex: /home/foouser/acme/etc
|
||||||
, configDir: '~/.config/acme/'
|
,
|
||||||
|
configDir: '~/.config/acme/'
|
||||||
|
|
||||||
// Get notified of important updates and help me make greenlock better
|
// Get notified of important updates and help me make greenlock better
|
||||||
, communityMember: true
|
,
|
||||||
|
communityMember: true
|
||||||
|
|
||||||
//, debug: true
|
//, debug: true
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -63,12 +69,12 @@ server.on('error', function (err) {
|
|||||||
server.on('stream', function (stream, headers) {
|
server.on('stream', function (stream, headers) {
|
||||||
console.log(headers);
|
console.log(headers);
|
||||||
stream.respond({
|
stream.respond({
|
||||||
'content-type': 'text/html'
|
'content-type': 'text/html',
|
||||||
, ':status': 200
|
':status': 200
|
||||||
});
|
});
|
||||||
stream.end('Hello, HTTP2 World!');
|
stream.end('Hello, HTTP2 World!');
|
||||||
});
|
});
|
||||||
server.on('listening', function () {
|
server.on('listening', function () {
|
||||||
console.log("Listening for http2 requests on", this.address());
|
console.log("Listening for http2 requests on", this.address());
|
||||||
});
|
});
|
||||||
server.listen(443);
|
server.listen(443);
|
@ -9,7 +9,9 @@ app.use('/', function (req, res) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// DO NOT DO app.listen() unless we're testing this directly
|
// DO NOT DO app.listen() unless we're testing this directly
|
||||||
if (require.main === module) { app.listen(3000); }
|
if (require.main === module) {
|
||||||
|
app.listen(3000);
|
||||||
|
}
|
||||||
|
|
||||||
// Instead do export the app:
|
// Instead do export the app:
|
||||||
module.exports = app;
|
module.exports = app;
|
@ -9,26 +9,30 @@ var greenlock = require('../').create({
|
|||||||
// Let's Encrypt v2 is ACME draft 11
|
// Let's Encrypt v2 is ACME draft 11
|
||||||
// Note: If at first you don't succeed, stop and switch to staging
|
// Note: If at first you don't succeed, stop and switch to staging
|
||||||
// https://acme-staging-v02.api.letsencrypt.org/directory
|
// https://acme-staging-v02.api.letsencrypt.org/directory
|
||||||
server: 'https://acme-v02.api.letsencrypt.org/directory'
|
server: 'https://acme-v02.api.letsencrypt.org/directory',
|
||||||
, version: 'draft-11'
|
version: 'draft-11'
|
||||||
// You MUST have write access to save certs
|
// You MUST have write access to save certs
|
||||||
, configDir: '~/.config/acme/'
|
,
|
||||||
|
configDir: '~/.config/acme/'
|
||||||
|
|
||||||
// The previous 'simple' example set these values statically,
|
// The previous 'simple' example set these values statically,
|
||||||
// but this example uses approveDomains() to set them dynamically
|
// but this example uses approveDomains() to set them dynamically
|
||||||
//, email: 'none@see.note.above'
|
//, email: 'none@see.note.above'
|
||||||
//, agreeTos: false
|
//, agreeTos: false
|
||||||
|
|
||||||
// approveDomains is the right place to check a database for
|
// approveDomains is the right place to check a database for
|
||||||
// email addresses with domains and agreements and such
|
// email addresses with domains and agreements and such
|
||||||
, approveDomains: approveDomains
|
,
|
||||||
|
approveDomains: approveDomains
|
||||||
|
|
||||||
, app: require('./my-express-app.js')
|
,
|
||||||
|
app: require('./my-express-app.js')
|
||||||
|
|
||||||
// Get notified of important updates and help me make greenlock better
|
// Get notified of important updates and help me make greenlock better
|
||||||
, communityMember: true
|
,
|
||||||
|
communityMember: true
|
||||||
|
|
||||||
//, debug: true
|
//, debug: true
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -52,7 +56,10 @@ function approveDomains(opts, certs, cb) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fooCheckDb(opts.domains, function (err, agree, email) {
|
fooCheckDb(opts.domains, function (err, agree, email) {
|
||||||
if (err) { cb(err); return; }
|
if (err) {
|
||||||
|
cb(err);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Services SHOULD automatically accept the ToS and use YOUR email
|
// Services SHOULD automatically accept the ToS and use YOUR email
|
||||||
// Clients MUST NOT accept the ToS without asking the user
|
// Clients MUST NOT accept the ToS without asking the user
|
||||||
@ -64,7 +71,10 @@ function approveDomains(opts, certs, cb) {
|
|||||||
// opts.challengeType = 'http-01';
|
// opts.challengeType = 'http-01';
|
||||||
// opts.challenge = require('le-challenge-fs').create({});
|
// opts.challenge = require('le-challenge-fs').create({});
|
||||||
|
|
||||||
cb(null, { options: opts, certs: certs });
|
cb(null, {
|
||||||
|
options: opts,
|
||||||
|
certs: certs
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -75,7 +85,7 @@ function approveDomains(opts, certs, cb) {
|
|||||||
function fooCheckDb(domains, cb) {
|
function fooCheckDb(domains, cb) {
|
||||||
// This is an oversimplified example of how we might implement a check in
|
// This is an oversimplified example of how we might implement a check in
|
||||||
// our database if we have different rules for different users and domains
|
// our database if we have different rules for different users and domains
|
||||||
var domains = [ 'example.com', 'www.example.com' ];
|
var domains = ['example.com', 'www.example.com'];
|
||||||
var userEmail = 'john.doe@example.com';
|
var userEmail = 'john.doe@example.com';
|
||||||
var userAgrees = true;
|
var userAgrees = true;
|
||||||
var passCheck = opts.domains.every(function (domain) {
|
var passCheck = opts.domains.every(function (domain) {
|
||||||
@ -87,4 +97,4 @@ function fooCheckDb(domains, cb) {
|
|||||||
} else {
|
} else {
|
||||||
cb(null, userAgrees, userEmail);
|
cb(null, userAgrees, userEmail);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -8,29 +8,36 @@ require('../greenlock.js').create({
|
|||||||
// Let's Encrypt v2 is ACME draft 11
|
// Let's Encrypt v2 is ACME draft 11
|
||||||
version: 'draft-11'
|
version: 'draft-11'
|
||||||
|
|
||||||
, server: 'https://acme-v02.api.letsencrypt.org/directory'
|
,
|
||||||
// Note: If at first you don't succeed, stop and switch to staging
|
server: 'https://acme-v02.api.letsencrypt.org/directory'
|
||||||
// https://acme-staging-v02.api.letsencrypt.org/directory
|
// Note: If at first you don't succeed, stop and switch to staging
|
||||||
|
// https://acme-staging-v02.api.letsencrypt.org/directory
|
||||||
|
|
||||||
// You MUST change this to a valid email address
|
// You MUST change this to a valid email address
|
||||||
, email: 'lukas.n912@gmail.com'
|
,
|
||||||
|
email: 'lukas.n912@gmail.com'
|
||||||
|
|
||||||
// You MUST NOT build clients that accept the ToS without asking the user
|
// You MUST NOT build clients that accept the ToS without asking the user
|
||||||
, agreeTos: true
|
,
|
||||||
|
agreeTos: true
|
||||||
|
|
||||||
// You MUST change these to valid domains
|
// You MUST change these to valid domains
|
||||||
// NOTE: all domains will validated and listed on the certificate
|
// NOTE: all domains will validated and listed on the certificate
|
||||||
, approvedDomains: [ 'www.smartshopper.cf', 'smartshopper.cf']
|
,
|
||||||
|
approvedDomains: ['www.smartshopper.cf', 'smartshopper.cf']
|
||||||
|
|
||||||
// You MUST have access to write to directory where certs are saved
|
// You MUST have access to write to directory where certs are saved
|
||||||
// ex: /home/foouser/acme/etc
|
// ex: /home/foouser/acme/etc
|
||||||
, configDir: '~/.config/acme/'
|
,
|
||||||
|
configDir: '~/.config/acme/'
|
||||||
|
|
||||||
, app: app
|
,
|
||||||
|
app: app
|
||||||
|
|
||||||
// Get notified of important updates and help me make greenlock better
|
// Get notified of important updates and help me make greenlock better
|
||||||
, communityMember: true
|
,
|
||||||
|
communityMember: true
|
||||||
|
|
||||||
//, debug: true
|
//, debug: true
|
||||||
|
|
||||||
}).listen(7000, 443);
|
}).listen(7000, 443);
|
@ -10,7 +10,7 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
var email = 'john.doe@gmail.com';
|
var email = 'john.doe@gmail.com';
|
||||||
var domains = [ 'example.com' ];
|
var domains = ['example.com'];
|
||||||
var agreeLeTos = true;
|
var agreeLeTos = true;
|
||||||
//var secret = "My Little Brony";
|
//var secret = "My Little Brony";
|
||||||
var secret = require('crypto').randomBytes(16).toString('hex');
|
var secret = require('crypto').randomBytes(16).toString('hex');
|
||||||
@ -18,18 +18,21 @@ var secret = require('crypto').randomBytes(16).toString('hex');
|
|||||||
require('../').create({
|
require('../').create({
|
||||||
version: 'draft-11'
|
version: 'draft-11'
|
||||||
|
|
||||||
, server: 'https://acme-v02.api.letsencrypt.org/directory'
|
,
|
||||||
// Note: If at first you don't succeed, stop and switch to staging
|
server: 'https://acme-v02.api.letsencrypt.org/directory'
|
||||||
// https://acme-staging-v02.api.letsencrypt.org/directory
|
// Note: If at first you don't succeed, stop and switch to staging
|
||||||
|
// https://acme-staging-v02.api.letsencrypt.org/directory
|
||||||
|
|
||||||
, email: email
|
,
|
||||||
, agreeTos: agreeLeTos
|
email: email,
|
||||||
, approveDomains: domains
|
agreeTos: agreeLeTos,
|
||||||
, configDir: '~/.config/acme/'
|
approveDomains: domains,
|
||||||
, app: remoteAccess(secret)
|
configDir: '~/.config/acme/',
|
||||||
// Get notified of important updates and help me make greenlock better
|
app: remoteAccess(secret)
|
||||||
, communityMember: true
|
// Get notified of important updates and help me make greenlock better
|
||||||
//, debug: true
|
,
|
||||||
|
communityMember: true
|
||||||
|
//, debug: true
|
||||||
}).listen(3000, 8443);
|
}).listen(3000, 8443);
|
||||||
|
|
||||||
|
|
||||||
@ -38,20 +41,39 @@ function remoteAccess(secret) {
|
|||||||
var basicAuth = require('express-basic-auth');
|
var basicAuth = require('express-basic-auth');
|
||||||
var serveIndex = require('serve-index');
|
var serveIndex = require('serve-index');
|
||||||
|
|
||||||
var rootIndex = serveIndex('/', { hidden: true, icons: true, view: 'details' });
|
var rootIndex = serveIndex('/', {
|
||||||
var rootFs = express.static('/', { dotfiles: 'allow', redirect: true, index: false });
|
hidden: true,
|
||||||
|
icons: true,
|
||||||
|
view: 'details'
|
||||||
|
});
|
||||||
|
var rootFs = express.static('/', {
|
||||||
|
dotfiles: 'allow',
|
||||||
|
redirect: true,
|
||||||
|
index: false
|
||||||
|
});
|
||||||
|
|
||||||
var userIndex = serveIndex(require('os').homedir(), { hidden: true, icons: true, view: 'details' });
|
var userIndex = serveIndex(require('os').homedir(), {
|
||||||
var userFs = express.static(require('os').homedir(), { dotfiles: 'allow', redirect: true, index: false });
|
hidden: true,
|
||||||
|
icons: true,
|
||||||
|
view: 'details'
|
||||||
|
});
|
||||||
|
var userFs = express.static(require('os').homedir(), {
|
||||||
|
dotfiles: 'allow',
|
||||||
|
redirect: true,
|
||||||
|
index: false
|
||||||
|
});
|
||||||
|
|
||||||
var app = express();
|
var app = express();
|
||||||
var realm = 'Login Required';
|
var realm = 'Login Required';
|
||||||
|
|
||||||
var myAuth = basicAuth({
|
var myAuth = basicAuth({
|
||||||
users: { 'root': secret, 'user': secret }
|
users: {
|
||||||
, challenge: true
|
'root': secret,
|
||||||
, realm: realm
|
'user': secret
|
||||||
, unauthorizedResponse: function (/*req*/) {
|
},
|
||||||
|
challenge: true,
|
||||||
|
realm: realm,
|
||||||
|
unauthorizedResponse: function ( /*req*/ ) {
|
||||||
return 'Unauthorized <a href="/">Home</a>';
|
return 'Unauthorized <a href="/">Home</a>';
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -59,9 +81,9 @@ function remoteAccess(secret) {
|
|||||||
app.get('/', function (req, res) {
|
app.get('/', function (req, res) {
|
||||||
res.setHeader('Content-Type', 'text/html; charset=utf-8');
|
res.setHeader('Content-Type', 'text/html; charset=utf-8');
|
||||||
res.end(
|
res.end(
|
||||||
'<a href="/browse/">View Files</a>'
|
'<a href="/browse/">View Files</a>' +
|
||||||
+ ' | '
|
' | ' +
|
||||||
+ '<a href="/logout/">Logout</a>'
|
'<a href="/logout/">Logout</a>'
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
app.use('/logout', function (req, res) {
|
app.use('/logout', function (req, res) {
|
||||||
@ -73,8 +95,18 @@ function remoteAccess(secret) {
|
|||||||
});
|
});
|
||||||
app.use('/browse', myAuth);
|
app.use('/browse', myAuth);
|
||||||
app.use('/browse', function (req, res, next) {
|
app.use('/browse', function (req, res, next) {
|
||||||
if ('root' === req.auth.user) { rootFs(req, res, function () { rootIndex(req, res, next); }); return; }
|
if ('root' === req.auth.user) {
|
||||||
if ('user' === req.auth.user) { userFs(req, res, function () { userIndex(req, res, next); }); return; }
|
rootFs(req, res, function () {
|
||||||
|
rootIndex(req, res, next);
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if ('user' === req.auth.user) {
|
||||||
|
userFs(req, res, function () {
|
||||||
|
userIndex(req, res, next);
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
res.end('Sad Panda');
|
res.end('Sad Panda');
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -92,4 +124,4 @@ function remoteAccess(secret) {
|
|||||||
console.log('');
|
console.log('');
|
||||||
|
|
||||||
return app;
|
return app;
|
||||||
}
|
}
|
@ -10,28 +10,34 @@ var greenlock = Greenlock.create({
|
|||||||
// Let's Encrypt v2 is ACME draft 11
|
// Let's Encrypt v2 is ACME draft 11
|
||||||
version: 'draft-11'
|
version: 'draft-11'
|
||||||
|
|
||||||
, server: 'https://acme-v02.api.letsencrypt.org/directory'
|
,
|
||||||
// Note: If at first you don't succeed, stop and switch to staging
|
server: 'https://acme-v02.api.letsencrypt.org/directory'
|
||||||
// https://acme-staging-v02.api.letsencrypt.org/directory
|
// Note: If at first you don't succeed, stop and switch to staging
|
||||||
|
// https://acme-staging-v02.api.letsencrypt.org/directory
|
||||||
|
|
||||||
// You MUST change this to a valid email address
|
// You MUST change this to a valid email address
|
||||||
, email: 'jon@example.com'
|
,
|
||||||
|
email: 'jon@example.com'
|
||||||
|
|
||||||
// You MUST NOT build clients that accept the ToS without asking the user
|
// You MUST NOT build clients that accept the ToS without asking the user
|
||||||
, agreeTos: true
|
,
|
||||||
|
agreeTos: true
|
||||||
|
|
||||||
// You MUST change these to valid domains
|
// You MUST change these to valid domains
|
||||||
// NOTE: all domains will validated and listed on the certificate
|
// NOTE: all domains will validated and listed on the certificate
|
||||||
, approvedDomains: [ 'example.com', 'www.example.com' ]
|
,
|
||||||
|
approvedDomains: ['example.com', 'www.example.com']
|
||||||
|
|
||||||
// You MUST have access to write to directory where certs are saved
|
// You MUST have access to write to directory where certs are saved
|
||||||
// ex: /home/foouser/acme/etc
|
// ex: /home/foouser/acme/etc
|
||||||
, configDir: '~/.config/acme/' // MUST have write access
|
,
|
||||||
|
configDir: '~/.config/acme/' // MUST have write access
|
||||||
|
|
||||||
// Get notified of important updates and help me make greenlock better
|
// Get notified of important updates and help me make greenlock better
|
||||||
, communityMember: true
|
,
|
||||||
|
communityMember: true
|
||||||
|
|
||||||
//, debug: true
|
//, debug: true
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -56,7 +62,10 @@ require('http').createServer(acmeChallengeHandler).listen(80, function () {
|
|||||||
|
|
||||||
// spdy is a drop-in replacement for the https API
|
// spdy is a drop-in replacement for the https API
|
||||||
var spdyOptions = Object.assign({}, greenlock.tlsOptions);
|
var spdyOptions = Object.assign({}, greenlock.tlsOptions);
|
||||||
spdyOptions.spdy = { protocols: [ 'h2', 'http/1.1' ], plain: false };
|
spdyOptions.spdy = {
|
||||||
|
protocols: ['h2', 'http/1.1'],
|
||||||
|
plain: false
|
||||||
|
};
|
||||||
var myApp = require('./my-express-app.js');
|
var myApp = require('./my-express-app.js');
|
||||||
var server = require('spdy').createServer(spdyOptions, myApp);
|
var server = require('spdy').createServer(spdyOptions, myApp);
|
||||||
server.on('error', function (err) {
|
server.on('error', function (err) {
|
||||||
@ -65,4 +74,4 @@ server.on('error', function (err) {
|
|||||||
server.on('listening', function () {
|
server.on('listening', function () {
|
||||||
console.log("Listening for SPDY/http2/https requests on", this.address());
|
console.log("Listening for SPDY/http2/https requests on", this.address());
|
||||||
});
|
});
|
||||||
server.listen(443);
|
server.listen(443);
|
@ -1,4 +1,5 @@
|
|||||||
#!/usr/bin/env node
|
#!/usr/bin/env node
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
///////////////////
|
///////////////////
|
||||||
@ -21,25 +22,32 @@ var serveStatic = require('serve-static');
|
|||||||
//var glx = require('greenlock-express')
|
//var glx = require('greenlock-express')
|
||||||
var glx = require('../').create({
|
var glx = require('../').create({
|
||||||
|
|
||||||
version: 'draft-11' // Let's Encrypt v2 is ACME draft 11
|
version: 'draft-11' // Let's Encrypt v2 is ACME draft 11
|
||||||
|
|
||||||
, server: 'https://acme-v02.api.letsencrypt.org/directory' // If at first you don't succeed, stop and switch to staging
|
,
|
||||||
// https://acme-staging-v02.api.letsencrypt.org/directory
|
server: 'https://acme-v02.api.letsencrypt.org/directory' // If at first you don't succeed, stop and switch to staging
|
||||||
|
// https://acme-staging-v02.api.letsencrypt.org/directory
|
||||||
|
|
||||||
, configDir: '~/.config/acme/' // You MUST have access to write to directory where certs
|
,
|
||||||
// are saved. ex: /home/foouser/.config/acme
|
configDir: '~/.config/acme/' // You MUST have access to write to directory where certs
|
||||||
|
// are saved. ex: /home/foouser/.config/acme
|
||||||
|
|
||||||
, approveDomains: myApproveDomains // Greenlock's wraps around tls.SNICallback. Check the
|
,
|
||||||
// domain name here and reject invalid ones
|
approveDomains: myApproveDomains // Greenlock's wraps around tls.SNICallback. Check the
|
||||||
|
// domain name here and reject invalid ones
|
||||||
|
|
||||||
, app: myVhostApp // Any node-style http app (i.e. express, koa, hapi, rill)
|
,
|
||||||
|
app: myVhostApp // Any node-style http app (i.e. express, koa, hapi, rill)
|
||||||
|
|
||||||
/* CHANGE TO A VALID EMAIL */
|
/* CHANGE TO A VALID EMAIL */
|
||||||
, email:'jon@example.com' // Email for Let's Encrypt account and Greenlock Security
|
,
|
||||||
, agreeTos: true // Accept Let's Encrypt ToS
|
email: 'jon@example.com' // Email for Let's Encrypt account and Greenlock Security
|
||||||
, communityMember: true // Join Greenlock to get important updates, no spam
|
,
|
||||||
|
agreeTos: true // Accept Let's Encrypt ToS
|
||||||
|
,
|
||||||
|
communityMember: true // Join Greenlock to get important updates, no spam
|
||||||
|
|
||||||
//, debug: true
|
//, debug: true
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -84,7 +92,10 @@ function myApproveDomains(opts, certs, cb) {
|
|||||||
// opts.agreeTos = true;
|
// opts.agreeTos = true;
|
||||||
// opts.challengeType = 'http-01';
|
// opts.challengeType = 'http-01';
|
||||||
// opts.challenge = require('le-challenge-fs').create({});
|
// opts.challenge = require('le-challenge-fs').create({});
|
||||||
cb(null, { options: opts, certs: certs });
|
cb(null, {
|
||||||
|
options: opts,
|
||||||
|
certs: certs
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -96,6 +107,7 @@ function myApproveDomains(opts, certs, cb) {
|
|||||||
// It will also make them lowercase and protect against "domain fronting".
|
// It will also make them lowercase and protect against "domain fronting".
|
||||||
// However, it's up to you to make sure you actually have a domain to serve :)
|
// However, it's up to you to make sure you actually have a domain to serve :)
|
||||||
var servers = {};
|
var servers = {};
|
||||||
|
|
||||||
function myVhostApp(req, res) {
|
function myVhostApp(req, res) {
|
||||||
var hostname = req.headers.host;
|
var hostname = req.headers.host;
|
||||||
var srvpath = path.join(srv, hostname);
|
var srvpath = path.join(srv, hostname);
|
||||||
@ -104,11 +116,13 @@ function myVhostApp(req, res) {
|
|||||||
if (!servers[hostname]) {
|
if (!servers[hostname]) {
|
||||||
try {
|
try {
|
||||||
fs.accessSync(srvpath);
|
fs.accessSync(srvpath);
|
||||||
servers[hostname] = serveStatic(srvpath, { redirect: true });
|
servers[hostname] = serveStatic(srvpath, {
|
||||||
} catch(e) {
|
redirect: true
|
||||||
|
});
|
||||||
|
} catch (e) {
|
||||||
finalhandler(req, res);
|
finalhandler(req, res);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
servers[hostname](req, res, finalhandler(req, res));
|
servers[hostname](req, res, finalhandler(req, res));
|
||||||
}
|
}
|
@ -12,29 +12,35 @@ var greenlock = Greenlock.create({
|
|||||||
// Let's Encrypt v2 is ACME draft 11
|
// Let's Encrypt v2 is ACME draft 11
|
||||||
// Note: If at first you don't succeed, stop and switch to staging
|
// Note: If at first you don't succeed, stop and switch to staging
|
||||||
// https://acme-staging-v02.api.letsencrypt.org/directory
|
// https://acme-staging-v02.api.letsencrypt.org/directory
|
||||||
server: 'https://acme-v02.api.letsencrypt.org/directory'
|
server: 'https://acme-v02.api.letsencrypt.org/directory',
|
||||||
, version: 'draft-11'
|
version: 'draft-11',
|
||||||
, configDir: '~/.config/acme/'
|
configDir: '~/.config/acme/',
|
||||||
, app: require('./my-express-app.js')
|
app: require('./my-express-app.js')
|
||||||
|
|
||||||
// You MUST change these to a valid email and domains
|
// You MUST change these to a valid email and domains
|
||||||
, email: 'john.doe@example.com'
|
,
|
||||||
, approvedDomains: [ 'example.com', 'www.example.com' ]
|
email: 'john.doe@example.com',
|
||||||
, agreeTos: true
|
approvedDomains: ['example.com', 'www.example.com'],
|
||||||
|
agreeTos: true
|
||||||
|
|
||||||
// Get notified of important updates and help me make greenlock better
|
// Get notified of important updates and help me make greenlock better
|
||||||
, communityMember: true
|
,
|
||||||
, telemetry: true
|
communityMember: true,
|
||||||
//, debug: true
|
telemetry: true
|
||||||
|
//, debug: true
|
||||||
});
|
});
|
||||||
|
|
||||||
var server = greenlock.listen(80, 443);
|
var server = greenlock.listen(80, 443);
|
||||||
|
|
||||||
var WebSocket = require('ws');
|
var WebSocket = require('ws');
|
||||||
var ws = new WebSocket.Server({ server: server });
|
var ws = new WebSocket.Server({
|
||||||
|
server: server
|
||||||
|
});
|
||||||
ws.on('connection', function (ws, req) {
|
ws.on('connection', function (ws, req) {
|
||||||
// inspect req.headers.authorization (or cookies) for session info
|
// inspect req.headers.authorization (or cookies) for session info
|
||||||
ws.send("[Secure Echo Server] Hello!\nAuth: '" + (req.headers.authorization || 'none') + "'\n"
|
ws.send("[Secure Echo Server] Hello!\nAuth: '" + (req.headers.authorization || 'none') + "'\n" +
|
||||||
+ "Cookie: '" + (req.headers.cookie || 'none') + "'\n");
|
"Cookie: '" + (req.headers.cookie || 'none') + "'\n");
|
||||||
ws.on('message', function (data) { ws.send(data); });
|
ws.on('message', function (data) {
|
||||||
});
|
ws.send(data);
|
||||||
|
});
|
||||||
|
});
|
@ -3,7 +3,7 @@
|
|||||||
var PromiseA;
|
var PromiseA;
|
||||||
try {
|
try {
|
||||||
PromiseA = require('bluebird');
|
PromiseA = require('bluebird');
|
||||||
} catch(e) {
|
} catch (e) {
|
||||||
PromiseA = global.Promise;
|
PromiseA = global.Promise;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -31,7 +31,9 @@ module.exports.create = function (opts) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function _listen(plainPort, plain) {
|
function _listen(plainPort, plain) {
|
||||||
if (!plainPort) { plainPort = 80; }
|
if (!plainPort) {
|
||||||
|
plainPort = 80;
|
||||||
|
}
|
||||||
|
|
||||||
var parts = String(plainPort).split(':');
|
var parts = String(plainPort).split(':');
|
||||||
var p = parts.pop();
|
var p = parts.pop();
|
||||||
@ -52,24 +54,26 @@ module.exports.create = function (opts) {
|
|||||||
var https;
|
var https;
|
||||||
try {
|
try {
|
||||||
https = require('spdy');
|
https = require('spdy');
|
||||||
greenlock.tlsOptions.spdy = { protocols: [ 'h2', 'http/1.1' ], plain: false };
|
greenlock.tlsOptions.spdy = {
|
||||||
|
protocols: ['h2', 'http/1.1'],
|
||||||
|
plain: false
|
||||||
|
};
|
||||||
httpType = 'http2 (spdy/h2)';
|
httpType = 'http2 (spdy/h2)';
|
||||||
} catch(e) {
|
} catch (e) {
|
||||||
https = require('https');
|
https = require('https');
|
||||||
httpType = 'https';
|
httpType = 'https';
|
||||||
}
|
}
|
||||||
server = https.createServer(
|
server = https.createServer(
|
||||||
greenlock.tlsOptions
|
greenlock.tlsOptions, greenlock.middleware.sanitizeHost(function (req, res) {
|
||||||
, greenlock.middleware.sanitizeHost(function (req, res) {
|
|
||||||
try {
|
try {
|
||||||
greenlock.app(req, res);
|
greenlock.app(req, res);
|
||||||
} catch(e) {
|
} catch (e) {
|
||||||
console.error("[error] [greenlock.app] Your HTTP handler had an uncaught error:");
|
console.error("[error] [greenlock.app] Your HTTP handler had an uncaught error:");
|
||||||
console.error(e);
|
console.error(e);
|
||||||
try {
|
try {
|
||||||
res.statusCode = 500;
|
res.statusCode = 500;
|
||||||
res.end("Internal Server Error: [Greenlock] HTTP exception logged for user-provided handler.");
|
res.end("Internal Server Error: [Greenlock] HTTP exception logged for user-provided handler.");
|
||||||
} catch(e) {
|
} catch (e) {
|
||||||
// ignore
|
// ignore
|
||||||
// (headers may have already been sent, etc)
|
// (headers may have already been sent, etc)
|
||||||
}
|
}
|
||||||
@ -79,15 +83,23 @@ module.exports.create = function (opts) {
|
|||||||
server.type = httpType;
|
server.type = httpType;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (addr) { args[1] = addr; }
|
if (addr) {
|
||||||
|
args[1] = addr;
|
||||||
|
}
|
||||||
if (!validHttpPort && !/(\/)|(\\\\)/.test(p)) {
|
if (!validHttpPort && !/(\/)|(\\\\)/.test(p)) {
|
||||||
console.warn("'" + p + "' doesn't seem to be a valid port number, socket path, or pipe");
|
console.warn("'" + p + "' doesn't seem to be a valid port number, socket path, or pipe");
|
||||||
}
|
}
|
||||||
if (plain) { tryPlain(); } else { trySecure(); }
|
if (plain) {
|
||||||
|
tryPlain();
|
||||||
|
} else {
|
||||||
|
trySecure();
|
||||||
|
}
|
||||||
|
|
||||||
var promise = new PromiseA(function (resolve) {
|
var promise = new PromiseA(function (resolve) {
|
||||||
args[0] = p;
|
args[0] = p;
|
||||||
args.push(function () { resolve(server); });
|
args.push(function () {
|
||||||
|
resolve(server);
|
||||||
|
});
|
||||||
server.listen.apply(server, args).on('error', function (e) {
|
server.listen.apply(server, args).on('error', function (e) {
|
||||||
if (server.listenerCount('error') < 2) {
|
if (server.listenerCount('error') < 2) {
|
||||||
console.warn("Did not successfully create http server and bind to port '" + p + "':");
|
console.warn("Did not successfully create http server and bind to port '" + p + "':");
|
||||||
@ -133,8 +145,8 @@ module.exports.create = function (opts) {
|
|||||||
if ('function' === typeof fnPlain) {
|
if ('function' === typeof fnPlain) {
|
||||||
fnPlain.apply(plainServer);
|
fnPlain.apply(plainServer);
|
||||||
} else if (!fn && !plainServer.listenerCount('listening') && !server.listenerCount('listening')) {
|
} else if (!fn && !plainServer.listenerCount('listening') && !server.listenerCount('listening')) {
|
||||||
console.info('[:' + (plainServer.address().port || plainServer.address())
|
console.info('[:' + (plainServer.address().port || plainServer.address()) +
|
||||||
+ "] Handling ACME challenges and redirecting to " + server.type);
|
"] Handling ACME challenges and redirecting to " + server.type);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Report h2/https status
|
// Report h2/https status
|
||||||
@ -156,4 +168,4 @@ module.exports.create = function (opts) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
return greenlock;
|
return greenlock;
|
||||||
};
|
};
|
@ -3,7 +3,7 @@
|
|||||||
var PromiseA;
|
var PromiseA;
|
||||||
try {
|
try {
|
||||||
PromiseA = require('bluebird');
|
PromiseA = require('bluebird');
|
||||||
} catch(e) {
|
} catch (e) {
|
||||||
PromiseA = global.Promise;
|
PromiseA = global.Promise;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -31,7 +31,9 @@ module.exports.create = function (opts) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function _listen(plainPort, plain) {
|
function _listen(plainPort, plain) {
|
||||||
if (!plainPort) { plainPort = 80; }
|
if (!plainPort) {
|
||||||
|
plainPort = 80;
|
||||||
|
}
|
||||||
|
|
||||||
var parts = String(plainPort).split(':');
|
var parts = String(plainPort).split(':');
|
||||||
var p = parts.pop();
|
var p = parts.pop();
|
||||||
@ -52,24 +54,26 @@ module.exports.create = function (opts) {
|
|||||||
var https;
|
var https;
|
||||||
try {
|
try {
|
||||||
https = require('spdy');
|
https = require('spdy');
|
||||||
greenlock.tlsOptions.spdy = { protocols: [ 'h2', 'http/1.1' ], plain: false };
|
greenlock.tlsOptions.spdy = {
|
||||||
|
protocols: ['h2', 'http/1.1'],
|
||||||
|
plain: false
|
||||||
|
};
|
||||||
httpType = 'http2 (spdy/h2)';
|
httpType = 'http2 (spdy/h2)';
|
||||||
} catch(e) {
|
} catch (e) {
|
||||||
https = require('https');
|
https = require('https');
|
||||||
httpType = 'https';
|
httpType = 'https';
|
||||||
}
|
}
|
||||||
server = https.createServer(
|
server = https.createServer(
|
||||||
greenlock.tlsOptions
|
greenlock.tlsOptions, greenlock.middleware.sanitizeHost(function (req, res) {
|
||||||
, greenlock.middleware.sanitizeHost(function (req, res) {
|
|
||||||
try {
|
try {
|
||||||
greenlock.app(req, res);
|
greenlock.app(req, res);
|
||||||
} catch(e) {
|
} catch (e) {
|
||||||
console.error("[error] [greenlock.app] Your HTTP handler had an uncaught error:");
|
console.error("[error] [greenlock.app] Your HTTP handler had an uncaught error:");
|
||||||
console.error(e);
|
console.error(e);
|
||||||
try {
|
try {
|
||||||
res.statusCode = 500;
|
res.statusCode = 500;
|
||||||
res.end("Internal Server Error: [Greenlock] HTTP exception logged for user-provided handler.");
|
res.end("Internal Server Error: [Greenlock] HTTP exception logged for user-provided handler.");
|
||||||
} catch(e) {
|
} catch (e) {
|
||||||
// ignore
|
// ignore
|
||||||
// (headers may have already been sent, etc)
|
// (headers may have already been sent, etc)
|
||||||
}
|
}
|
||||||
@ -79,15 +83,23 @@ module.exports.create = function (opts) {
|
|||||||
server.type = httpType;
|
server.type = httpType;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (addr) { args[1] = addr; }
|
if (addr) {
|
||||||
|
args[1] = addr;
|
||||||
|
}
|
||||||
if (!validHttpPort && !/(\/)|(\\\\)/.test(p)) {
|
if (!validHttpPort && !/(\/)|(\\\\)/.test(p)) {
|
||||||
console.warn("'" + p + "' doesn't seem to be a valid port number, socket path, or pipe");
|
console.warn("'" + p + "' doesn't seem to be a valid port number, socket path, or pipe");
|
||||||
}
|
}
|
||||||
if (plain) { tryPlain(); } else { trySecure(); }
|
if (plain) {
|
||||||
|
tryPlain();
|
||||||
|
} else {
|
||||||
|
trySecure();
|
||||||
|
}
|
||||||
|
|
||||||
var promise = new PromiseA(function (resolve) {
|
var promise = new PromiseA(function (resolve) {
|
||||||
args[0] = p;
|
args[0] = p;
|
||||||
args.push(function () { resolve(server); });
|
args.push(function () {
|
||||||
|
resolve(server);
|
||||||
|
});
|
||||||
server.listen.apply(server, args).on('error', function (e) {
|
server.listen.apply(server, args).on('error', function (e) {
|
||||||
if (server.listenerCount('error') < 2) {
|
if (server.listenerCount('error') < 2) {
|
||||||
console.warn("Did not successfully create http server and bind to port '" + p + "':");
|
console.warn("Did not successfully create http server and bind to port '" + p + "':");
|
||||||
@ -133,8 +145,8 @@ module.exports.create = function (opts) {
|
|||||||
if ('function' === typeof fnPlain) {
|
if ('function' === typeof fnPlain) {
|
||||||
fnPlain.apply(plainServer);
|
fnPlain.apply(plainServer);
|
||||||
} else if (!fn && !plainServer.listenerCount('listening') && !server.listenerCount('listening')) {
|
} else if (!fn && !plainServer.listenerCount('listening') && !server.listenerCount('listening')) {
|
||||||
console.info('[:' + (plainServer.address().port || plainServer.address())
|
console.info('[:' + (plainServer.address().port || plainServer.address()) +
|
||||||
+ "] Handling ACME challenges and redirecting to " + server.type);
|
"] Handling ACME challenges and redirecting to " + server.type);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Report h2/https status
|
// Report h2/https status
|
||||||
@ -156,4 +168,4 @@ module.exports.create = function (opts) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
return greenlock;
|
return greenlock;
|
||||||
};
|
};
|
@ -9,4 +9,4 @@
|
|||||||
"token_uri": "https://oauth2.googleapis.com/token",
|
"token_uri": "https://oauth2.googleapis.com/token",
|
||||||
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
|
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
|
||||||
"client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/firebase-adminsdk-61077%40test-667ca.iam.gserviceaccount.com"
|
"client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/firebase-adminsdk-61077%40test-667ca.iam.gserviceaccount.com"
|
||||||
}
|
}
|
@ -23,5 +23,7 @@ messaging.setBackgroundMessageHandler(payload => {
|
|||||||
// }
|
// }
|
||||||
// return self.registration.showNotification(title, options)
|
// return self.registration.showNotification(title, options)
|
||||||
const title = payload.data.title
|
const title = payload.data.title
|
||||||
new Notification(title, { body: payload.data.text});
|
new Notification(title, {
|
||||||
|
body: payload.data.text
|
||||||
|
});
|
||||||
})
|
})
|
@ -1,81 +1,98 @@
|
|||||||
$(document).ready(function() {
|
$(document).ready(function () {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Initialize Firebase
|
// Initialize Firebase
|
||||||
var config = {
|
var config = {
|
||||||
apiKey: "AIzaSyCuvwf78cmSDoZ2yS4XxHZhnjUn7yIHYfw",
|
apiKey: "AIzaSyCuvwf78cmSDoZ2yS4XxHZhnjUn7yIHYfw",
|
||||||
authDomain: "test-667ca.firebaseapp.com",
|
authDomain: "test-667ca.firebaseapp.com",
|
||||||
databaseURL: "https://test-667ca.firebaseio.com",
|
databaseURL: "https://test-667ca.firebaseio.com",
|
||||||
projectId: "test-667ca",
|
projectId: "test-667ca",
|
||||||
storageBucket: "test-667ca.appspot.com",
|
storageBucket: "test-667ca.appspot.com",
|
||||||
messagingSenderId: "221332577314"
|
messagingSenderId: "221332577314"
|
||||||
};
|
};
|
||||||
|
|
||||||
firebase.initializeApp(config);
|
firebase.initializeApp(config);
|
||||||
|
|
||||||
|
|
||||||
var segment_str = window.location.pathname;
|
var segment_str = window.location.pathname;
|
||||||
var segment_array = segment_str.split( '/' );
|
var segment_array = segment_str.split('/');
|
||||||
var last_segment = segment_array.pop();
|
|
||||||
|
|
||||||
//verifyInvite(last_segment);
|
|
||||||
getList(last_segment);
|
|
||||||
verifyInvite(last_segment);
|
|
||||||
|
|
||||||
|
|
||||||
function verifyInvite(link) {
|
|
||||||
//alert("Ore Link", link)
|
|
||||||
firebase.auth().onAuthStateChanged(function(user){if(user){firebase.auth().currentUser.getIdToken(/* forceRefresh */ true).then(function(idtoken) {
|
|
||||||
$.ajax({
|
|
||||||
type: "POST",
|
|
||||||
url: "/invitemember",
|
|
||||||
data: {
|
|
||||||
idtoken: idtoken,
|
|
||||||
link: link
|
|
||||||
},
|
|
||||||
success(){
|
|
||||||
window.location.href = "/dash/" + idtoken
|
|
||||||
//alert("Success");
|
|
||||||
},
|
|
||||||
error(err){
|
|
||||||
console.error("Error: " + err);
|
|
||||||
//alert("Error");
|
|
||||||
window.location.href = "/dash/" + idtoken
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}).catch((error) => console.error("Get id token client error: ", error));}else{console.log("Check Auth error", user)}});
|
|
||||||
}
|
|
||||||
|
|
||||||
function getList(link) {
|
|
||||||
firebase.auth().onAuthStateChanged(function(user){if(user){firebase.auth().currentUser.getIdToken(/* forceRefresh */ true).then(function(idtoken) {
|
|
||||||
$.ajax({
|
|
||||||
type: "GET",
|
|
||||||
url: "/shoppinglistsbylink?link=" + link,
|
|
||||||
data: {
|
|
||||||
idtoken: idtoken
|
|
||||||
},
|
|
||||||
success(data){
|
|
||||||
console.log(data);
|
|
||||||
|
|
||||||
$(".s_name").append(data.find(function(obj) {return obj.invitelink == link}).name);
|
|
||||||
$(".s_desc").append(data.find(function(obj) {return obj.invitelink == link}).description);
|
|
||||||
$(".s_link").append(data.find(function(obj) {return obj.invitelink == link}).invitelink);
|
|
||||||
},
|
|
||||||
error(err){
|
|
||||||
console.error("Error: " + err);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}).catch((error) => console.error("Get id token client error: ", error));}else{console.log("Check Auth error", user)}});
|
|
||||||
}
|
|
||||||
|
|
||||||
$(".btn_verify").click(function() {
|
|
||||||
var segment_str = window.location.pathname;
|
|
||||||
var segment_array = segment_str.split( '/' );
|
|
||||||
var last_segment = segment_array.pop();
|
var last_segment = segment_array.pop();
|
||||||
|
|
||||||
|
//verifyInvite(last_segment);
|
||||||
|
getList(last_segment);
|
||||||
verifyInvite(last_segment);
|
verifyInvite(last_segment);
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
});
|
function verifyInvite(link) {
|
||||||
|
//alert("Ore Link", link)
|
||||||
|
firebase.auth().onAuthStateChanged(function (user) {
|
||||||
|
if (user) {
|
||||||
|
firebase.auth().currentUser.getIdToken( /* forceRefresh */ true).then(function (idtoken) {
|
||||||
|
$.ajax({
|
||||||
|
type: "POST",
|
||||||
|
url: "/invitemember",
|
||||||
|
data: {
|
||||||
|
idtoken: idtoken,
|
||||||
|
link: link
|
||||||
|
},
|
||||||
|
success() {
|
||||||
|
window.location.href = "/dash/" + idtoken
|
||||||
|
//alert("Success");
|
||||||
|
},
|
||||||
|
error(err) {
|
||||||
|
console.error("Error: " + err);
|
||||||
|
//alert("Error");
|
||||||
|
window.location.href = "/dash/" + idtoken
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}).catch((error) => console.error("Get id token client error: ", error));
|
||||||
|
} else {
|
||||||
|
console.log("Check Auth error", user)
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function getList(link) {
|
||||||
|
firebase.auth().onAuthStateChanged(function (user) {
|
||||||
|
if (user) {
|
||||||
|
firebase.auth().currentUser.getIdToken( /* forceRefresh */ true).then(function (idtoken) {
|
||||||
|
$.ajax({
|
||||||
|
type: "GET",
|
||||||
|
url: "/shoppinglistsbylink?link=" + link,
|
||||||
|
data: {
|
||||||
|
idtoken: idtoken
|
||||||
|
},
|
||||||
|
success(data) {
|
||||||
|
console.log(data);
|
||||||
|
|
||||||
|
$(".s_name").append(data.find(function (obj) {
|
||||||
|
return obj.invitelink == link
|
||||||
|
}).name);
|
||||||
|
$(".s_desc").append(data.find(function (obj) {
|
||||||
|
return obj.invitelink == link
|
||||||
|
}).description);
|
||||||
|
$(".s_link").append(data.find(function (obj) {
|
||||||
|
return obj.invitelink == link
|
||||||
|
}).invitelink);
|
||||||
|
},
|
||||||
|
error(err) {
|
||||||
|
console.error("Error: " + err);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}).catch((error) => console.error("Get id token client error: ", error));
|
||||||
|
} else {
|
||||||
|
console.log("Check Auth error", user)
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
$(".btn_verify").click(function () {
|
||||||
|
var segment_str = window.location.pathname;
|
||||||
|
var segment_array = segment_str.split('/');
|
||||||
|
var last_segment = segment_array.pop();
|
||||||
|
verifyInvite(last_segment);
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
});
|
@ -1,6 +1,6 @@
|
|||||||
body {
|
body {
|
||||||
background-color: #121212;
|
background-color: #121212;
|
||||||
display:none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.cont {
|
.cont {
|
||||||
|
@ -6,128 +6,144 @@ var config = {
|
|||||||
projectId: "test-667ca",
|
projectId: "test-667ca",
|
||||||
storageBucket: "test-667ca.appspot.com",
|
storageBucket: "test-667ca.appspot.com",
|
||||||
messagingSenderId: "221332577314"
|
messagingSenderId: "221332577314"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
firebase.initializeApp(config);
|
firebase.initializeApp(config);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$(document).ready(function() {
|
$(document).ready(function () {
|
||||||
firebase.auth().onAuthStateChanged(async function(user){if(user){firebase.auth().currentUser.getIdToken(/* forceRefresh */ true).then(function(idtoken) {
|
firebase.auth().onAuthStateChanged(async function (user) {
|
||||||
console.log("/shoppinglistx idtoken:", idtoken);
|
if (user) {
|
||||||
var url = "/dash/" + idtoken
|
firebase.auth().currentUser.getIdToken( /* forceRefresh */ true).then(function (idtoken) {
|
||||||
console.log("URL: ", url)
|
console.log("/shoppinglistx idtoken:", idtoken);
|
||||||
$('#dashurl').attr("href", url);
|
var url = "/dash/" + idtoken
|
||||||
|
console.log("URL: ", url)
|
||||||
|
$('#dashurl').attr("href", url);
|
||||||
|
|
||||||
|
}).catch((error) => console.error("/shoppinglist Get id token client error: ", error));
|
||||||
|
} else {
|
||||||
|
console.log("Check Auth error", user)
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
}).catch((error) => console.error("/shoppinglist Get id token client error: ", error));}else{console.log("Check Auth error", user)}});
|
|
||||||
|
|
||||||
eigeneEinkaufslisten();
|
eigeneEinkaufslisten();
|
||||||
geteilteEinkaufslisten();
|
geteilteEinkaufslisten();
|
||||||
|
|
||||||
$(".detailcardausgabe").hide();
|
$(".detailcardausgabe").hide();
|
||||||
|
|
||||||
$(".logout").click(function(){
|
$(".logout").click(function () {
|
||||||
console.log("click logout")
|
console.log("click logout")
|
||||||
firebase.auth().signOut().then(function() {
|
firebase.auth().signOut().then(function () {
|
||||||
document.location.replace('/');
|
document.location.replace('/');
|
||||||
}).catch(function(error) {
|
}).catch(function (error) {
|
||||||
console.error("Logout Error: ", error)
|
console.error("Logout Error: ", error)
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
$('.add').click(function(){
|
$('.add').click(function () {
|
||||||
console.log("click add");
|
console.log("click add");
|
||||||
// let name = $("#einkaufslistenname").val();
|
// let name = $("#einkaufslistenname").val();
|
||||||
|
|
||||||
firebase.auth().onAuthStateChanged(async function(user){if(user){firebase.auth().currentUser.getIdToken(/* forceRefresh */ true).then(function(idtoken) {
|
firebase.auth().onAuthStateChanged(async function (user) {
|
||||||
console.log("/shoppinglistx idtoken:", idtoken);
|
if (user) {
|
||||||
$.ajax({
|
firebase.auth().currentUser.getIdToken( /* forceRefresh */ true).then(function (idtoken) {
|
||||||
type: "POST",
|
console.log("/shoppinglistx idtoken:", idtoken);
|
||||||
url: "/shoppinglist",
|
$.ajax({
|
||||||
data: {
|
type: "POST",
|
||||||
name: $("#einkaufslistenname").val(),
|
url: "/shoppinglist",
|
||||||
description: $("#einkaufslistenbeschreibung").val(),
|
data: {
|
||||||
color: $( "input:checked" ).val(),
|
name: $("#einkaufslistenname").val(),
|
||||||
idtoken: idtoken
|
description: $("#einkaufslistenbeschreibung").val(),
|
||||||
},
|
color: $("input:checked").val(),
|
||||||
success(res){
|
idtoken: idtoken
|
||||||
console.log("add funktioniert");
|
},
|
||||||
$(".listen-ausgabe").html("");
|
success(res) {
|
||||||
eigeneEinkaufslisten();
|
console.log("add funktioniert");
|
||||||
geteilteEinkaufslisten();
|
$(".listen-ausgabe").html("");
|
||||||
$("#EigeneListeAdd").modal("hide");
|
eigeneEinkaufslisten();
|
||||||
},
|
geteilteEinkaufslisten();
|
||||||
error(err){
|
$("#EigeneListeAdd").modal("hide");
|
||||||
console.log("/shoppinglist error", err);
|
},
|
||||||
}
|
error(err) {
|
||||||
});
|
console.log("/shoppinglist error", err);
|
||||||
}).catch((error) => console.error("/shoppinglist Get id token client error: ", error));}else{console.log("Check Auth error", user)}});
|
}
|
||||||
|
});
|
||||||
|
}).catch((error) => console.error("/shoppinglist Get id token client error: ", error));
|
||||||
|
} else {
|
||||||
|
console.log("Check Auth error", user)
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
$(".gruppenadd").click(function(){
|
$(".gruppenadd").click(function () {
|
||||||
|
|
||||||
// let name = $("#groupname").val();
|
// let name = $("#groupname").val();
|
||||||
// let color = $("#groupfarbe").val();
|
// let color = $("#groupfarbe").val();
|
||||||
$("#ListenDetailAdd").modal("hide");
|
$("#ListenDetailAdd").modal("hide");
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: "POST",
|
type: "POST",
|
||||||
url: "/group",
|
url: "/group",
|
||||||
data: {
|
data: {
|
||||||
sl_id: globaleAddZwischenID,
|
sl_id: globaleAddZwischenID,
|
||||||
name: $("#groupname").val(),
|
name: $("#groupname").val(),
|
||||||
color: $( "input:checked" ).val()
|
color: $("input:checked").val()
|
||||||
},
|
},
|
||||||
success(res){
|
success(res) {
|
||||||
console.log("groupadd funktioniert");
|
console.log("groupadd funktioniert");
|
||||||
|
|
||||||
},
|
},
|
||||||
error(err){
|
error(err) {
|
||||||
console.log("error");
|
console.log("error");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
$(".sl_add").click(function(){
|
$(".sl_add").click(function () {
|
||||||
$('#EigeneListeAdd').modal('show');
|
$('#EigeneListeAdd').modal('show');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
var globaleAddZwischenID = "";
|
var globaleAddZwischenID = "";
|
||||||
// var globaleGetZwischenID = "";
|
// var globaleGetZwischenID = "";
|
||||||
|
|
||||||
function eigeneEinkaufslisten(){
|
function eigeneEinkaufslisten() {
|
||||||
firebase.auth().onAuthStateChanged(async function(user){if(user){firebase.auth().currentUser.getIdToken(/* forceRefresh */ true).then(function(idtoken) {
|
firebase.auth().onAuthStateChanged(async function (user) {
|
||||||
console.log("/myshoppinglists idtoke: ", idtoken);
|
if (user) {
|
||||||
$.ajax({
|
firebase.auth().currentUser.getIdToken( /* forceRefresh */ true).then(function (idtoken) {
|
||||||
type: "GET",
|
console.log("/myshoppinglists idtoke: ", idtoken);
|
||||||
url: "/myshoppinglists",
|
$.ajax({
|
||||||
data:{
|
type: "GET",
|
||||||
idtoken: idtoken
|
url: "/myshoppinglists",
|
||||||
},
|
data: {
|
||||||
success(res){
|
idtoken: idtoken
|
||||||
firebase.auth().onAuthStateChanged(async function(user){if(user){firebase.auth().currentUser.getIdToken(/* forceRefresh */ true).then(function(idtoken) {
|
},
|
||||||
console.log("/userinfo_json idtoken: ",idtoken)
|
success(res) {
|
||||||
$.ajax({
|
firebase.auth().onAuthStateChanged(async function (user) {
|
||||||
type: "GET",
|
if (user) {
|
||||||
url: "/userinfo_json",
|
firebase.auth().currentUser.getIdToken( /* forceRefresh */ true).then(function (idtoken) {
|
||||||
data: {
|
console.log("/userinfo_json idtoken: ", idtoken)
|
||||||
idtoken: idtoken
|
$.ajax({
|
||||||
},
|
type: "GET",
|
||||||
success(data){
|
url: "/userinfo_json",
|
||||||
const userinfo = data.name;
|
data: {
|
||||||
const picture = data.picture;
|
idtoken: idtoken
|
||||||
console.log(data)
|
},
|
||||||
for(let i = 0; i < res.length; i++){
|
success(data) {
|
||||||
const el = res[i];
|
const userinfo = data.name;
|
||||||
|
const picture = data.picture;
|
||||||
$(".listen-ausgabe").append(`<div class="col-md-12 karten">
|
console.log(data)
|
||||||
|
for (let i = 0; i < res.length; i++) {
|
||||||
|
const el = res[i];
|
||||||
|
|
||||||
|
$(".listen-ausgabe").append(`<div class="col-md-12 karten">
|
||||||
<div class="card border-light mb-3 shadow-sm" style="max-width: 18rem;" id="${el.sl_id}">
|
<div class="card border-light mb-3 shadow-sm" style="max-width: 18rem;" id="${el.sl_id}">
|
||||||
<div class="card-header" style="background-color: #${el.color};">
|
<div class="card-header" style="background-color: #${el.color};">
|
||||||
<span>
|
<span>
|
||||||
@ -142,49 +158,62 @@ function eigeneEinkaufslisten(){
|
|||||||
<h5 class="card-title">${el.name}</h5>
|
<h5 class="card-title">${el.name}</h5>
|
||||||
<p class="card-text">${el.description}</p>
|
<p class="card-text">${el.description}</p>
|
||||||
</div>
|
</div>
|
||||||
</div></div>`
|
</div></div>`)
|
||||||
)
|
}
|
||||||
|
console.log("Eigene Einkaufslisten");
|
||||||
|
loeschen();
|
||||||
|
lala();
|
||||||
|
Detail();
|
||||||
|
// groupHinzufügen()
|
||||||
|
},
|
||||||
|
error(err) {
|
||||||
|
console.error("userinfo_json error: ", err)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}).catch((error) => console.error("Get id token client error: ", error));
|
||||||
|
} else {
|
||||||
|
console.log("Check Auth error", user)
|
||||||
}
|
}
|
||||||
console.log("Eigene Einkaufslisten");
|
});
|
||||||
loeschen();
|
},
|
||||||
lala();
|
error(err) {
|
||||||
Detail();
|
console.error("/myshoppinglists ajax error: ", err);
|
||||||
// groupHinzufügen()
|
}
|
||||||
},
|
});
|
||||||
error(err){
|
}).catch((error) => console.error("Get id token client error: ", error));
|
||||||
console.error("userinfo_json error: ", err)
|
} else {
|
||||||
}
|
console.log("Check Auth error", user)
|
||||||
})
|
}
|
||||||
}).catch((error) => console.error("Get id token client error: ", error));}else{console.log("Check Auth error", user)}});
|
});
|
||||||
},
|
|
||||||
error(err){
|
|
||||||
console.error("/myshoppinglists ajax error: ", err);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}).catch((error) => console.error("Get id token client error: ", error));}else{console.log("Check Auth error", user)}});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
function geteilteEinkaufslisten(){
|
function geteilteEinkaufslisten() {
|
||||||
firebase.auth().onAuthStateChanged(async function(user){if(user){firebase.auth().currentUser.getIdToken(/* forceRefresh */ true).then(function(idtoken) {
|
firebase.auth().onAuthStateChanged(async function (user) {
|
||||||
console.log("/sharedshoppinglists idtoke: ", idtoken)
|
if (user) {
|
||||||
$.ajax({
|
firebase.auth().currentUser.getIdToken( /* forceRefresh */ true).then(function (idtoken) {
|
||||||
data: "GET",
|
console.log("/sharedshoppinglists idtoke: ", idtoken)
|
||||||
url: "/sharedshoppinglists",
|
$.ajax({
|
||||||
data: {
|
data: "GET",
|
||||||
idtoken: idtoken
|
url: "/sharedshoppinglists",
|
||||||
},
|
data: {
|
||||||
success(res){
|
idtoken: idtoken
|
||||||
console.log("Geteilte Einkaufslisten");
|
},
|
||||||
},
|
success(res) {
|
||||||
error(err){
|
console.log("Geteilte Einkaufslisten");
|
||||||
console.error("/sharedshoppinglists error:", err);
|
},
|
||||||
}
|
error(err) {
|
||||||
});
|
console.error("/sharedshoppinglists error:", err);
|
||||||
}).catch((error) => console.error("Get id token client error: ", error));}else{console.log("Check Auth error", user)}});
|
}
|
||||||
|
});
|
||||||
|
}).catch((error) => console.error("Get id token client error: ", error));
|
||||||
|
} else {
|
||||||
|
console.log("Check Auth error", user)
|
||||||
|
}
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
function loeschen(){
|
function loeschen() {
|
||||||
$(".trash").click(function(){
|
$(".trash").click(function () {
|
||||||
|
|
||||||
let card = $(this).closest(".card");
|
let card = $(this).closest(".card");
|
||||||
let id = card.attr("id");
|
let id = card.attr("id");
|
||||||
@ -195,12 +224,13 @@ function loeschen(){
|
|||||||
type: "DELETE",
|
type: "DELETE",
|
||||||
url: "/shoppinglist",
|
url: "/shoppinglist",
|
||||||
data: {
|
data: {
|
||||||
sl_id: id},
|
sl_id: id
|
||||||
success(res){
|
},
|
||||||
|
success(res) {
|
||||||
console.log("card gelöscht");
|
console.log("card gelöscht");
|
||||||
card.remove();
|
card.remove();
|
||||||
},
|
},
|
||||||
error(err){
|
error(err) {
|
||||||
console.log("error");
|
console.log("error");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -208,8 +238,8 @@ function loeschen(){
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
function lala(){
|
function lala() {
|
||||||
$(".groupadd").click(function(){
|
$(".groupadd").click(function () {
|
||||||
let card = $(this).closest(".card");
|
let card = $(this).closest(".card");
|
||||||
let id = card.attr("id");
|
let id = card.attr("id");
|
||||||
globaleAddZwischenID = id;
|
globaleAddZwischenID = id;
|
||||||
@ -217,51 +247,53 @@ function lala(){
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function Detail(){
|
function Detail() {
|
||||||
$(".edit").click(function(){
|
$(".edit").click(function () {
|
||||||
|
|
||||||
$(".cardausgabe").hide();
|
$(".cardausgabe").hide();
|
||||||
$(".detailcardausgabe").show();
|
$(".detailcardausgabe").show();
|
||||||
|
|
||||||
let card = $(this).closest(".card");
|
let card = $(this).closest(".card");
|
||||||
let id = card.attr("id");
|
let id = card.attr("id");
|
||||||
firebase.auth().onAuthStateChanged(async function(user){if(user){firebase.auth().currentUser.getIdToken(/* forceRefresh */ true).then(function(idtoken) {
|
firebase.auth().onAuthStateChanged(async function (user) {
|
||||||
$.ajax({
|
if (user) {
|
||||||
type: "GET",
|
firebase.auth().currentUser.getIdToken( /* forceRefresh */ true).then(function (idtoken) {
|
||||||
url: "/shoppinglist_json/" + id,
|
|
||||||
data: {
|
|
||||||
idtoken: idtoken
|
|
||||||
},
|
|
||||||
success(res){
|
|
||||||
console.log(res)
|
|
||||||
console.log("/myshoppinglists inside idtoken: ", idtoken)
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: "GET",
|
type: "GET",
|
||||||
url: "/myshoppinglists",
|
url: "/shoppinglist_json/" + id,
|
||||||
data: {
|
data: {
|
||||||
idtoken: idtoken
|
idtoken: idtoken
|
||||||
},
|
},
|
||||||
success(result){
|
success(res) {
|
||||||
// var idtoken = getIdTokenGoogle()
|
console.log(res)
|
||||||
|
console.log("/myshoppinglists inside idtoken: ", idtoken)
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: "GET",
|
type: "GET",
|
||||||
url: "/userinfo_json",
|
url: "/myshoppinglists",
|
||||||
data:{
|
data: {
|
||||||
idtoken: idtoken
|
idtoken: idtoken
|
||||||
},
|
},
|
||||||
success(data){
|
success(result) {
|
||||||
let userinfo = "some info"
|
// var idtoken = getIdTokenGoogle()
|
||||||
console.log(userinfo);
|
$.ajax({
|
||||||
|
type: "GET",
|
||||||
const neu = result.filter(obj => obj.sl_id === id);
|
url: "/userinfo_json",
|
||||||
|
data: {
|
||||||
|
idtoken: idtoken
|
||||||
|
},
|
||||||
|
success(data) {
|
||||||
|
let userinfo = "some info"
|
||||||
|
console.log(userinfo);
|
||||||
|
|
||||||
var link = "/dash/"+idtoken;
|
const neu = result.filter(obj => obj.sl_id === id);
|
||||||
|
|
||||||
$(".kopf").attr("style",`background-color:#${neu[0].color}`);
|
var link = "/dash/" + idtoken;
|
||||||
|
|
||||||
console.log(neu[0].color);
|
$(".kopf").attr("style", `background-color:#${neu[0].color}`);
|
||||||
|
|
||||||
$(".card-header").append(`<div class="shoplistid" id="${id}">
|
console.log(neu[0].color);
|
||||||
|
|
||||||
|
$(".card-header").append(`<div class="shoplistid" id="${id}">
|
||||||
<a href="${link}" style="left: 5px; margin-top: -50px;color: black;">
|
<a href="${link}" style="left: 5px; margin-top: -50px;color: black;">
|
||||||
<i class="fas fa-caret-left"></i>
|
<i class="fas fa-caret-left"></i>
|
||||||
</a>
|
</a>
|
||||||
@ -272,9 +304,9 @@ function Detail(){
|
|||||||
${neu[0].name}
|
${neu[0].name}
|
||||||
</h1></div>
|
</h1></div>
|
||||||
`);
|
`);
|
||||||
for (let i = 0; i < res.groups.length; i++) {
|
for (let i = 0; i < res.groups.length; i++) {
|
||||||
const el = res.groups[i];
|
const el = res.groups[i];
|
||||||
$(".gruppeninhalt").append(`<div class="col-md-6 col-lg-4 shoplisteid" id="${res.sl_id}">
|
$(".gruppeninhalt").append(`<div class="col-md-6 col-lg-4 shoplisteid" id="${res.sl_id}">
|
||||||
<div class="card mb-3 groupid ${el.group_id}" id="${el.group_id}" style="max-width: 18rem;background-color:#${el.color};">
|
<div class="card mb-3 groupid ${el.group_id}" id="${el.group_id}" style="max-width: 18rem;background-color:#${el.color};">
|
||||||
|
|
||||||
<div class="card-header"><h5 class="card-title">${el.name}</h5><button class="btn trashgroup"><i class="far fa-trash-alt"></i></button><button class="btn seemore" type="button" data-toggle="collapse" data-target="#${el.name}" aria-expanded="false" aria-controls="${el.name}"><i class="fas fa-caret-down"></i></button>
|
<div class="card-header"><h5 class="card-title">${el.name}</h5><button class="btn trashgroup"><i class="far fa-trash-alt"></i></button><button class="btn seemore" type="button" data-toggle="collapse" data-target="#${el.name}" aria-expanded="false" aria-controls="${el.name}"><i class="fas fa-caret-down"></i></button>
|
||||||
@ -284,71 +316,81 @@ function Detail(){
|
|||||||
|
|
||||||
</div></div>
|
</div></div>
|
||||||
`);
|
`);
|
||||||
for(let x = 0; x < el.content.length; x++){
|
for (let x = 0; x < el.content.length; x++) {
|
||||||
const el2 = el.content[x]
|
const el2 = el.content[x]
|
||||||
$(`.${el.name}`).append(`<div class="collapse" id="${el.name}"><ul><li>${el2.count}x ${el2.name}</li></ul></div>`);
|
$(`.${el.name}`).append(`<div class="collapse" id="${el.name}"><ul><li>${el2.count}x ${el2.name}</li></ul></div>`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ItemAdden();
|
ItemAdden();
|
||||||
groupdelete();
|
groupdelete();
|
||||||
|
},
|
||||||
|
error(err) {
|
||||||
|
console.log("Detail error userinfo_json: ", err);
|
||||||
|
}
|
||||||
|
})
|
||||||
},
|
},
|
||||||
error(err){
|
error(err) {
|
||||||
console.log("Detail error userinfo_json: ", err);
|
console.log("Detail error myshoppinglists: ", err);
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
},
|
},
|
||||||
error(err){
|
error(err) {
|
||||||
console.log("Detail error myshoppinglists: ", err);
|
console.log("Detail error shoppinglist_json: ", err);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
}).catch((error) => console.error("Get id token client error: ", error));
|
||||||
error(err){
|
} else {
|
||||||
console.log("Detail error shoppinglist_json: " , err);
|
console.log("Check Auth error", user)
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}).catch((error) => console.error("Get id token client error: ", error));}else{console.log("Check Auth error", user)}});
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
function ItemAdden(){
|
function ItemAdden() {
|
||||||
$(".itemadd").click(function(){
|
$(".itemadd").click(function () {
|
||||||
|
|
||||||
let getid = $(this).closest('.shoplistid');
|
let getid = $(this).closest('.shoplistid');
|
||||||
let id = getid.attr('id');
|
let id = getid.attr('id');
|
||||||
globaleAddZwischenID = id;
|
globaleAddZwischenID = id;
|
||||||
console.log(id);
|
console.log(id);
|
||||||
$('.select').remove();
|
$('.select').remove();
|
||||||
|
|
||||||
$('.GroupItemAdd').modal('show');
|
$('.GroupItemAdd').modal('show');
|
||||||
|
|
||||||
firebase.auth().onAuthStateChanged(async function(user){if(user){firebase.auth().currentUser.getIdToken(/* forceRefresh */ true).then(function(idtoken) {
|
firebase.auth().onAuthStateChanged(async function (user) {
|
||||||
$.ajax({
|
if (user) {
|
||||||
type: "GET",
|
firebase.auth().currentUser.getIdToken( /* forceRefresh */ true).then(function (idtoken) {
|
||||||
url: "/shoppinglist_json/" + id,
|
$.ajax({
|
||||||
data: {
|
type: "GET",
|
||||||
idtoken: idtoken
|
url: "/shoppinglist_json/" + id,
|
||||||
},
|
data: {
|
||||||
success(result){
|
idtoken: idtoken
|
||||||
|
},
|
||||||
|
success(result) {
|
||||||
|
|
||||||
console.log(result.groups);
|
console.log(result.groups);
|
||||||
|
|
||||||
for (let i = 0; i < result.groups.length; i++) {
|
for (let i = 0; i < result.groups.length; i++) {
|
||||||
const el = result.groups[i];
|
const el = result.groups[i];
|
||||||
$(".custom-select-groups").append(`
|
$(".custom-select-groups").append(`
|
||||||
<option class="select" value="${el.group_id}">${el.name}</option>
|
<option class="select" value="${el.group_id}">${el.name}</option>
|
||||||
`);
|
`);
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
error(err){
|
error(err) {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}).catch((error) => console.error("Get id token client error: ", error));}else{console.log("Check Auth error", user)}});
|
}).catch((error) => console.error("Get id token client error: ", error));
|
||||||
|
} else {
|
||||||
|
console.log("Check Auth error", user)
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
$(".itemhinzu").click(function(){
|
$(".itemhinzu").click(function () {
|
||||||
|
|
||||||
var name = $('#itemname').val();
|
var name = $('#itemname').val();
|
||||||
var zahl = $('#inputGroupSelect01').val();
|
var zahl = $('#inputGroupSelect01').val();
|
||||||
@ -361,14 +403,15 @@ $(".itemhinzu").click(function(){
|
|||||||
type: "POST",
|
type: "POST",
|
||||||
url: "/item",
|
url: "/item",
|
||||||
data: {
|
data: {
|
||||||
group_id: $('#inputGroupSelect02').val(),
|
group_id: $('#inputGroupSelect02').val(),
|
||||||
sl_id: globaleAddZwischenID,
|
sl_id: globaleAddZwischenID,
|
||||||
name: $('#itemname').val(),
|
name: $('#itemname').val(),
|
||||||
count: $('#inputGroupSelect01').val()
|
count: $('#inputGroupSelect01').val()
|
||||||
},
|
},
|
||||||
success(result){
|
success(result) {
|
||||||
console.log("post item");
|
console.log("post item");
|
||||||
},error(err){
|
},
|
||||||
|
error(err) {
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -377,9 +420,9 @@ $(".itemhinzu").click(function(){
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
function groupdelete(){
|
function groupdelete() {
|
||||||
$('.trashgroup').click(function(){
|
$('.trashgroup').click(function () {
|
||||||
|
|
||||||
let getid = $(this).closest('.shoplisteid');
|
let getid = $(this).closest('.shoplisteid');
|
||||||
let shoplistid = getid.attr('id');
|
let shoplistid = getid.attr('id');
|
||||||
let getid2 = $(this).closest('.groupid');
|
let getid2 = $(this).closest('.groupid');
|
||||||
@ -393,15 +436,16 @@ function groupdelete(){
|
|||||||
url: "/group",
|
url: "/group",
|
||||||
data: {
|
data: {
|
||||||
sl_id: shoplistid,
|
sl_id: shoplistid,
|
||||||
group_id: groupid},
|
group_id: groupid
|
||||||
success(res){
|
},
|
||||||
|
success(res) {
|
||||||
console.log("card gelöscht");
|
console.log("card gelöscht");
|
||||||
$(`.${groupid}`).remove();
|
$(`.${groupid}`).remove();
|
||||||
},
|
},
|
||||||
error(err){
|
error(err) {
|
||||||
console.log("error");
|
console.log("error");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
};
|
};
|
File diff suppressed because it is too large
Load Diff
@ -1,50 +1,47 @@
|
|||||||
|
|
||||||
|
|
||||||
// var admin = require("firebase-admin");
|
|
||||||
|
|
||||||
// var serviceAccount = require("firebaseAdminKey.json");
|
|
||||||
|
|
||||||
// admin.initializeApp({
|
|
||||||
// credential: admin.credential.cert(serviceAccount),
|
|
||||||
// databaseURL: "https://test-667ca.firebaseio.com"
|
|
||||||
// });
|
|
||||||
|
|
||||||
var msg = firebase.messaging();
|
var msg = firebase.messaging();
|
||||||
msg.requestPermission()
|
msg.requestPermission()
|
||||||
.then(function(){
|
.then(function () {
|
||||||
|
|
||||||
return msg.getToken();
|
return msg.getToken();
|
||||||
})
|
})
|
||||||
.then(token => {
|
.then(token => {
|
||||||
console.log("Zugriff auf msg", token);
|
console.log("Zugriff auf msg", token);
|
||||||
updateUser(token);
|
updateUser(token);
|
||||||
|
|
||||||
})
|
})
|
||||||
.catch(err => {
|
.catch(err => {
|
||||||
console.error("Msg Error: ", err);
|
console.error("Msg Error: ", err);
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
function updateUser(token) {
|
function updateUser(token) {
|
||||||
firebase.auth().onAuthStateChanged(function(user){if(user){firebase.auth().currentUser.getIdToken(/* forceRefresh */ true).then(function(idtoken) {
|
firebase.auth().onAuthStateChanged(function (user) {
|
||||||
$.ajax({
|
if (user) {
|
||||||
type: "POST",
|
firebase.auth().currentUser.getIdToken( /* forceRefresh */ true).then(function (idtoken) {
|
||||||
url: "/user",
|
$.ajax({
|
||||||
data:{
|
type: "POST",
|
||||||
idtoken: idtoken,
|
url: "/user",
|
||||||
message_id: token
|
data: {
|
||||||
},
|
idtoken: idtoken,
|
||||||
success(){
|
message_id: token
|
||||||
console.log("User updated");
|
},
|
||||||
},
|
success() {
|
||||||
error(err){
|
console.log("User updated");
|
||||||
console.error("Error: " + err);
|
},
|
||||||
}
|
error(err) {
|
||||||
});
|
console.error("Error: " + err);
|
||||||
}).catch((error) => console.error("Get id token client error: ", error));}else{console.log("Check Auth error", user)}});
|
}
|
||||||
|
});
|
||||||
|
}).catch((error) => console.error("Get id token client error: ", error));
|
||||||
|
} else {
|
||||||
|
console.log("Check Auth error", user)
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
msg.onMessage(payload => {
|
msg.onMessage(payload => {
|
||||||
const title = payload.data.title
|
const title = payload.data.title
|
||||||
new Notification(title, { body: payload.data.body});
|
new Notification(title, {
|
||||||
})
|
body: payload.data.body
|
||||||
|
});
|
||||||
|
})
|
@ -1,101 +1,110 @@
|
|||||||
|
|
||||||
|
|
||||||
// Initialize Firebase
|
// Initialize Firebase
|
||||||
var config = {
|
var config = {
|
||||||
apiKey: "AIzaSyCuvwf78cmSDoZ2yS4XxHZhnjUn7yIHYfw",
|
apiKey: "AIzaSyCuvwf78cmSDoZ2yS4XxHZhnjUn7yIHYfw",
|
||||||
authDomain: "test-667ca.firebaseapp.com",
|
authDomain: "test-667ca.firebaseapp.com",
|
||||||
databaseURL: "https://test-667ca.firebaseio.com",
|
databaseURL: "https://test-667ca.firebaseio.com",
|
||||||
projectId: "test-667ca",
|
projectId: "test-667ca",
|
||||||
storageBucket: "test-667ca.appspot.com",
|
storageBucket: "test-667ca.appspot.com",
|
||||||
messagingSenderId: "221332577314"
|
messagingSenderId: "221332577314"
|
||||||
};
|
};
|
||||||
firebase.initializeApp(config);
|
firebase.initializeApp(config);
|
||||||
|
|
||||||
|
|
||||||
function checkAuth(){
|
function checkAuth() {
|
||||||
firebase.auth().onAuthStateChanged(async function(user){
|
firebase.auth().onAuthStateChanged(async function (user) {
|
||||||
if(user){
|
if (user) {
|
||||||
try{
|
try {
|
||||||
firebase.auth().currentUser.getIdToken(/* forceRefresh */ true).then(function(idToken) {
|
firebase.auth().currentUser.getIdToken( /* forceRefresh */ true).then(function (idToken) {
|
||||||
console.log("Vor Replace");
|
console.log("Vor Replace");
|
||||||
|
|
||||||
window.location.replace("/dash/" + idToken);
|
window.location.replace("/dash/" + idToken);
|
||||||
}).catch(function(error) {
|
}).catch(function (error) {
|
||||||
console.error("Get id token client error: ", error)
|
console.error("Get id token client error: ", error)
|
||||||
});
|
});
|
||||||
}catch{
|
} catch {
|
||||||
console.error("checkAuth error: ")
|
console.error("checkAuth error: ")
|
||||||
}
|
}
|
||||||
|
|
||||||
// document.getElementById("loginbutton").style.display = "none";
|
// document.getElementById("loginbutton").style.display = "none";
|
||||||
//
|
//
|
||||||
}else{
|
} else {
|
||||||
// document.getElementById("loginbutton").style.display = "block";
|
// document.getElementById("loginbutton").style.display = "block";
|
||||||
console.log("Check Auth error", user)
|
console.log("Check Auth error", user)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
var user = firebase.auth().currentUser;
|
var user = firebase.auth().currentUser;
|
||||||
}
|
}
|
||||||
window.onload = function(){
|
window.onload = function () {
|
||||||
checkAuth();
|
checkAuth();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var vue = new Vue({
|
var vue = new Vue({
|
||||||
el: '#vue-app',
|
el: '#vue-app',
|
||||||
data:{
|
data: {
|
||||||
|
email: "",
|
||||||
|
password: ""
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
login() {
|
||||||
|
var provider = new firebase.auth.GoogleAuthProvider();
|
||||||
|
provider.addScope('profile');
|
||||||
|
provider.addScope('email');
|
||||||
|
firebase.auth().signInWithPopup(provider).then(function (result) {
|
||||||
|
// This gives you a Google Access Token. You can use it to access the Google API.
|
||||||
|
var token = result.credential.accessToken;
|
||||||
|
var idToken = result.credential.idToken;
|
||||||
|
// The signed-in user info.
|
||||||
|
var user = result.user;
|
||||||
|
console.log("Eingelogt");
|
||||||
|
checkAuth();
|
||||||
|
}).catch(function (error) {
|
||||||
|
// Handle Errors here.
|
||||||
|
var errorCode = error.code;
|
||||||
|
var errorMessage = error.message;
|
||||||
|
// The email of the user's account used.
|
||||||
|
var email = error.email;
|
||||||
|
// The firebase.auth.AuthCredential type that was used.
|
||||||
|
var credential = error.credential;
|
||||||
|
|
||||||
|
});
|
||||||
},
|
},
|
||||||
methods: {
|
loginemail(){
|
||||||
login(){
|
firebase.auth().signInWithEmailAndPassword(this.email, this.password).then(result =>{
|
||||||
var provider = new firebase.auth.GoogleAuthProvider();
|
checkAuth();
|
||||||
provider.addScope('profile');
|
}).catch(function(error) {
|
||||||
provider.addScope('email');
|
// Handle Errors here.
|
||||||
firebase.auth().signInWithPopup(provider).then(function(result) {
|
var errorCode = error.code;
|
||||||
// This gives you a Google Access Token. You can use it to access the Google API.
|
var errorMessage = error.message;
|
||||||
var token = result.credential.accessToken;
|
// ...
|
||||||
var idToken = result.credential.idToken;
|
});
|
||||||
// The signed-in user info.
|
|
||||||
var user = result.user;
|
|
||||||
console.log("Eingelogt");
|
|
||||||
checkAuth();
|
|
||||||
}).catch(function(error) {
|
|
||||||
// Handle Errors here.
|
|
||||||
var errorCode = error.code;
|
|
||||||
var errorMessage = error.message;
|
|
||||||
// The email of the user's account used.
|
|
||||||
var email = error.email;
|
|
||||||
// The firebase.auth.AuthCredential type that was used.
|
|
||||||
var credential = error.credential;
|
|
||||||
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
},
|
|
||||||
|
|
||||||
mounted() {
|
|
||||||
/*axios.post('/user', {
|
|
||||||
message_id: 'test',
|
|
||||||
})
|
|
||||||
.then(function (response) {
|
|
||||||
console.log(response);
|
|
||||||
})
|
|
||||||
.catch(function (error) {
|
|
||||||
console.log(error);
|
|
||||||
});*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// mounted() {
|
},
|
||||||
// axios.post('/user', {
|
|
||||||
// message_id: 'test',
|
mounted() {
|
||||||
// })
|
/*axios.post('/user', {
|
||||||
// .then(function (response) {
|
message_id: 'test',
|
||||||
// console.log(response);
|
})
|
||||||
// })
|
.then(function (response) {
|
||||||
// .catch(function (error) {
|
console.log(response);
|
||||||
// console.log(error);
|
})
|
||||||
// });
|
.catch(function (error) {
|
||||||
// }
|
console.log(error);
|
||||||
|
});*/
|
||||||
|
}
|
||||||
|
|
||||||
|
// mounted() {
|
||||||
|
// axios.post('/user', {
|
||||||
|
// message_id: 'test',
|
||||||
|
// })
|
||||||
|
// .then(function (response) {
|
||||||
|
// console.log(response);
|
||||||
|
// })
|
||||||
|
// .catch(function (error) {
|
||||||
|
// console.log(error);
|
||||||
|
// });
|
||||||
|
// }
|
||||||
|
|
||||||
});
|
});
|
@ -1,4 +1,4 @@
|
|||||||
$(document).ready(function() {
|
$(document).ready(function () {
|
||||||
refresh();
|
refresh();
|
||||||
|
|
||||||
userinfo();
|
userinfo();
|
||||||
@ -13,8 +13,8 @@ $(document).ready(function() {
|
|||||||
hidden: false
|
hidden: false
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$(".btn_invite").click(function() {
|
$(".btn_invite").click(function () {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: "POST",
|
type: "POST",
|
||||||
url: "/invite",
|
url: "/invite",
|
||||||
@ -25,11 +25,11 @@ $(document).ready(function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
$(document).on("click", ".btn_detail", function() {
|
$(document).on("click", ".btn_detail", function () {
|
||||||
window.location.replace("/shoppinglist_json/" + $(this).closest("tr").attr("id"));
|
window.location.replace("/shoppinglist_json/" + $(this).closest("tr").attr("id"));
|
||||||
});
|
});
|
||||||
|
|
||||||
$(".btn_add").click(function() {
|
$(".btn_add").click(function () {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: "POST",
|
type: "POST",
|
||||||
url: "/shoppinglist",
|
url: "/shoppinglist",
|
||||||
@ -37,19 +37,21 @@ $(document).ready(function() {
|
|||||||
name: $(".name").val(),
|
name: $(".name").val(),
|
||||||
description: $(".description").val(),
|
description: $(".description").val(),
|
||||||
color: "red"
|
color: "red"
|
||||||
}, success(result) {
|
},
|
||||||
|
success(result) {
|
||||||
refresh();
|
refresh();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
$(document).on("click", ".btn_delete", function() {
|
$(document).on("click", ".btn_delete", function () {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: "DELETE",
|
type: "DELETE",
|
||||||
url: "/shoppinglist",
|
url: "/shoppinglist",
|
||||||
data: {
|
data: {
|
||||||
sl_id: $(this).closest("tr").attr("id")
|
sl_id: $(this).closest("tr").attr("id")
|
||||||
}, success(result) {
|
},
|
||||||
|
success(result) {
|
||||||
refresh();
|
refresh();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -64,10 +66,10 @@ function refresh() {
|
|||||||
type: "GET",
|
type: "GET",
|
||||||
url: "/myshoppinglists",
|
url: "/myshoppinglists",
|
||||||
success(data) {
|
success(data) {
|
||||||
for(let item of data) {
|
for (let item of data) {
|
||||||
$(".tb_myshoppinglists").append("<tr id='" + item.sl_id +"'><td>" + item.name + "</td><td>" + item.description +
|
$(".tb_myshoppinglists").append("<tr id='" + item.sl_id + "'><td>" + item.name + "</td><td>" + item.description +
|
||||||
"</td><td> <a class='btn-floating btn-large waves-effect waves-light red btn_detail'><i class='material-icons'>forward</i></a></td>"
|
"</td><td> <a class='btn-floating btn-large waves-effect waves-light red btn_detail'><i class='material-icons'>forward</i></a></td>" +
|
||||||
+ "<td><a class='btn-floating btn-large waves-effect waves-light red btn_delete'><i class='material-icons'>clear</i></a></td></tr>");
|
"<td><a class='btn-floating btn-large waves-effect waves-light red btn_delete'><i class='material-icons'>clear</i></a></td></tr>");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -76,9 +78,9 @@ function refresh() {
|
|||||||
type: "GET",
|
type: "GET",
|
||||||
url: "/sharedshoppinglists",
|
url: "/sharedshoppinglists",
|
||||||
success(data) {
|
success(data) {
|
||||||
for(let item of data) {
|
for (let item of data) {
|
||||||
$(".tb_sharedshoppinglists").append("<tr id='" + item.sl_id +"'><td>" + item.name + "</td><td>" + item.description +
|
$(".tb_sharedshoppinglists").append("<tr id='" + item.sl_id + "'><td>" + item.name + "</td><td>" + item.description +
|
||||||
"</td><td> <a class='btn-floating btn-large waves-effect waves-light red btn_detail'><i class='material-icons'>forward</i></a></td></tr>");
|
"</td><td> <a class='btn-floating btn-large waves-effect waves-light red btn_detail'><i class='material-icons'>forward</i></a></td></tr>");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -7,16 +7,18 @@ $(document).ready(function () {
|
|||||||
var canvas = document.getElementById("canvas");
|
var canvas = document.getElementById("canvas");
|
||||||
var context = canvas.getContext("2d");
|
var context = canvas.getContext("2d");
|
||||||
|
|
||||||
navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.oGetUserMedia || navigator.msGetUserMedia;
|
navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.oGetUserMedia || navigator.msGetUserMedia;
|
||||||
|
|
||||||
if (navigator.getUserMedia) {
|
if (navigator.getUserMedia) {
|
||||||
navigator.getUserMedia({ video: true }, streamWebcam, throwError);
|
navigator.getUserMedia({
|
||||||
|
video: true
|
||||||
|
}, streamWebcam, throwError);
|
||||||
}
|
}
|
||||||
|
|
||||||
$(".btnsnap").click(function() {
|
$(".btnsnap").click(function () {
|
||||||
snap();
|
snap();
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
function streamWebcam(stream) {
|
function streamWebcam(stream) {
|
||||||
|
@ -1,12 +1,49 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
var _createClass = function () {
|
||||||
|
function defineProperties(target, props) {
|
||||||
|
for (var i = 0; i < props.length; i++) {
|
||||||
|
var descriptor = props[i];
|
||||||
|
descriptor.enumerable = descriptor.enumerable || false;
|
||||||
|
descriptor.configurable = true;
|
||||||
|
if ("value" in descriptor) descriptor.writable = true;
|
||||||
|
Object.defineProperty(target, descriptor.key, descriptor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return function (Constructor, protoProps, staticProps) {
|
||||||
|
if (protoProps) defineProperties(Constructor.prototype, protoProps);
|
||||||
|
if (staticProps) defineProperties(Constructor, staticProps);
|
||||||
|
return Constructor;
|
||||||
|
};
|
||||||
|
}();
|
||||||
|
|
||||||
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
function _possibleConstructorReturn(self, call) {
|
||||||
|
if (!self) {
|
||||||
|
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
||||||
|
}
|
||||||
|
return call && (typeof call === "object" || typeof call === "function") ? call : self;
|
||||||
|
}
|
||||||
|
|
||||||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
|
function _inherits(subClass, superClass) {
|
||||||
|
if (typeof superClass !== "function" && superClass !== null) {
|
||||||
|
throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
|
||||||
|
}
|
||||||
|
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
||||||
|
constructor: {
|
||||||
|
value: subClass,
|
||||||
|
enumerable: false,
|
||||||
|
writable: true,
|
||||||
|
configurable: true
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;
|
||||||
|
}
|
||||||
|
|
||||||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
function _classCallCheck(instance, Constructor) {
|
||||||
|
if (!(instance instanceof Constructor)) {
|
||||||
|
throw new TypeError("Cannot call a class as a function");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
@ -487,7 +524,13 @@ var Dropzone = function (_Emitter) {
|
|||||||
* Allows you to translate the different units. Starting with `tb` for terabytes and going down to
|
* Allows you to translate the different units. Starting with `tb` for terabytes and going down to
|
||||||
* `b` for bytes.
|
* `b` for bytes.
|
||||||
*/
|
*/
|
||||||
dictFileSizeUnits: { tb: "TB", gb: "GB", mb: "MB", kb: "KB", b: "b" },
|
dictFileSizeUnits: {
|
||||||
|
tb: "TB",
|
||||||
|
gb: "GB",
|
||||||
|
mb: "MB",
|
||||||
|
kb: "KB",
|
||||||
|
b: "b"
|
||||||
|
},
|
||||||
/**
|
/**
|
||||||
* Called when dropzone initialized
|
* Called when dropzone initialized
|
||||||
* You can add event listeners here
|
* You can add event listeners here
|
||||||
@ -1016,7 +1059,7 @@ var Dropzone = function (_Emitter) {
|
|||||||
var _this = _possibleConstructorReturn(this, (Dropzone.__proto__ || Object.getPrototypeOf(Dropzone)).call(this));
|
var _this = _possibleConstructorReturn(this, (Dropzone.__proto__ || Object.getPrototypeOf(Dropzone)).call(this));
|
||||||
|
|
||||||
var fallback = void 0,
|
var fallback = void 0,
|
||||||
left = void 0;
|
left = void 0;
|
||||||
_this.element = el;
|
_this.element = el;
|
||||||
// For backwards compatibility since the version was in the prototype previously
|
// For backwards compatibility since the version was in the prototype previously
|
||||||
_this.version = Dropzone.version;
|
_this.version = Dropzone.version;
|
||||||
@ -1345,7 +1388,8 @@ var Dropzone = function (_Emitter) {
|
|||||||
// "paste": (e) =>
|
// "paste": (e) =>
|
||||||
// noPropagation e
|
// noPropagation e
|
||||||
// @paste e
|
// @paste e
|
||||||
} }];
|
}
|
||||||
|
}];
|
||||||
|
|
||||||
this.clickableElements.forEach(function (clickableElement) {
|
this.clickableElements.forEach(function (clickableElement) {
|
||||||
return _this3.listeners.push({
|
return _this3.listeners.push({
|
||||||
@ -1450,7 +1494,7 @@ var Dropzone = function (_Emitter) {
|
|||||||
key: "getFallbackForm",
|
key: "getFallbackForm",
|
||||||
value: function getFallbackForm() {
|
value: function getFallbackForm() {
|
||||||
var existingFallback = void 0,
|
var existingFallback = void 0,
|
||||||
form = void 0;
|
form = void 0;
|
||||||
if (existingFallback = this.getExistingFallback()) {
|
if (existingFallback = this.getExistingFallback()) {
|
||||||
return existingFallback;
|
return existingFallback;
|
||||||
}
|
}
|
||||||
@ -1647,8 +1691,8 @@ var Dropzone = function (_Emitter) {
|
|||||||
key: "paste",
|
key: "paste",
|
||||||
value: function paste(e) {
|
value: function paste(e) {
|
||||||
if (__guard__(e != null ? e.clipboardData : undefined, function (x) {
|
if (__guard__(e != null ? e.clipboardData : undefined, function (x) {
|
||||||
return x.items;
|
return x.items;
|
||||||
}) == null) {
|
}) == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2603,8 +2647,8 @@ var Dropzone = function (_Emitter) {
|
|||||||
chunk.total = e.total;
|
chunk.total = e.total;
|
||||||
chunk.bytesSent = e.loaded;
|
chunk.bytesSent = e.loaded;
|
||||||
var fileProgress = 0,
|
var fileProgress = 0,
|
||||||
fileTotal = void 0,
|
fileTotal = void 0,
|
||||||
fileBytesSent = void 0;
|
fileBytesSent = void 0;
|
||||||
file.upload.progress = 0;
|
file.upload.progress = 0;
|
||||||
file.upload.total = 0;
|
file.upload.total = 0;
|
||||||
file.upload.bytesSent = 0;
|
file.upload.bytesSent = 0;
|
||||||
@ -2853,7 +2897,7 @@ var Dropzone = function (_Emitter) {
|
|||||||
value: function uuidv4() {
|
value: function uuidv4() {
|
||||||
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
|
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
|
||||||
var r = Math.random() * 16 | 0,
|
var r = Math.random() * 16 | 0,
|
||||||
v = c === 'x' ? r : r & 0x3 | 0x8;
|
v = c === 'x' ? r : r & 0x3 | 0x8;
|
||||||
return v.toString(16);
|
return v.toString(16);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -2986,8 +3030,9 @@ Dropzone.discover = function () {
|
|||||||
// incorrectly **
|
// incorrectly **
|
||||||
//
|
//
|
||||||
Dropzone.blacklistedBrowsers = [
|
Dropzone.blacklistedBrowsers = [
|
||||||
// The mac os and windows phone version of opera 12 seems to have a problem with the File drag'n'drop API.
|
// The mac os and windows phone version of opera 12 seems to have a problem with the File drag'n'drop API.
|
||||||
/opera.*(Macintosh|Windows Phone).*version\/12/i];
|
/opera.*(Macintosh|Windows Phone).*version\/12/i
|
||||||
|
];
|
||||||
|
|
||||||
// Checks if the browser is supported
|
// Checks if the browser is supported
|
||||||
Dropzone.isBrowserSupported = function () {
|
Dropzone.isBrowserSupported = function () {
|
||||||
@ -3041,7 +3086,9 @@ Dropzone.dataURItoBlob = function (dataURI) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// write the ArrayBuffer to a blob
|
// write the ArrayBuffer to a blob
|
||||||
return new Blob([ab], { type: mimeString });
|
return new Blob([ab], {
|
||||||
|
type: mimeString
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
// Returns an array without the rejected item
|
// Returns an array without the rejected item
|
||||||
@ -3095,7 +3142,7 @@ Dropzone.getElement = function (el, name) {
|
|||||||
|
|
||||||
Dropzone.getElements = function (els, name) {
|
Dropzone.getElements = function (els, name) {
|
||||||
var el = void 0,
|
var el = void 0,
|
||||||
elements = void 0;
|
elements = void 0;
|
||||||
if (els instanceof Array) {
|
if (els instanceof Array) {
|
||||||
elements = [];
|
elements = [];
|
||||||
try {
|
try {
|
||||||
@ -3248,7 +3295,7 @@ var detectVerticalSquash = function detectVerticalSquash(img) {
|
|||||||
ctx.drawImage(img, 0, 0);
|
ctx.drawImage(img, 0, 0);
|
||||||
|
|
||||||
var _ctx$getImageData = ctx.getImageData(1, 0, 1, ih),
|
var _ctx$getImageData = ctx.getImageData(1, 0, 1, ih),
|
||||||
data = _ctx$getImageData.data;
|
data = _ctx$getImageData.data;
|
||||||
|
|
||||||
// search image edge pixel position in case it is squashed vertically.
|
// search image edge pixel position in case it is squashed vertically.
|
||||||
|
|
||||||
@ -3521,10 +3568,11 @@ contentLoaded(window, Dropzone._autoDiscoverFunction);
|
|||||||
function __guard__(value, transform) {
|
function __guard__(value, transform) {
|
||||||
return typeof value !== 'undefined' && value !== null ? transform(value) : undefined;
|
return typeof value !== 'undefined' && value !== null ? transform(value) : undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
function __guardMethod__(obj, methodName, transform) {
|
function __guardMethod__(obj, methodName, transform) {
|
||||||
if (typeof obj !== 'undefined' && obj !== null && typeof obj[methodName] === 'function') {
|
if (typeof obj !== 'undefined' && obj !== null && typeof obj[methodName] === 'function') {
|
||||||
return transform(obj, methodName);
|
return transform(obj, methodName);
|
||||||
} else {
|
} else {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,212 +1,247 @@
|
|||||||
var id;
|
var id;
|
||||||
|
|
||||||
$(document).ready(function() {
|
$(document).ready(function () {
|
||||||
|
|
||||||
M.AutoInit();
|
M.AutoInit();
|
||||||
//initialize all modals
|
//initialize all modals
|
||||||
$('.modal').modal({
|
$('.modal').modal({
|
||||||
dismissible: false
|
dismissible: false
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
$('.materialboxed').materialbox();
|
|
||||||
$('.fixed-action-btn').floatingActionButton();
|
|
||||||
|
|
||||||
|
|
||||||
if ($(window).width() > 600) {
|
$('.materialboxed').materialbox();
|
||||||
//large
|
$('.fixed-action-btn').floatingActionButton();
|
||||||
$(".col").css("height", "100%");
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
//small
|
|
||||||
$(".col").css("height", "50%");
|
|
||||||
}
|
|
||||||
|
|
||||||
$("#modal1").modal("open");
|
|
||||||
|
|
||||||
|
|
||||||
$(".btn-analyze").click(function() {
|
if ($(window).width() > 600) {
|
||||||
|
//large
|
||||||
|
$(".col").css("height", "100%");
|
||||||
|
} else {
|
||||||
|
//small
|
||||||
|
$(".col").css("height", "50%");
|
||||||
|
}
|
||||||
|
|
||||||
|
$("#modal1").modal("open");
|
||||||
|
|
||||||
|
|
||||||
|
$(".btn-analyze").click(function () {
|
||||||
analyzeUploaded();
|
analyzeUploaded();
|
||||||
});
|
});
|
||||||
|
|
||||||
//AJAX
|
|
||||||
|
|
||||||
// Initialize Firebase
|
//AJAX
|
||||||
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);
|
// 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"
|
||||||
|
};
|
||||||
|
|
||||||
getAllShoppinglists();
|
firebase.initializeApp(config);
|
||||||
|
|
||||||
updateUser();
|
|
||||||
testSearch();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function movePurchases(text) {
|
|
||||||
firebase.auth().onAuthStateChanged(function(user){if(user){firebase.auth().currentUser.getIdToken(/* forceRefresh */ true).then(function(idtoken) {
|
|
||||||
$.ajax({
|
|
||||||
type: "POST",
|
|
||||||
url: "/dones",
|
|
||||||
data:{
|
|
||||||
idtoken: idtoken,
|
|
||||||
sl_id: id,
|
|
||||||
billcontent: text
|
|
||||||
},
|
|
||||||
success(result){
|
|
||||||
console.log(result);
|
|
||||||
window.location.href = "/dash/" + idtoken
|
|
||||||
},
|
|
||||||
error(err){
|
|
||||||
console.error("Error: " + err);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}).catch((error) => console.error("Get id token client error: ", error));}else{console.log("Check Auth error", user)}});
|
|
||||||
}
|
|
||||||
|
|
||||||
$(".test").click(function() {
|
|
||||||
//movePurchases();
|
|
||||||
getAllShoppinglists();
|
getAllShoppinglists();
|
||||||
});
|
|
||||||
|
|
||||||
$(document).on("click", ".btndash", function() {
|
updateUser();
|
||||||
firebase.auth().onAuthStateChanged(function(user){if(user){firebase.auth().currentUser.getIdToken(/* forceRefresh */ true).then(function(idtoken) {
|
testSearch();
|
||||||
window.location.href = "/dash/" + idtoken
|
|
||||||
}).catch((error) => console.error("Get id token client error: ", error));}else{console.log("Check Auth error", user)}});
|
|
||||||
});
|
|
||||||
|
|
||||||
function analyzeUploaded() {
|
|
||||||
|
|
||||||
$("#modalEND").modal("open");
|
|
||||||
|
|
||||||
var img = document.getElementById("blah");
|
function movePurchases(text) {
|
||||||
|
firebase.auth().onAuthStateChanged(function (user) {
|
||||||
Tesseract.recognize(img).progress((progress) => {
|
if (user) {
|
||||||
|
firebase.auth().currentUser.getIdToken( /* forceRefresh */ true).then(function (idtoken) {
|
||||||
if (progress.status == "recognizing text") {
|
$.ajax({
|
||||||
loading = true;
|
type: "POST",
|
||||||
}
|
url: "/dones",
|
||||||
}).then((result) => {
|
data: {
|
||||||
loading = false;
|
idtoken: idtoken,
|
||||||
console.log(result.text);
|
sl_id: id,
|
||||||
movePurchases(result.text);
|
billcontent: text
|
||||||
$(".determinate").css("width", "0%");
|
},
|
||||||
});
|
success(result) {
|
||||||
}
|
console.log(result);
|
||||||
|
window.location.href = "/dash/" + idtoken
|
||||||
setInterval(updateProgress(), 500);
|
},
|
||||||
|
error(err) {
|
||||||
function updateProgress(percent) {
|
console.error("Error: " + err);
|
||||||
if(loading == true) {
|
}
|
||||||
$(".determinate").css("width", progress.progress * 100 + "%");
|
});
|
||||||
|
}).catch((error) => console.error("Get id token client error: ", error));
|
||||||
|
} else {
|
||||||
|
console.log("Check Auth error", user)
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
function updateUser() {
|
$(".test").click(function () {
|
||||||
firebase.auth().onAuthStateChanged(function(user){if(user){firebase.auth().currentUser.getIdToken(/* forceRefresh */ true).then(function(idtoken) {
|
//movePurchases();
|
||||||
$.ajax({
|
getAllShoppinglists();
|
||||||
type: "POST",
|
|
||||||
url: "/user",
|
|
||||||
data:{
|
|
||||||
idtoken: idtoken,
|
|
||||||
message_id: "msgtest"
|
|
||||||
},
|
|
||||||
success(){
|
|
||||||
console.log("USer updated");
|
|
||||||
},
|
|
||||||
error(err){
|
|
||||||
console.error("Error: " + err);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}).catch((error) => console.error("Get id token client error: ", error));}else{console.log("Check Auth error", user)}});
|
|
||||||
}
|
|
||||||
|
|
||||||
function testSearch() {
|
|
||||||
console.log("dpne");
|
|
||||||
$.ajax({
|
|
||||||
type: "DELETE",
|
|
||||||
url: "/member",
|
|
||||||
data: {
|
|
||||||
sl_id: "PDADo1iJ",
|
|
||||||
uid: "VZT25Xd3rLXEmGGUcrtocbJ9QBu2"
|
|
||||||
},
|
|
||||||
success(data) {
|
|
||||||
console.log(data);
|
|
||||||
},
|
|
||||||
error(err) {
|
|
||||||
console.error(err);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
|
||||||
|
$(document).on("click", ".btndash", function () {
|
||||||
function getAllShoppinglists() {
|
firebase.auth().onAuthStateChanged(function (user) {
|
||||||
firebase.auth().onAuthStateChanged(function(user){if(user){firebase.auth().currentUser.getIdToken(/* forceRefresh */ true).then(function(idtoken) {
|
if (user) {
|
||||||
$.ajax({
|
firebase.auth().currentUser.getIdToken( /* forceRefresh */ true).then(function (idtoken) {
|
||||||
type: "GET",
|
window.location.href = "/dash/" + idtoken
|
||||||
url: "/myshoppinglists",
|
}).catch((error) => console.error("Get id token client error: ", error));
|
||||||
data:{
|
} else {
|
||||||
idtoken: idtoken,
|
console.log("Check Auth error", user)
|
||||||
},
|
|
||||||
success(data){
|
|
||||||
|
|
||||||
$(".preloader-wrapper").css("display", "none");
|
|
||||||
for(let item of data) {
|
|
||||||
$(".output").append("<a id='" + item.sl_id +"' class='collection-item'>" + item.name + "</a>")
|
|
||||||
}
|
|
||||||
|
|
||||||
},
|
|
||||||
error(err){
|
|
||||||
console.error("Error: " + err);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}).catch((error) => console.error("Get id token client error: ", error));}else{console.log("Check Auth error", user)}});
|
});
|
||||||
}
|
|
||||||
|
|
||||||
$(document).on("click", ".collection-item", function() {
|
function analyzeUploaded() {
|
||||||
id = $(this).closest("a").attr("id");
|
|
||||||
|
|
||||||
$(".active").removeClass("active");
|
$("#modalEND").modal("open");
|
||||||
|
|
||||||
$(this).addClass("active");
|
var img = document.getElementById("blah");
|
||||||
});
|
|
||||||
|
|
||||||
$(".btncont").click(function() {
|
Tesseract.recognize(img).progress((progress) => {
|
||||||
run([{y:100}, {y:0}], $(".r1"));
|
|
||||||
});
|
|
||||||
|
|
||||||
function run(v, elem){
|
if (progress.status == "recognizing text") {
|
||||||
//Reverse the array
|
loading = true;
|
||||||
var reversed = JSON.parse(JSON.stringify(v)).reverse();
|
}
|
||||||
|
}).then((result) => {
|
||||||
$(v[0]).animate(v[1], {
|
loading = false;
|
||||||
//The speed the element moves - lower is faster
|
console.log(result.text);
|
||||||
duration: 500,
|
movePurchases(result.text);
|
||||||
step: function(val) {
|
$(".determinate").css("width", "0%");
|
||||||
//Adding the transform to your element
|
});
|
||||||
elem.css("transform", `translateY(${val}%)`);
|
}
|
||||||
|
|
||||||
|
setInterval(updateProgress(), 500);
|
||||||
|
|
||||||
|
function updateProgress(percent) {
|
||||||
|
if (loading == true) {
|
||||||
|
$(".determinate").css("width", progress.progress * 100 + "%");
|
||||||
}
|
}
|
||||||
})
|
|
||||||
};
|
|
||||||
|
|
||||||
$(".opt1").click(function() {
|
}
|
||||||
run([{y:0}, {y:-100}], $(".r1"))
|
|
||||||
|
|
||||||
run([{y:0}, {y:-100}], $(".r2"));
|
function updateUser() {
|
||||||
//$("#modal2").modal("open");
|
firebase.auth().onAuthStateChanged(function (user) {
|
||||||
});
|
if (user) {
|
||||||
|
firebase.auth().currentUser.getIdToken( /* forceRefresh */ true).then(function (idtoken) {
|
||||||
|
$.ajax({
|
||||||
|
type: "POST",
|
||||||
|
url: "/user",
|
||||||
|
data: {
|
||||||
|
idtoken: idtoken,
|
||||||
|
message_id: "msgtest"
|
||||||
|
},
|
||||||
|
success() {
|
||||||
|
console.log("USer updated");
|
||||||
|
},
|
||||||
|
error(err) {
|
||||||
|
console.error("Error: " + err);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}).catch((error) => console.error("Get id token client error: ", error));
|
||||||
|
} else {
|
||||||
|
console.log("Check Auth error", user)
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
$(".opt2").click(function() {
|
function testSearch() {
|
||||||
// $('.row').animate({'margin-top': '-100%'}, 1000);
|
console.log("dpne");
|
||||||
});
|
$.ajax({
|
||||||
|
type: "DELETE",
|
||||||
|
url: "/member",
|
||||||
|
data: {
|
||||||
|
sl_id: "PDADo1iJ",
|
||||||
|
uid: "VZT25Xd3rLXEmGGUcrtocbJ9QBu2"
|
||||||
|
},
|
||||||
|
success(data) {
|
||||||
|
console.log(data);
|
||||||
|
},
|
||||||
|
error(err) {
|
||||||
|
console.error(err);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function getAllShoppinglists() {
|
||||||
|
firebase.auth().onAuthStateChanged(function (user) {
|
||||||
|
if (user) {
|
||||||
|
firebase.auth().currentUser.getIdToken( /* forceRefresh */ true).then(function (idtoken) {
|
||||||
|
$.ajax({
|
||||||
|
type: "GET",
|
||||||
|
url: "/myshoppinglists",
|
||||||
|
data: {
|
||||||
|
idtoken: idtoken,
|
||||||
|
},
|
||||||
|
success(data) {
|
||||||
|
|
||||||
|
$(".preloader-wrapper").css("display", "none");
|
||||||
|
for (let item of data) {
|
||||||
|
$(".output").append("<a id='" + item.sl_id + "' class='collection-item'>" + item.name + "</a>")
|
||||||
|
}
|
||||||
|
|
||||||
|
},
|
||||||
|
error(err) {
|
||||||
|
console.error("Error: " + err);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}).catch((error) => console.error("Get id token client error: ", error));
|
||||||
|
} else {
|
||||||
|
console.log("Check Auth error", user)
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
$(document).on("click", ".collection-item", function () {
|
||||||
|
id = $(this).closest("a").attr("id");
|
||||||
|
|
||||||
|
$(".active").removeClass("active");
|
||||||
|
|
||||||
|
$(this).addClass("active");
|
||||||
|
});
|
||||||
|
|
||||||
|
$(".btncont").click(function () {
|
||||||
|
run([{
|
||||||
|
y: 100
|
||||||
|
}, {
|
||||||
|
y: 0
|
||||||
|
}], $(".r1"));
|
||||||
|
});
|
||||||
|
|
||||||
|
function run(v, elem) {
|
||||||
|
//Reverse the array
|
||||||
|
var reversed = JSON.parse(JSON.stringify(v)).reverse();
|
||||||
|
|
||||||
|
$(v[0]).animate(v[1], {
|
||||||
|
//The speed the element moves - lower is faster
|
||||||
|
duration: 500,
|
||||||
|
step: function (val) {
|
||||||
|
//Adding the transform to your element
|
||||||
|
elem.css("transform", `translateY(${val}%)`);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
};
|
||||||
|
|
||||||
|
$(".opt1").click(function () {
|
||||||
|
run([{
|
||||||
|
y: 0
|
||||||
|
}, {
|
||||||
|
y: -100
|
||||||
|
}], $(".r1"))
|
||||||
|
|
||||||
|
run([{
|
||||||
|
y: 0
|
||||||
|
}, {
|
||||||
|
y: -100
|
||||||
|
}], $(".r2"));
|
||||||
|
//$("#modal2").modal("open");
|
||||||
|
});
|
||||||
|
|
||||||
|
$(".opt2").click(function () {
|
||||||
|
// $('.row').animate({'margin-top': '-100%'}, 1000);
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -228,5 +263,4 @@ var loading = false;
|
|||||||
$(".determinate").css("width", "0%");
|
$(".determinate").css("width", "0%");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
@ -1,9 +1,4 @@
|
|||||||
var admin = require('firebase-admin');
|
|
||||||
var serviceAccount = require('../login/firebaseAdminKey.json');
|
|
||||||
var firebaseAdmin = admin.initializeApp({
|
|
||||||
credential: admin.credential.cert(serviceAccount),
|
|
||||||
databaseURL: 'https://test-667ca.firebaseio.com'
|
|
||||||
});
|
|
||||||
|
|
||||||
function sendPush(msgtoken, title, text){
|
function sendPush(msgtoken, title, text){
|
||||||
var message = {
|
var message = {
|
||||||
|
@ -8,58 +8,46 @@ var push = require("./../push/push");
|
|||||||
var postgres = require("./../db-connect/db-connect");
|
var postgres = require("./../db-connect/db-connect");
|
||||||
|
|
||||||
|
|
||||||
// Initialize Firebase
|
var admin = require('firebase-admin');
|
||||||
// const config = {
|
var serviceAccount = require('../login/firebaseAdminKey.json');
|
||||||
// apiKey: "AIzaSyCuvwf78cmSDoZ2yS4XxHZhnjUn7yIHYfw",
|
var firebaseAdmin = admin.initializeApp({
|
||||||
// authDomain: "test-667ca.firebaseapp.com",
|
credential: admin.credential.cert(serviceAccount),
|
||||||
// databaseURL: "https://test-667ca.firebaseio.com",
|
databaseURL: 'https://test-667ca.firebaseio.com'
|
||||||
// projectId: "test-667ca",
|
});
|
||||||
// storageBucket: "test-667ca.appspot.com",
|
|
||||||
// messagingSenderId: "221332577314"
|
|
||||||
// };
|
|
||||||
// firebase.initializeApp(config);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//Push
|
//Push
|
||||||
router.get('/push/:msgtoken/:message/:title', function (req, res, next) {
|
router.get('/push/:msgtoken/:message/:title', function (req, res, next) {
|
||||||
push.sendPush(req.params.msgtoken, req.params.title, req.params.message);
|
push.sendPush(req.params.msgtoken, req.params.title, req.params.message);
|
||||||
var sender = "Message Token: " + req.params.msgtoken + " Message: " + req.params.message + " Title: " + req.params.title;
|
var sender = "Message Token: " + req.params.msgtoken + " Message: " + req.params.message + " Title: " + req.params.title;
|
||||||
res.status(200).send(sender);
|
res.status(200).send(sender);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
// Login und Dash
|
// Login und Dash
|
||||||
router.get('/', function(req, res, next) {
|
router.get('/', function (req, res, next) {
|
||||||
res.render('index');
|
res.render('index');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
router.get('/dash/:idtoken', function(req, res, next) {
|
router.get('/dash/:idtoken', function (req, res, next) {
|
||||||
// const msgtoken = req.params.msgtoken;
|
// const msgtoken = req.params.msgtoken;
|
||||||
const token = req.params.idtoken;
|
const token = req.params.idtoken;
|
||||||
var uid;
|
var uid;
|
||||||
firebaseAdmin.auth().verifyIdToken(token)
|
firebaseAdmin.auth().verifyIdToken(token)
|
||||||
.then(function(decodedToken) {
|
.then(function (decodedToken) {
|
||||||
uid = decodedToken.uid;
|
uid = decodedToken.uid;
|
||||||
// HIER WEITER MACHEN
|
// HIER WEITER MACHEN
|
||||||
// uid ist nur hier drinen verfügbar
|
// uid ist nur hier drinen verfügbar
|
||||||
|
|
||||||
|
|
||||||
}).catch(function(error) {
|
}).catch(function (error) {
|
||||||
console.log(error)
|
console.log(error)
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
res.render('dash');
|
res.render('dash');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
@ -67,27 +55,25 @@ router.get('/dash/:idtoken', function(req, res, next) {
|
|||||||
|
|
||||||
//GET Own shoppinglists as JSON
|
//GET Own shoppinglists as JSON
|
||||||
|
|
||||||
router.get("/myshoppinglists",async function(req, res, next) {
|
router.get("/myshoppinglists", async function (req, res, next) {
|
||||||
var token = req.query.idtoken;
|
var token = req.query.idtoken;
|
||||||
console.log("/myshoppinglists idtoken: ", token)
|
console.log("/myshoppinglists idtoken: ", token)
|
||||||
firebaseAdmin.auth().verifyIdToken(token)
|
firebaseAdmin.auth().verifyIdToken(token)
|
||||||
.then(async function(decodedToken) {
|
.then(async function (decodedToken) {
|
||||||
uid = decodedToken.uid;
|
uid = decodedToken.uid;
|
||||||
console.log("uid", uid)
|
console.log("uid", uid)
|
||||||
try {
|
try {
|
||||||
//Get user id: req.session.passport.user.profile.id
|
//Get user id: req.session.passport.user.profile.id
|
||||||
res.status(200).send(await postgres.getShoppinglistsAdmin(uid));
|
res.status(200).send(await postgres.getShoppinglistsAdmin(uid));
|
||||||
}
|
} catch (err) {
|
||||||
|
|
||||||
catch(err) {
|
|
||||||
res.status(400).send(await err);
|
res.status(400).send(await err);
|
||||||
}
|
}
|
||||||
|
|
||||||
}).catch(function(error) {
|
}).catch(function (error) {
|
||||||
console.log(error)
|
console.log(error)
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
//Test Funktion für Android, liefert die FirebaseAdmin Skd UID
|
//Test Funktion für Android, liefert die FirebaseAdmin Skd UID
|
||||||
@ -108,97 +94,89 @@ router.get("/myshoppinglists",async function(req, res, next) {
|
|||||||
|
|
||||||
//GET Shared shoppinglists as JSON
|
//GET Shared shoppinglists as JSON
|
||||||
|
|
||||||
router.get("/sharedshoppinglists", async function(req, res, next) {
|
router.get("/sharedshoppinglists", async function (req, res, next) {
|
||||||
var token = req.query.idtoken;
|
var token = req.query.idtoken;
|
||||||
firebaseAdmin.auth().verifyIdToken(token)
|
firebaseAdmin.auth().verifyIdToken(token)
|
||||||
.then(async function(decodedToken) {
|
.then(async function (decodedToken) {
|
||||||
uid = decodedToken.uid;
|
uid = decodedToken.uid;
|
||||||
console.log("uid", uid)
|
console.log("uid", uid)
|
||||||
try {
|
try {
|
||||||
//Get user id: req.session.passport.user.profile.id
|
//Get user id: req.session.passport.user.profile.id
|
||||||
res.status(200).send(await postgres.getShoppinglistsShared(uid));
|
res.status(200).send(await postgres.getShoppinglistsShared(uid));
|
||||||
}
|
} catch (err) {
|
||||||
|
|
||||||
catch(err) {
|
|
||||||
res.status(400).send(await err);
|
res.status(400).send(await err);
|
||||||
}
|
}
|
||||||
|
|
||||||
}).catch(function(error) {
|
}).catch(function (error) {
|
||||||
console.log(error)
|
console.log(error)
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
//GET ALL SHOPPINGLISTS
|
//GET ALL SHOPPINGLISTS
|
||||||
|
|
||||||
router.get("/shoppinglistsbylink", async function(req, res, next) {
|
router.get("/shoppinglistsbylink", async function (req, res, next) {
|
||||||
var token = req.query.idtoken;
|
var token = req.query.idtoken;
|
||||||
firebaseAdmin.auth().verifyIdToken(token)
|
firebaseAdmin.auth().verifyIdToken(token)
|
||||||
.then(async function(decodedToken) {
|
.then(async function (decodedToken) {
|
||||||
uid = decodedToken.uid;
|
uid = decodedToken.uid;
|
||||||
console.log("uid", uid)
|
console.log("uid", uid)
|
||||||
try {
|
try {
|
||||||
//Get user id: req.session.passport.user.profile.id
|
//Get user id: req.session.passport.user.profile.id
|
||||||
res.status(200).send(await postgres.getShoppinglistsByLink(req.query.link));
|
res.status(200).send(await postgres.getShoppinglistsByLink(req.query.link));
|
||||||
}
|
} catch (err) {
|
||||||
|
|
||||||
catch(err) {
|
|
||||||
res.status(400).send(await err);
|
res.status(400).send(await err);
|
||||||
}
|
}
|
||||||
|
|
||||||
}).catch(function(error) {
|
}).catch(function (error) {
|
||||||
console.log(error)
|
console.log(error)
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
//POST new shoppinglist
|
//POST new shoppinglist
|
||||||
|
|
||||||
router.post("/shoppinglist", async function(req, res, next) {
|
router.post("/shoppinglist", async function (req, res, next) {
|
||||||
console.log("/shoppinglist idtoken: ", req.body.idtoken)
|
console.log("/shoppinglist idtoken: ", req.body.idtoken)
|
||||||
var token = req.body.idtoken;
|
var token = req.body.idtoken;
|
||||||
|
|
||||||
var uid;
|
var uid;
|
||||||
firebaseAdmin.auth().verifyIdToken(token)
|
firebaseAdmin.auth().verifyIdToken(token)
|
||||||
.then(async function(decodedToken) {
|
.then(async function (decodedToken) {
|
||||||
uid = decodedToken.uid;
|
uid = decodedToken.uid;
|
||||||
console.log("UID: ", uid);
|
console.log("UID: ", uid);
|
||||||
console.log("So andere sachen: ", req.body.name, req.body.description);
|
console.log("So andere sachen: ", req.body.name, req.body.description);
|
||||||
try {
|
try {
|
||||||
|
|
||||||
res.status(200).send(await postgres.newShoppinglist(req.body.name, req.body.description, uid, req.body.color));
|
res.status(200).send(await postgres.newShoppinglist(req.body.name, req.body.description, uid, req.body.color));
|
||||||
sendPush("enG4tJ6LyyU:APA91bEYjUEs7Sdzvu2ivgfqtpzlg42BZLlujDSRg0WLBvfZ_oD4V7cTx2o6MVr4oAdeHaK0wttPMQ85GMMOkgM7xvbHFcwXUG4MCr8JXX16S-OV2CS4ikQ286DOHPtBotbM7pqFTvIM", "Einkaufsliste " + req.body.name + " wurde erstellt!", req.body.description)
|
sendPush("enG4tJ6LyyU:APA91bEYjUEs7Sdzvu2ivgfqtpzlg42BZLlujDSRg0WLBvfZ_oD4V7cTx2o6MVr4oAdeHaK0wttPMQ85GMMOkgM7xvbHFcwXUG4MCr8JXX16S-OV2CS4ikQ286DOHPtBotbM7pqFTvIM", "Einkaufsliste " + req.body.name + " wurde erstellt!", req.body.description)
|
||||||
}
|
} catch (err) {
|
||||||
|
|
||||||
catch(err) {
|
|
||||||
res.status(400).send(await err);
|
res.status(400).send(await err);
|
||||||
}
|
}
|
||||||
}).catch(function(error) {
|
}).catch(function (error) {
|
||||||
console.log(error)
|
console.log(error)
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
//GET Shoppinglist detail
|
//GET Shoppinglist detail
|
||||||
|
|
||||||
router.get("/shoppinglist_json/:sl_id", async (req, res) => {
|
router.get("/shoppinglist_json/:sl_id", async (req, res) => {
|
||||||
var token = req.query.idtoken;
|
var token = req.query.idtoken;
|
||||||
var uid;
|
var uid;
|
||||||
firebaseAdmin.auth().verifyIdToken(token)
|
firebaseAdmin.auth().verifyIdToken(token)
|
||||||
.then(async function(decodedToken) {
|
.then(async function (decodedToken) {
|
||||||
uid = decodedToken.uid;
|
uid = decodedToken.uid;
|
||||||
console.log("UID: ", uid);
|
console.log("UID: ", uid);
|
||||||
try {
|
try {
|
||||||
res.status(200).send(await postgres.displayShoppinglist(req.params.sl_id));
|
res.status(200).send(await postgres.displayShoppinglist(req.params.sl_id));
|
||||||
}
|
} catch (err) {
|
||||||
|
|
||||||
catch(err) {
|
|
||||||
res.status(400).send(await err);
|
res.status(400).send(await err);
|
||||||
}
|
}
|
||||||
}).catch(function(error) {
|
}).catch(function (error) {
|
||||||
console.log(error)
|
console.log(error)
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
@ -210,41 +188,34 @@ postgres.displayShoppinglist("4tezJYMK");
|
|||||||
router.delete("/shoppinglist", async (req, res) => {
|
router.delete("/shoppinglist", async (req, res) => {
|
||||||
try {
|
try {
|
||||||
res.status(200).send(await postgres.deleteShoppinglist(req.body.sl_id));
|
res.status(200).send(await postgres.deleteShoppinglist(req.body.sl_id));
|
||||||
sendPush("enG4tJ6LyyU:APA91bEYjUEs7Sdzvu2ivgfqtpzlg42BZLlujDSRg0WLBvfZ_oD4V7cTx2o6MVr4oAdeHaK0wttPMQ85GMMOkgM7xvbHFcwXUG4MCr8JXX16S-OV2CS4ikQ286DOHPtBotbM7pqFTvIM", "Die Einkaufsliste " + req.body.sl_id + " wurde gelöscht!", "Einkaufsliste wurde geändert")
|
} catch (err) {
|
||||||
}
|
|
||||||
|
|
||||||
catch(err) {
|
|
||||||
res.status(400).send(await err);
|
res.status(400).send(await err);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
//Group erstellen
|
//Group erstellen
|
||||||
|
|
||||||
router.post("/group", async (req, res) => {
|
router.post("/group", async (req, res) => {
|
||||||
try {
|
try {
|
||||||
res.status(200).send(await postgres.addGroup(req.body.sl_id, req.body.name, req.body.color, req.body.hidden));
|
res.status(200).send(await postgres.addGroup(req.body.sl_id, req.body.name, req.body.color, req.body.hidden));
|
||||||
}
|
} catch (err) {
|
||||||
|
|
||||||
catch(err) {
|
|
||||||
res.status(400).send(await err);
|
res.status(400).send(await err);
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
//Item erstellen
|
//Item erstellen
|
||||||
|
|
||||||
router.post("/item", async (req, res) => {
|
router.post("/item", async (req, res) => {
|
||||||
try {
|
try {
|
||||||
res.status(200).send(await postgres.addItem(req.body.group_id, req.body.sl_id, req.body.name, req.body.count));
|
res.status(200).send(await postgres.addItem(req.body.group_id, req.body.sl_id, req.body.name, req.body.count));
|
||||||
}
|
} catch (err) {
|
||||||
|
|
||||||
catch (err) {
|
|
||||||
res.status(400).send(await err);
|
res.status(400).send(await err);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
router.get("/test1", (req, res) => {
|
router.get("/test1", (req, res) => {
|
||||||
res.render("test");
|
res.render("test");
|
||||||
});
|
});
|
||||||
|
|
||||||
router.get("/userinfo_json", (req, res) => {
|
router.get("/userinfo_json", (req, res) => {
|
||||||
@ -252,9 +223,9 @@ router.get("/userinfo_json", (req, res) => {
|
|||||||
|
|
||||||
console.log("/userinfo_json idtoken: ", token)
|
console.log("/userinfo_json idtoken: ", token)
|
||||||
firebaseAdmin.auth().verifyIdToken(token)
|
firebaseAdmin.auth().verifyIdToken(token)
|
||||||
.then(function(decodedToken) {
|
.then(function (decodedToken) {
|
||||||
res.send(decodedToken);
|
res.send(decodedToken);
|
||||||
}).catch(function(error) {
|
}).catch(function (error) {
|
||||||
console.log(error)
|
console.log(error)
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -263,9 +234,7 @@ router.get("/userinfo_json", (req, res) => {
|
|||||||
router.put("/shoppinglist", async (req, res) => {
|
router.put("/shoppinglist", async (req, res) => {
|
||||||
try {
|
try {
|
||||||
res.status(200).send(await postgres.editShoppinglist(req.body.sl_id, req.body.name, req.body.description, req.body.color));
|
res.status(200).send(await postgres.editShoppinglist(req.body.sl_id, req.body.name, req.body.description, req.body.color));
|
||||||
}
|
} catch (err) {
|
||||||
|
|
||||||
catch(err) {
|
|
||||||
res.status(400).send(await err);
|
res.status(400).send(await err);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -275,9 +244,7 @@ router.put("/shoppinglist", async (req, res) => {
|
|||||||
router.put("/group", async (req, res) => {
|
router.put("/group", async (req, res) => {
|
||||||
try {
|
try {
|
||||||
res.status(200).send(await postgres.editGroup(req.body.sl_id, req.body.group_id, req.body.name, req.body.color, req.body.hidden));
|
res.status(200).send(await postgres.editGroup(req.body.sl_id, req.body.group_id, req.body.name, req.body.color, req.body.hidden));
|
||||||
}
|
} catch (err) {
|
||||||
|
|
||||||
catch(err) {
|
|
||||||
res.status(400).send(await err);
|
res.status(400).send(await err);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -285,29 +252,23 @@ router.put("/group", async (req, res) => {
|
|||||||
router.put("/item", async (req, res) => {
|
router.put("/item", async (req, res) => {
|
||||||
try {
|
try {
|
||||||
res.status(200).send(await postgres.editItem(req.body.sl_id, req.body.group_id, req.body.item_id, req.body.name, req.body.count));
|
res.status(200).send(await postgres.editItem(req.body.sl_id, req.body.group_id, req.body.item_id, req.body.name, req.body.count));
|
||||||
}
|
} catch (err) {
|
||||||
|
|
||||||
catch(err) {
|
|
||||||
res.status(400).send(await err);
|
res.status(400).send(await err);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
router.delete("/group", async(req, res) => {
|
router.delete("/group", async (req, res) => {
|
||||||
try {
|
try {
|
||||||
res.status(200).send(await postgres.deleteGroup(req.body.group_id, req.body.sl_id));
|
res.status(200).send(await postgres.deleteGroup(req.body.group_id, req.body.sl_id));
|
||||||
}
|
} catch (err) {
|
||||||
|
|
||||||
catch(err) {
|
|
||||||
res.status(400).send(await err);
|
res.status(400).send(await err);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
router.delete("/item", async(req, res) => {
|
router.delete("/item", async (req, res) => {
|
||||||
try {
|
try {
|
||||||
res.status(200).send(await postgres.deleteItem(req.body.item_id, req.body.group.id, req.body.sl_id));
|
res.status(200).send(await postgres.deleteItem(req.body.item_id, req.body.group.id, req.body.sl_id));
|
||||||
}
|
} catch (err) {
|
||||||
|
|
||||||
catch(err) {
|
|
||||||
res.status(400).send(await err);
|
res.status(400).send(await err);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -317,9 +278,7 @@ router.delete("/item", async(req, res) => {
|
|||||||
router.post("/invite", async (req, res) => {
|
router.post("/invite", async (req, res) => {
|
||||||
try {
|
try {
|
||||||
res.status(200).send(await postgres.createInvite(req.body.sl_id));
|
res.status(200).send(await postgres.createInvite(req.body.sl_id));
|
||||||
}
|
} catch (err) {
|
||||||
|
|
||||||
catch(err) {
|
|
||||||
res.status(400).send(await err);
|
res.status(400).send(await err);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -327,9 +286,7 @@ router.post("/invite", async (req, res) => {
|
|||||||
router.post("/maninvite", async (req, res) => {
|
router.post("/maninvite", async (req, res) => {
|
||||||
try {
|
try {
|
||||||
res.status(200).send(await postgres.manInvite(req.body.sl_id, req.body.uid));
|
res.status(200).send(await postgres.manInvite(req.body.sl_id, req.body.uid));
|
||||||
}
|
} catch (err) {
|
||||||
|
|
||||||
catch(err) {
|
|
||||||
res.status(400).send(err);
|
res.status(400).send(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -339,9 +296,7 @@ router.post("/maninvite", async (req, res) => {
|
|||||||
router.delete("/member", (req, res) => {
|
router.delete("/member", (req, res) => {
|
||||||
try {
|
try {
|
||||||
postgres.removeMember(req.body.uid, req.body.sl_id)
|
postgres.removeMember(req.body.uid, req.body.sl_id)
|
||||||
}
|
} catch (err) {
|
||||||
|
|
||||||
catch(err) {
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -355,56 +310,50 @@ router.post("/invitemember", (req, res) => {
|
|||||||
var token = req.body.idtoken;
|
var token = req.body.idtoken;
|
||||||
var uid;
|
var uid;
|
||||||
firebaseAdmin.auth().verifyIdToken(token)
|
firebaseAdmin.auth().verifyIdToken(token)
|
||||||
.then(async function(decodedToken) {
|
.then(async function (decodedToken) {
|
||||||
uid = decodedToken.uid;
|
uid = decodedToken.uid;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
console.log("Route LInk inv", req.body.link);
|
console.log("Route LInk inv", req.body.link);
|
||||||
res.status(200).send(await postgres.verifyInvite(req.body.link, uid));
|
res.status(200).send(await postgres.verifyInvite(req.body.link, uid));
|
||||||
}
|
} catch (err) {
|
||||||
|
|
||||||
catch(err) {
|
|
||||||
res.status(400).send(await err);
|
res.status(400).send(await err);
|
||||||
}
|
}
|
||||||
}).catch(function(error) {
|
}).catch(function (error) {
|
||||||
console.log(error)
|
console.log(error)
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
//Update User
|
//Update User
|
||||||
|
|
||||||
router.post("/user", async function(req, res, next) {
|
router.post("/user", async function (req, res, next) {
|
||||||
console.log("/shoppinglist idtoken: ", req.body.idtoken)
|
console.log("/shoppinglist idtoken: ", req.body.idtoken)
|
||||||
var token = req.body.idtoken;
|
var token = req.body.idtoken;
|
||||||
|
|
||||||
var uid;
|
var uid;
|
||||||
firebaseAdmin.auth().verifyIdToken(token)
|
firebaseAdmin.auth().verifyIdToken(token)
|
||||||
.then(async function(decodedToken) {
|
.then(async function (decodedToken) {
|
||||||
uid = decodedToken.uid;
|
uid = decodedToken.uid;
|
||||||
console.log("UID: ", uid);
|
console.log("UID: ", uid);
|
||||||
console.log("So andere sachen: ", req.body.name, req.body.description);
|
console.log("So andere sachen: ", req.body.name, req.body.description);
|
||||||
try {
|
try {
|
||||||
|
|
||||||
res.status(200).send(await postgres.updateUser(uid, req.body.message_id, decodedToken.name, decodedToken.picture, decodedToken.email));
|
res.status(200).send(await postgres.updateUser(uid, req.body.message_id, decodedToken.name, decodedToken.picture, decodedToken.email));
|
||||||
}
|
} catch (err) {
|
||||||
|
|
||||||
catch(err) {
|
|
||||||
res.status(400).send(await err);
|
res.status(400).send(await err);
|
||||||
}
|
}
|
||||||
}).catch(function(error) {
|
}).catch(function (error) {
|
||||||
console.log(error)
|
console.log(error)
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
router.get("/users", async (req, res) => {
|
router.get("/users", async (req, res) => {
|
||||||
try {
|
try {
|
||||||
res.status(200).send(await postgres.searchUsers(req.query.search));
|
res.status(200).send(await postgres.searchUsers(req.query.search));
|
||||||
}
|
} catch (err) {
|
||||||
|
|
||||||
catch(err) {
|
|
||||||
res.status(400).send(err);
|
res.status(400).send(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
@ -417,19 +366,17 @@ router.post("/donepurchases", (req, res) => {
|
|||||||
var token = req.query.idtoken;
|
var token = req.query.idtoken;
|
||||||
var uid;
|
var uid;
|
||||||
firebaseAdmin.auth().verifyIdToken(token)
|
firebaseAdmin.auth().verifyIdToken(token)
|
||||||
.then(async function(decodedToken) {
|
.then(async function (decodedToken) {
|
||||||
uid = decodedToken.uid;
|
uid = decodedToken.uid;
|
||||||
try {
|
try {
|
||||||
console.log("test");
|
console.log("test");
|
||||||
}
|
} catch (err) {
|
||||||
|
|
||||||
catch(err) {
|
|
||||||
console.error(error);
|
console.error(error);
|
||||||
}
|
}
|
||||||
}).catch( async function(error) {
|
}).catch(async function (error) {
|
||||||
console.log(error)
|
console.log(error)
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
@ -438,53 +385,49 @@ router.get("/donepurchases", (req, res) => {
|
|||||||
var token = req.query.idtoken;
|
var token = req.query.idtoken;
|
||||||
var uid;
|
var uid;
|
||||||
firebaseAdmin.auth().verifyIdToken(token)
|
firebaseAdmin.auth().verifyIdToken(token)
|
||||||
.then(async function(decodedToken) {
|
.then(async function (decodedToken) {
|
||||||
uid = decodedToken.uid;
|
uid = decodedToken.uid;
|
||||||
try {
|
try {
|
||||||
res.status(200).send(await postgres.getDonePurchases(uid));
|
res.status(200).send(await postgres.getDonePurchases(uid));
|
||||||
}
|
} catch (err) {
|
||||||
|
|
||||||
catch(err) {
|
|
||||||
res.status(400).send(await err);
|
res.status(400).send(await err);
|
||||||
}
|
}
|
||||||
}).catch( async function(error) {
|
}).catch(async function (error) {
|
||||||
console.log(error)
|
console.log(error)
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
//OCR Scan
|
//OCR Scan
|
||||||
|
|
||||||
|
|
||||||
router.get("/scan/", async (req, res,) => {
|
router.get("/scan/", async (req, res, ) => {
|
||||||
res.render("ocrscan");
|
res.render("ocrscan");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
router.post("/dones", async function(req, res, next) {
|
router.post("/dones", async function (req, res, next) {
|
||||||
console.log("/shoppinglist idtoken: ", req.body.idtoken)
|
console.log("/shoppinglist idtoken: ", req.body.idtoken)
|
||||||
var token = req.body.idtoken;
|
var token = req.body.idtoken;
|
||||||
|
|
||||||
var uid;
|
var uid;
|
||||||
firebaseAdmin.auth().verifyIdToken(token)
|
firebaseAdmin.auth().verifyIdToken(token)
|
||||||
.then(async function(decodedToken) {
|
.then(async function (decodedToken) {
|
||||||
uid = decodedToken.uid;
|
uid = decodedToken.uid;
|
||||||
console.log("UID: ", uid);
|
console.log("UID: ", uid);
|
||||||
console.log("So andere sachen: ", req.body.name, req.body.description);
|
console.log("So andere sachen: ", req.body.name, req.body.description);
|
||||||
try {
|
try {
|
||||||
|
|
||||||
res.status(200).send(await postgres.moveDoneItems(uid, req.body.sl_id, req.body.billcontent));
|
res.status(200).send(await postgres.moveDoneItems(uid, req.body.sl_id, req.body.billcontent));
|
||||||
}
|
} catch (err) {
|
||||||
|
|
||||||
catch(err) {
|
|
||||||
res.status(400).send(await err);
|
res.status(400).send(await err);
|
||||||
}
|
}
|
||||||
}).catch(function(error) {
|
}).catch(function (error) {
|
||||||
console.log(error)
|
console.log(error)
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
module.exports = router;
|
|
||||||
|
|
||||||
|
module.exports = router;
|
@ -2,8 +2,8 @@ var express = require('express');
|
|||||||
var router = express.Router();
|
var router = express.Router();
|
||||||
|
|
||||||
/* GET users listing. */
|
/* GET users listing. */
|
||||||
router.get('/', function(req, res, next) {
|
router.get('/', function (req, res, next) {
|
||||||
res.send('respond with a resource');
|
res.send('respond with a resource');
|
||||||
});
|
});
|
||||||
|
|
||||||
module.exports = router;
|
module.exports = router;
|
@ -1,13 +1,15 @@
|
|||||||
#!/usr/bin/env node
|
#!/usr/bin/env node
|
||||||
|
|
||||||
var Greenlock = require('../');
|
var Greenlock = require('../');
|
||||||
var greenlock = Greenlock.create({
|
var greenlock = Greenlock.create({
|
||||||
version: 'draft-11'
|
version: 'draft-11',
|
||||||
, server: 'https://acme-staging-v02.api.letsencrypt.org/directory'
|
server: 'https://acme-staging-v02.api.letsencrypt.org/directory',
|
||||||
, agreeTos: true
|
agreeTos: true,
|
||||||
, approvedDomains: [ 'example.com', 'www.example.com' ]
|
approvedDomains: ['example.com', 'www.example.com'],
|
||||||
, configDir: require('path').join(require('os').tmpdir(), 'acme')
|
configDir: require('path').join(require('os').tmpdir(), 'acme')
|
||||||
|
|
||||||
, app: require('express')().use('/', function (req, res) {
|
,
|
||||||
|
app: require('express')().use('/', function (req, res) {
|
||||||
res.setHeader('Content-Type', 'text/html; charset=utf-8');
|
res.setHeader('Content-Type', 'text/html; charset=utf-8');
|
||||||
res.end('Hello, World!\n\n💚 🔒.js');
|
res.end('Hello, World!\n\n💚 🔒.js');
|
||||||
})
|
})
|
||||||
@ -72,4 +74,4 @@ var server5 = greenlock.listen(10080, 10443, function () {
|
|||||||
|
|
||||||
var server6 = greenlock.listen('[::]:11080', '[::1]:11443');
|
var server6 = greenlock.listen('[::]:11080', '[::1]:11443');
|
||||||
|
|
||||||
var server7 = greenlock.listen('/tmp/gl.plain.sock', '/tmp/gl.sec.sock');
|
var server7 = greenlock.listen('/tmp/gl.plain.sock', '/tmp/gl.sec.sock');
|
@ -1,36 +0,0 @@
|
|||||||
|
|
||||||
<script src="https://www.gstatic.com/firebasejs/5.7.0/firebase.js"></script>
|
|
||||||
|
|
||||||
|
|
||||||
<script >
|
|
||||||
|
|
||||||
// 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);
|
|
||||||
|
|
||||||
console.log("EJS TEst: ", "<%= customtoken%>")
|
|
||||||
firebase.auth().signInWithCustomToken("<%= customtoken%>").then(function(response){
|
|
||||||
firebase.auth().getIdToken(/* forceRefresh */ ).then(function(idToken) {
|
|
||||||
console.log("IDTOKEN: ", idToken)
|
|
||||||
window.location.replace('/dash/'+ idToken);
|
|
||||||
}).catch(function(error) {
|
|
||||||
console.error("token error: ", error)
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
}).catch(function(error) {
|
|
||||||
// Handle Errors here.
|
|
||||||
var errorCode = error.code;
|
|
||||||
var errorMessage = error.message;
|
|
||||||
console.error("Custom token error: ", error.message)
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
</script>
|
|
@ -1,16 +1,19 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
|
||||||
|
<head>
|
||||||
<title></title>
|
<title></title>
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
||||||
<link rel='stylesheet' href='/stylesheets/style.css'>
|
<link rel='stylesheet' href='/stylesheets/style.css'>
|
||||||
<link rel='stylesheet' href='/stylesheets/colorpicker-style.css'>
|
<link rel='stylesheet' href='/stylesheets/colorpicker-style.css'>
|
||||||
<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="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'>
|
<link rel='stylesheet' href='/bootstrap/dist/css/bootstrap.min.css'>
|
||||||
<script src="https://www.gstatic.com/firebasejs/5.7.0/firebase.js"></script>
|
<script src="https://www.gstatic.com/firebasejs/5.7.0/firebase.js"></script>
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
<body id="vue-app">
|
|
||||||
|
<body id="vue-app">
|
||||||
|
|
||||||
<!-- Navbar -->
|
<!-- Navbar -->
|
||||||
<nav class="navbar sticky-top navbar-light bg-light" style="background-color:rgb(200, 200, 201)">
|
<nav class="navbar sticky-top navbar-light bg-light" style="background-color:rgb(200, 200, 201)">
|
||||||
@ -21,12 +24,13 @@
|
|||||||
</a>
|
</a>
|
||||||
<ul class="nav justify-content-end liste">
|
<ul class="nav justify-content-end liste">
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<!-- <a class="nav-link active" href="#">Add</a> -->
|
<!-- <a class="nav-link active" href="#">Add</a> -->
|
||||||
<button class="btn btn-outline-light border-secondary sl_add" style="color: black">Shoppingliste Hinzufügen</button>
|
<button class="btn btn-outline-light border-secondary sl_add" style="color: black">Shoppingliste
|
||||||
|
Hinzufügen</button>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
<!-- <a href="/logout"> -->
|
<!-- <a href="/logout"> -->
|
||||||
<button class="btn btn-outline-light border-secondary logout" style="color: black">Logout</button>
|
<button class="btn btn-outline-light border-secondary logout" style="color: black">Logout</button>
|
||||||
<!-- </a> -->
|
<!-- </a> -->
|
||||||
</nav>
|
</nav>
|
||||||
<br>
|
<br>
|
||||||
@ -50,71 +54,74 @@
|
|||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<!-- Modal Group Hinzufügen -->
|
<!-- Modal Group Hinzufügen -->
|
||||||
<div class="modal fade bd-example-modal-sm ListenDetailAdd" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">
|
<div class="modal fade bd-example-modal-sm ListenDetailAdd" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel"
|
||||||
|
aria-hidden="true">
|
||||||
<div class="modal-dialog modal-sm">
|
<div class="modal-dialog modal-sm">
|
||||||
<div class="modal-content">
|
<div class="modal-content">
|
||||||
<div>
|
<div>
|
||||||
|
|
||||||
<center><p class="layout ueberschrift">Group hinzufügen</p></center>
|
<center>
|
||||||
|
<p class="layout ueberschrift">Group hinzufügen</p>
|
||||||
|
</center>
|
||||||
<div class="form-group layout">
|
<div class="form-group layout">
|
||||||
<label for="exampleInputEmail1">Name</label>
|
<label for="exampleInputEmail1">Name</label>
|
||||||
<input type="text" class="form-control" id="groupname"placeholder="zB: Getränke">
|
<input type="text" class="form-control" id="groupname" placeholder="zB: Getränke">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group layout">
|
<div class="form-group layout">
|
||||||
<label for="exampleInputPassword1">Farbe</label>
|
<label for="exampleInputPassword1">Farbe</label>
|
||||||
<div class="farbeeen">
|
<div class="farbeeen">
|
||||||
|
|
||||||
<input type="radio" name="color" id="farbe1" value="F44336" />
|
|
||||||
<label for="farbe1"><span class="farbe1 border"></span></label>
|
|
||||||
|
|
||||||
<input type="radio" name="color" id="farbe2" value="e91e63" />
|
|
||||||
<label for="farbe2"><span class="farbe2"></span></label>
|
|
||||||
|
|
||||||
<input type="radio" name="color" id="farbe3" value="9c27b0" />
|
|
||||||
<label for="farbe3"><span class="farbe3"></span></label>
|
|
||||||
|
|
||||||
<input type="radio" name="color" id="farbe4" value="673ab7" />
|
|
||||||
<label for="farbe4"><span class="farbe4"></span></label>
|
|
||||||
|
|
||||||
<input type="radio" name="color" id="farbe5" value="3F51B5" />
|
|
||||||
<label for="farbe5"><span class="farbe5"></span></label>
|
|
||||||
|
|
||||||
<input type="radio" name="color" id="farbe6" value="2196F3" />
|
|
||||||
<label for="farbe6"><span class="farbe6"></span></label>
|
|
||||||
|
|
||||||
<br>
|
<input type="radio" name="color" id="farbe1" value="F44336" />
|
||||||
|
<label for="farbe1"><span class="farbe1 border"></span></label>
|
||||||
<input type="radio" name="color" id="farbe7" value="03a9f4" />
|
|
||||||
<label for="farbe7"><span class="farbe7"></span></label>
|
|
||||||
|
|
||||||
<input type="radio" name="color" id="farbe8" value="00bcd4" />
|
|
||||||
<label for="farbe8"><span class="farbe8"></span></label>
|
|
||||||
|
|
||||||
<input type="radio" name="color" id="farbe9" value="009688" />
|
|
||||||
<label for="farbe9"><span class="farbe9"></span></label>
|
|
||||||
|
|
||||||
<input type="radio" name="color" id="farbe10" value="4caf50" />
|
<input type="radio" name="color" id="farbe2" value="e91e63" />
|
||||||
<label for="farbe10"><span class="farbe10"></span></label>
|
<label for="farbe2"><span class="farbe2"></span></label>
|
||||||
|
|
||||||
<input type="radio" name="color" id="farbe11" value="8bc34a" />
|
<input type="radio" name="color" id="farbe3" value="9c27b0" />
|
||||||
<label for="farbe11"><span class="farbe11"></span></label>
|
<label for="farbe3"><span class="farbe3"></span></label>
|
||||||
|
|
||||||
<input type="radio" name="color" id="farbe12" value="cddc39" />
|
<input type="radio" name="color" id="farbe4" value="673ab7" />
|
||||||
<label for="farbe12"><span class="farbe12"></span></label>
|
<label for="farbe4"><span class="farbe4"></span></label>
|
||||||
|
|
||||||
|
<input type="radio" name="color" id="farbe5" value="3F51B5" />
|
||||||
|
<label for="farbe5"><span class="farbe5"></span></label>
|
||||||
|
|
||||||
|
<input type="radio" name="color" id="farbe6" value="2196F3" />
|
||||||
|
<label for="farbe6"><span class="farbe6"></span></label>
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
|
<input type="radio" name="color" id="farbe7" value="03a9f4" />
|
||||||
|
<label for="farbe7"><span class="farbe7"></span></label>
|
||||||
|
|
||||||
|
<input type="radio" name="color" id="farbe8" value="00bcd4" />
|
||||||
|
<label for="farbe8"><span class="farbe8"></span></label>
|
||||||
|
|
||||||
|
<input type="radio" name="color" id="farbe9" value="009688" />
|
||||||
|
<label for="farbe9"><span class="farbe9"></span></label>
|
||||||
|
|
||||||
|
<input type="radio" name="color" id="farbe10" value="4caf50" />
|
||||||
|
<label for="farbe10"><span class="farbe10"></span></label>
|
||||||
|
|
||||||
|
<input type="radio" name="color" id="farbe11" value="8bc34a" />
|
||||||
|
<label for="farbe11"><span class="farbe11"></span></label>
|
||||||
|
|
||||||
|
<input type="radio" name="color" id="farbe12" value="cddc39" />
|
||||||
|
<label for="farbe12"><span class="farbe12"></span></label>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<center><button type="submit" class="btn btn-outline-dark gruppenadd">Hinzufügen</button></center>
|
<center><button type="submit" class="btn btn-outline-dark gruppenadd">Hinzufügen</button></center>
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -122,33 +129,36 @@
|
|||||||
|
|
||||||
|
|
||||||
<!-- Modal Item Hinzufügen -->
|
<!-- Modal Item Hinzufügen -->
|
||||||
<div class="modal fade bd-example-modal-sm GroupItemAdd" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">
|
<div class="modal fade bd-example-modal-sm GroupItemAdd" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel"
|
||||||
|
aria-hidden="true">
|
||||||
<div class="modal-dialog modal-sm">
|
<div class="modal-dialog modal-sm">
|
||||||
<div class="modal-content">
|
<div class="modal-content">
|
||||||
<div class="inhalt">
|
<div class="inhalt">
|
||||||
|
|
||||||
<center><p class="layout ueberschrift">Item hinzufügen</p></center>
|
<center>
|
||||||
|
<p class="layout ueberschrift">Item hinzufügen</p>
|
||||||
|
</center>
|
||||||
<div class="form-group layout">
|
<div class="form-group layout">
|
||||||
<label for="exampleInputEmail1">Gegenstand</label>
|
<label for="exampleInputEmail1">Gegenstand</label>
|
||||||
<input type="text" class="form-control" id="itemname" placeholder="zB: Coca Cola">
|
<input type="text" class="form-control" id="itemname" placeholder="zB: Coca Cola">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group layout">
|
<div class="form-group layout">
|
||||||
<label for="Anzahl-example">Anzahl</label>
|
<label for="Anzahl-example">Anzahl</label>
|
||||||
<select class="custom-select" id="inputGroupSelect01">
|
<select class="custom-select" id="inputGroupSelect01">
|
||||||
<option value="1">1</option>
|
<option value="1">1</option>
|
||||||
<option value="2">2</option>
|
<option value="2">2</option>
|
||||||
<option value="3">3</option>
|
<option value="3">3</option>
|
||||||
<option value="4">4</option>
|
<option value="4">4</option>
|
||||||
<option value="5">5</option>
|
<option value="5">5</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group layout">
|
<div class="form-group layout">
|
||||||
<label for="Group-select">Group</label>
|
<label for="Group-select">Group</label>
|
||||||
<select class="custom-select custom-select-groups" id="inputGroupSelect02">
|
<select class="custom-select custom-select-groups" id="inputGroupSelect02">
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<center><button type="submit" class="btn btn-outline-dark itemhinzu">Hinzufügen</button></center>
|
<center><button type="submit" class="btn btn-outline-dark itemhinzu">Hinzufügen</button></center>
|
||||||
<br>
|
<br>
|
||||||
@ -158,66 +168,67 @@
|
|||||||
|
|
||||||
|
|
||||||
<!-- Modal Shoppingliste Hinzufügen -->
|
<!-- Modal Shoppingliste Hinzufügen -->
|
||||||
<div class="modal fade bd-example-modal-sm EigeneListeAdd" tabindex="-1" id="EigeneListeAdd" role="dialog" aria-labelledby="EigeneListeAdd" aria-hidden="true">
|
<div class="modal fade bd-example-modal-sm EigeneListeAdd" tabindex="-1" id="EigeneListeAdd" role="dialog"
|
||||||
|
aria-labelledby="EigeneListeAdd" aria-hidden="true">
|
||||||
<div class="modal-dialog modal-sm">
|
<div class="modal-dialog modal-sm">
|
||||||
<div class="modal-content">
|
<div class="modal-content">
|
||||||
<div>
|
<div>
|
||||||
|
|
||||||
<div class="form-group layout">
|
<div class="form-group layout">
|
||||||
<label for="exampleInputEmail1">Name</label>
|
<label for="exampleInputEmail1">Name</label>
|
||||||
<input type="text" class="form-control" id="einkaufslistenname"placeholder="zB: Billa">
|
<input type="text" class="form-control" id="einkaufslistenname" placeholder="zB: Billa">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group layout">
|
<div class="form-group layout">
|
||||||
<label for="exampleInputPassword1">Beschreibung</label>
|
<label for="exampleInputPassword1">Beschreibung</label>
|
||||||
<input type="text" class="form-control" id="einkaufslistenbeschreibung" placeholder="zB: Großeinkauf bei Billa">
|
<input type="text" class="form-control" id="einkaufslistenbeschreibung" placeholder="zB: Großeinkauf bei Billa">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group layout">
|
<div class="form-group layout">
|
||||||
<label for="exampleInputPassword1">Farbe</label>
|
<label for="exampleInputPassword1">Farbe</label>
|
||||||
<div class="farbeeen">
|
<div class="farbeeen">
|
||||||
|
|
||||||
<input type="radio" name="color" id="farbe1" value="F44336" />
|
<input type="radio" name="color" id="farbe1" value="F44336" />
|
||||||
<label for="farbe1"><span class="farbe1 border"></span></label>
|
<label for="farbe1"><span class="farbe1 border"></span></label>
|
||||||
|
|
||||||
<input type="radio" name="color" id="farbe2" value="e91e63" />
|
<input type="radio" name="color" id="farbe2" value="e91e63" />
|
||||||
<label for="farbe2"><span class="farbe2"></span></label>
|
<label for="farbe2"><span class="farbe2"></span></label>
|
||||||
|
|
||||||
<input type="radio" name="color" id="farbe3" value="9c27b0" />
|
<input type="radio" name="color" id="farbe3" value="9c27b0" />
|
||||||
<label for="farbe3"><span class="farbe3"></span></label>
|
<label for="farbe3"><span class="farbe3"></span></label>
|
||||||
|
|
||||||
<input type="radio" name="color" id="farbe4" value="673ab7" />
|
<input type="radio" name="color" id="farbe4" value="673ab7" />
|
||||||
<label for="farbe4"><span class="farbe4"></span></label>
|
<label for="farbe4"><span class="farbe4"></span></label>
|
||||||
|
|
||||||
<input type="radio" name="color" id="farbe5" value="3F51B5" />
|
<input type="radio" name="color" id="farbe5" value="3F51B5" />
|
||||||
<label for="farbe5"><span class="farbe5"></span></label>
|
<label for="farbe5"><span class="farbe5"></span></label>
|
||||||
|
|
||||||
<input type="radio" name="color" id="farbe6" value="2196F3" />
|
<input type="radio" name="color" id="farbe6" value="2196F3" />
|
||||||
<label for="farbe6"><span class="farbe6"></span></label>
|
<label for="farbe6"><span class="farbe6"></span></label>
|
||||||
|
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||
<input type="radio" name="color" id="farbe7" value="03a9f4" />
|
<input type="radio" name="color" id="farbe7" value="03a9f4" />
|
||||||
<label for="farbe7"><span class="farbe7"></span></label>
|
<label for="farbe7"><span class="farbe7"></span></label>
|
||||||
|
|
||||||
<input type="radio" name="color" id="farbe8" value="00bcd4" />
|
<input type="radio" name="color" id="farbe8" value="00bcd4" />
|
||||||
<label for="farbe8"><span class="farbe8"></span></label>
|
<label for="farbe8"><span class="farbe8"></span></label>
|
||||||
|
|
||||||
<input type="radio" name="color" id="farbe9" value="009688" />
|
<input type="radio" name="color" id="farbe9" value="009688" />
|
||||||
<label for="farbe9"><span class="farbe9"></span></label>
|
<label for="farbe9"><span class="farbe9"></span></label>
|
||||||
|
|
||||||
<input type="radio" name="color" id="farbe10" value="4caf50" />
|
<input type="radio" name="color" id="farbe10" value="4caf50" />
|
||||||
<label for="farbe10"><span class="farbe10"></span></label>
|
<label for="farbe10"><span class="farbe10"></span></label>
|
||||||
|
|
||||||
<input type="radio" name="color" id="farbe11" value="8bc34a" />
|
<input type="radio" name="color" id="farbe11" value="8bc34a" />
|
||||||
<label for="farbe11"><span class="farbe11"></span></label>
|
<label for="farbe11"><span class="farbe11"></span></label>
|
||||||
|
|
||||||
<input type="radio" name="color" id="farbe12" value="cddc39" />
|
<input type="radio" name="color" id="farbe12" value="cddc39" />
|
||||||
<label for="farbe12"><span class="farbe12"></span></label>
|
<label for="farbe12"><span class="farbe12"></span></label>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<center><button type="submit" class="btn btn-outline-dark add">Hinzufügen</button></center>
|
<center><button type="submit" class="btn btn-outline-dark add">Hinzufügen</button></center>
|
||||||
<br>
|
<br>
|
||||||
@ -240,5 +251,6 @@
|
|||||||
<script src="https://unpkg.com/ionicons@4.4.8/dist/ionicons.js"></script>
|
<script src="https://unpkg.com/ionicons@4.4.8/dist/ionicons.js"></script>
|
||||||
<script src="/javascripts/test.js"></script>
|
<script src="/javascripts/test.js"></script>
|
||||||
<script src="/javascripts/firebase-app.js"></script>
|
<script src="/javascripts/firebase-app.js"></script>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
@ -1,3 +1,7 @@
|
|||||||
<h1><%= message %></h1>
|
<h1>
|
||||||
<h2><%= error.status %></h2>
|
<%= message %>
|
||||||
<pre><%= error.stack %></pre>
|
</h1>
|
||||||
|
<h2>
|
||||||
|
<%= error.status %>
|
||||||
|
</h2>
|
||||||
|
<pre><%= error.stack %></pre>
|
@ -1,22 +1,31 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
|
||||||
|
|
||||||
<link rel='stylesheet' href='/stylesheets/style.css' />
|
<head>
|
||||||
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
|
|
||||||
|
|
||||||
<script src="https://www.gstatic.com/firebasejs/5.7.0/firebase.js"></script>
|
|
||||||
|
|
||||||
</head>
|
<link rel='stylesheet' href='/stylesheets/style.css' />
|
||||||
<body>
|
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
|
||||||
|
|
||||||
<div id='vue-app'>
|
<script src="https://www.gstatic.com/firebasejs/5.7.0/firebase.js"></script>
|
||||||
|
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<div id='vue-app'>
|
||||||
|
|
||||||
|
<input v-model="email" id="email" type="email">
|
||||||
|
<input v-model="password" id="password" type="password">
|
||||||
|
<button id="loginemailbutton" @click="loginemail()">Login with Email</button>
|
||||||
|
|
||||||
|
{{email}}
|
||||||
|
|
||||||
<button id="loginbutton" @click="login()">Login with google</button>
|
<button id="loginbutton" @click="login()">Login with google</button>
|
||||||
|
|
||||||
|
|
||||||
<script src="javascripts/login.js"></script>
|
<script src="javascripts/login.js"></script>
|
||||||
|
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
|
||||||
|
</html>
|
@ -1,5 +1,6 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
@ -9,13 +10,13 @@
|
|||||||
<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
|
<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
|
||||||
|
|
||||||
<script src="https://www.gstatic.com/firebasejs/5.7.0/firebase.js"></script>
|
<script src="https://www.gstatic.com/firebasejs/5.7.0/firebase.js"></script>
|
||||||
|
|
||||||
<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
|
<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
|
||||||
<script src="/invite/inv.js"></script>
|
<script src="/invite/inv.js"></script>
|
||||||
|
|
||||||
<link rel="stylesheet" href="/invite/style.css">
|
<link rel="stylesheet" href="/invite/style.css">
|
||||||
|
|
||||||
|
|
||||||
<!--Import Google Icon Font-->
|
<!--Import Google Icon Font-->
|
||||||
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
|
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
|
||||||
|
|
||||||
@ -29,6 +30,7 @@
|
|||||||
<!-- Compiled and minified JavaScript -->
|
<!-- Compiled and minified JavaScript -->
|
||||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js"></script>
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js"></script>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
|
|
||||||
@ -49,9 +51,10 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
@ -53,4 +53,4 @@
|
|||||||
|
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
@ -2,87 +2,91 @@
|
|||||||
<html lang="en">
|
<html lang="en">
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
||||||
<title>Document</title>
|
<title>Document</title>
|
||||||
|
|
||||||
<script src="https://www.gstatic.com/firebasejs/5.7.0/firebase.js"></script>
|
<script src="https://www.gstatic.com/firebasejs/5.7.0/firebase.js"></script>
|
||||||
|
|
||||||
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
|
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
|
||||||
<script src="/ocrscan/axios.js"></script>
|
<script src="/ocrscan/axios.js"></script>
|
||||||
|
|
||||||
<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
|
<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
|
||||||
|
|
||||||
<script src='https://cdn.jsdelivr.net/gh/naptha/tesseract.js@v1.0.14/dist/tesseract.min.js'></script>
|
<script src='https://cdn.jsdelivr.net/gh/naptha/tesseract.js@v1.0.14/dist/tesseract.min.js'></script>
|
||||||
|
|
||||||
<!--Import Google Icon Font-->
|
<!--Import Google Icon Font-->
|
||||||
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
|
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
|
||||||
|
|
||||||
|
|
||||||
<!--Let browser know website is optimized for mobile-->
|
<!--Let browser know website is optimized for mobile-->
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
|
|
||||||
<!-- Compiled and minified CSS -->
|
<!-- Compiled and minified CSS -->
|
||||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css">
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css">
|
||||||
|
|
||||||
<!-- Compiled and minified JavaScript -->
|
<!-- Compiled and minified JavaScript -->
|
||||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js"></script>
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js"></script>
|
||||||
|
|
||||||
<link rel="stylesheet" href="ocrscan/style.css">
|
<link rel="stylesheet" href="ocrscan/style.css">
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
<div class="row r1">
|
<div class="row r1">
|
||||||
<div class="col s12 m6 l6 opt1 waves-effect waves-dark" >
|
<div class="col s12 m6 l6 opt1 waves-effect waves-dark">
|
||||||
<center><i class="material-icons ico" >file_upload</i></center>
|
<center><i class="material-icons ico">file_upload</i></center>
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="col s12 m6 l6 opt2 waves-effect waves-dark" onclick="M.toast({html: 'Not yet available'})">
|
|
||||||
|
|
||||||
<center><i class="material-icons ico">camera</i></center>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="row r2">
|
<div class="col s12 m6 l6 opt2 waves-effect waves-dark" onclick="M.toast({html: 'Not yet available'})">
|
||||||
<div class="container">
|
|
||||||
<div class="file-field input-field">
|
<center><i class="material-icons ico">camera</i></center>
|
||||||
<div class="btn deep-orange darken-1 btn-choose waves-effect waves-light">
|
</div>
|
||||||
<span>Choose Image</span>
|
</div>
|
||||||
<input type='file' onchange="readURL(this);" />
|
|
||||||
</div>
|
<div class="row r2">
|
||||||
<div class="file-path-wrapper">
|
<div class="container">
|
||||||
</div>
|
<div class="file-field input-field">
|
||||||
|
<div class="btn deep-orange darken-1 btn-choose waves-effect waves-light">
|
||||||
|
<span>Choose Image</span>
|
||||||
|
<input type='file' onchange="readURL(this);" />
|
||||||
|
</div>
|
||||||
|
<div class="file-path-wrapper">
|
||||||
</div>
|
</div>
|
||||||
<center><img id="blah" src="#" alt="" /></center>
|
|
||||||
</div>
|
</div>
|
||||||
|
<center><img id="blah" src="#" alt="" /></center>
|
||||||
<center><button class="btn waves-effect waves-light deep-orange darken-1 disabled btn-analyze " type="submit" name="action">Continue<i class="material-icons right">send</i></button></center>
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<center><button class="btn waves-effect waves-light deep-orange darken-1 disabled btn-analyze " type="submit" name="action">Continue<i
|
||||||
|
class="material-icons right">send</i></button></center>
|
||||||
|
|
||||||
|
</div>
|
||||||
<div class="fixed-action-btn">
|
|
||||||
|
|
||||||
|
|
||||||
|
<div class="fixed-action-btn">
|
||||||
<a class="btn-floating btn-large btndash">
|
<a class="btn-floating btn-large btndash">
|
||||||
<i class="large material-icons blue-grey darken-4">arrow_back</i>
|
<i class="large material-icons blue-grey darken-4">arrow_back</i>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<!-- Modal Structure PRE -->
|
<!-- Modal Structure PRE -->
|
||||||
<div id="modal1" class="modal">
|
<div id="modal1" class="modal">
|
||||||
<div class="modal-content">
|
<div class="modal-content">
|
||||||
<h4>Choose Shoppinglist</h4>
|
<h4>Choose Shoppinglist</h4>
|
||||||
<center> <div class="preloader-wrapper big active">
|
<center>
|
||||||
|
<div class="preloader-wrapper big active">
|
||||||
<div class="spinner-layer spinner-blue-only">
|
<div class="spinner-layer spinner-blue-only">
|
||||||
<div class="circle-clipper left">
|
<div class="circle-clipper left">
|
||||||
<div class="circle"></div>
|
<div class="circle"></div>
|
||||||
</div><div class="gap-patch">
|
</div>
|
||||||
|
<div class="gap-patch">
|
||||||
<div class="circle"></div>
|
<div class="circle"></div>
|
||||||
</div><div class="circle-clipper right">
|
</div>
|
||||||
|
<div class="circle-clipper right">
|
||||||
<div class="circle"></div>
|
<div class="circle"></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -90,52 +94,53 @@
|
|||||||
</center>
|
</center>
|
||||||
<div class="collection output">
|
<div class="collection output">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
<a class="modal-close waves-effect waves-red btn-flat btndash">Return to Dashboard</a>
|
<a class="modal-close waves-effect waves-red btn-flat btndash">Return to Dashboard</a>
|
||||||
<a class="modal-close waves-effect waves-green btn-flat btncont">Continue</a>
|
<a class="modal-close waves-effect waves-green btn-flat btncont">Continue</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Modal Structure IMPORT -->
|
<!-- Modal Structure IMPORT -->
|
||||||
<div id="modal2" class="modal">
|
<div id="modal2" class="modal">
|
||||||
<div class="modal-content">
|
<div class="modal-content">
|
||||||
<h4>Import Image</h4>
|
<h4>Import Image</h4>
|
||||||
|
|
||||||
<div class="file-field input-field">
|
<div class="file-field input-field">
|
||||||
<div class="btn">
|
<div class="btn">
|
||||||
<span>File</span>
|
<span>File</span>
|
||||||
<input type='file' onchange="readURL(this);" />
|
<input type='file' onchange="readURL(this);" />
|
||||||
</div>
|
|
||||||
<div class="file-path-wrapper">
|
|
||||||
<input class="file-path validate" type="text" placeholder="Upload one or more files">
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<img class="materialboxed" id="blah" src="#" alt="your image" />
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer">
|
<div class="file-path-wrapper">
|
||||||
<a class="modal-close waves-effect waves-red btn-flat btndash">Return to Dashboard</a>
|
<input class="file-path validate" type="text" placeholder="Upload one or more files">
|
||||||
<a href="#!" class="modal-close waves-effect waves-green btn-flat btnanalyze">Remove Items</a>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<img class="materialboxed" id="blah" src="#" alt="your image" />
|
||||||
|
|
||||||
<!-- Modal Structure PRELOADER END-->
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<a class="modal-close waves-effect waves-red btn-flat btndash">Return to Dashboard</a>
|
||||||
|
<a href="#!" class="modal-close waves-effect waves-green btn-flat btnanalyze">Remove Items</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Modal Structure PRELOADER END-->
|
||||||
<div id="modalEND" class="modal">
|
<div id="modalEND" class="modal">
|
||||||
<div class="modal-content">
|
<div class="modal-content">
|
||||||
<center> <div class="progress">
|
<center>
|
||||||
<div class="indeterminate"></div>
|
<div class="progress">
|
||||||
|
<div class="indeterminate"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</center>
|
</center>
|
||||||
<p>Loading ...</p>
|
<p>Loading ...</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<script src="/ocrscan/cam.js"></script>
|
<script src="/ocrscan/cam.js"></script>
|
||||||
<script src="/ocrscan/ocrscan.js"></script>
|
<script src="/ocrscan/ocrscan.js"></script>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user