Initial location view
Signed-off-by: James Ketrenos <james_eikona@ketrenos.com>
This commit is contained in:
parent
d06a3e6846
commit
641fb29e16
@ -14,6 +14,44 @@ function Group() {
|
||||
const groupId = useParams().group;
|
||||
const [ group, setGroup ] = useState(null);
|
||||
const [ error, setError ] = useState(null);
|
||||
const [ locations, setLocations ] = useState([]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!user) {
|
||||
return;
|
||||
}
|
||||
|
||||
const effect = async () => {
|
||||
const res = await window.fetch(
|
||||
`${base}/api/v1/locations/`, {
|
||||
method: 'GET',
|
||||
cache: 'no-cache',
|
||||
credentials: 'same-origin',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'CSRF-Token': csrfToken
|
||||
}
|
||||
});
|
||||
const data = await res.json();
|
||||
if (res.status >= 400) {
|
||||
setError(data.message ? data.message : res.statusText);
|
||||
return;
|
||||
}
|
||||
if (!data) {
|
||||
return;
|
||||
}
|
||||
setLocations(data.map(location => {
|
||||
const fields = Object.getOwnPropertyNames(location)
|
||||
.map(field => <div key={field}>
|
||||
<div>{field}</div>
|
||||
<div>{location[field]}</div>
|
||||
</div>);
|
||||
return <div key={location.id}>{ fields }</div>;
|
||||
}));
|
||||
};
|
||||
effect();
|
||||
}, [user, setGroup, groupId, csrfToken]);
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
if (!user || !groupId || !csrfToken) {
|
||||
@ -22,7 +60,7 @@ function Group() {
|
||||
|
||||
const effect = async () => {
|
||||
const res = await window.fetch(
|
||||
`${base}/api/v1/group/${groupId}/events`, {
|
||||
`${base}/api/v1/groups/${groupId}/events`, {
|
||||
method: 'POST',
|
||||
cache: 'no-cache',
|
||||
credentials: 'same-origin',
|
||||
@ -35,7 +73,7 @@ function Group() {
|
||||
if (res.status >= 400) {
|
||||
setError(data.message ? data.message : res.statusText);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (!data) {
|
||||
return;
|
||||
}
|
||||
@ -48,6 +86,8 @@ function Group() {
|
||||
<Paper className="Group">
|
||||
<GlobalContext.Provider value={{user, setUser}}>
|
||||
Group: {groupId}
|
||||
<div>Locations</div>
|
||||
{ locations }
|
||||
</GlobalContext.Provider>
|
||||
</Paper>
|
||||
);
|
||||
|
@ -61,12 +61,29 @@ goodTimesDB.init().then((db) => {
|
||||
app.locals.db = db;
|
||||
app.set('basePath', basePath);
|
||||
|
||||
app.use(`${basePath}api/v1/groups`, require('./routes/groups'));
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
app.use((req, _res, next) => {
|
||||
console.log(
|
||||
`${req.method} ${req.path} - ` +
|
||||
`${req.session.userId ? req.session.userId : 'Not logged in'}`
|
||||
);
|
||||
next();
|
||||
});
|
||||
app.use(`${basePath}api/v1/users`, require('./routes/users'));
|
||||
app.use((req, res, next) => {
|
||||
if (!req.session.userId) {
|
||||
return res.status(401).send({ message: `You must be logged in.` });
|
||||
}
|
||||
next();
|
||||
});
|
||||
app.use(`${basePath}api/v1/groups`, require('./routes/groups'));
|
||||
app.use(`${basePath}api/v1/events`, require('./routes/events'));
|
||||
app.use(`${basePath}api/v1/locations`, require('./routes/locations'));
|
||||
|
||||
/* Error handler and catch for 404 */
|
||||
app.use(methodOverride());
|
||||
app.use((err, req, res, next) => {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
app.use((err, req, res, _next) => {
|
||||
console.log('CSRF debug: ', {
|
||||
token: req.header('CSRF-Token'),
|
||||
csrf: req.csrfToken(),
|
||||
|
115
server/db.js
115
server/db.js
@ -17,6 +17,12 @@ function init() {
|
||||
autoIncrement: true
|
||||
},
|
||||
name: Sequelize.STRING,
|
||||
description: Sequelize.STRING,
|
||||
public: {
|
||||
type: Sequelize.BOOLEAN,
|
||||
allowNull: false,
|
||||
defaultValue: true
|
||||
},
|
||||
ownerId: Sequelize.INTEGER
|
||||
}, {
|
||||
timestamps: false,
|
||||
@ -47,6 +53,33 @@ function init() {
|
||||
timestamps: false
|
||||
});
|
||||
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const Location = db.sequelize.define('locations', {
|
||||
id: {
|
||||
type: Sequelize.INTEGER,
|
||||
primaryKey: true,
|
||||
autoIncrement: true
|
||||
},
|
||||
groupId: {
|
||||
type: Sequelize.INTEGER,
|
||||
allowNull: false,
|
||||
references: {
|
||||
model: Group,
|
||||
key: 'id'
|
||||
}
|
||||
},
|
||||
name: Sequelize.STRING,
|
||||
location: Sequelize.STRING,
|
||||
map: Sequelize.STRING,
|
||||
url: Sequelize.STRING,
|
||||
note: Sequelize.STRING,
|
||||
disabled: Sequelize.BOOLEAN,
|
||||
beerlist: Sequelize.STRING,
|
||||
added: Sequelize.DATE
|
||||
}, {
|
||||
timestamps: false
|
||||
});
|
||||
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const Authentication = db.sequelize.define('authentication', {
|
||||
key: {
|
||||
@ -72,7 +105,7 @@ function init() {
|
||||
});
|
||||
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const GroupUsers = db.sequelize.define('groupuser', {
|
||||
const GroupUsers = db.sequelize.define('groupusers', {
|
||||
groupId: {
|
||||
type: Sequelize.INTEGER,
|
||||
allowNull: false,
|
||||
@ -93,6 +126,86 @@ function init() {
|
||||
timestamps: false
|
||||
});
|
||||
|
||||
const Event = db.sequelize.define('events', {
|
||||
id: {
|
||||
type: Sequelize.INTEGER,
|
||||
primaryKey: true,
|
||||
autoIncrement: true
|
||||
},
|
||||
groupId: {
|
||||
type: Sequelize.INTEGER,
|
||||
allowNull: false,
|
||||
references: {
|
||||
model: Group,
|
||||
key: 'id'
|
||||
}
|
||||
},
|
||||
date: Sequelize.DATE
|
||||
}, {
|
||||
timestamps: false
|
||||
});
|
||||
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const EventVote = db.sequelize.define('eventvotes', {
|
||||
eventId: {
|
||||
type: Sequelize.INTEGER,
|
||||
allowNull: false,
|
||||
references: {
|
||||
model: Event,
|
||||
key: 'id'
|
||||
}
|
||||
},
|
||||
userId: {
|
||||
type: Sequelize.INTEGER,
|
||||
allowNull: false,
|
||||
references: {
|
||||
model: User,
|
||||
key: 'id'
|
||||
}
|
||||
},
|
||||
locationId: {
|
||||
type: Sequelize.INTEGER,
|
||||
allowNull: false,
|
||||
references: {
|
||||
model: Location,
|
||||
key: 'id'
|
||||
}
|
||||
},
|
||||
rating: Sequelize.INTEGER,
|
||||
submitted: Sequelize.DATE
|
||||
}, {
|
||||
timestamps: false
|
||||
});
|
||||
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const Attendance = db.sequelize.define('attendees', {
|
||||
eventId: {
|
||||
type: Sequelize.INTEGER,
|
||||
allowNull: false,
|
||||
references: {
|
||||
model: Event,
|
||||
key: 'id'
|
||||
}
|
||||
},
|
||||
userId: {
|
||||
type: Sequelize.INTEGER,
|
||||
allowNull: false,
|
||||
references: {
|
||||
model: User,
|
||||
key: 'id'
|
||||
}
|
||||
},
|
||||
state: {
|
||||
type: {
|
||||
type: Sequelize.ENUM,
|
||||
values: ['unknown', 'in', 'out']
|
||||
}
|
||||
},
|
||||
note: Sequelize.STRING
|
||||
}, {
|
||||
timestamps: false
|
||||
});
|
||||
|
||||
return db.sequelize.sync({
|
||||
force: false
|
||||
}).then(function () {
|
||||
|
32
server/location-data.js
Normal file
32
server/location-data.js
Normal file
@ -0,0 +1,32 @@
|
||||
module.exports = [{'id':1,'name':'CPR','location':'Cornelius Pass & Imbrie Dr ','map':'http://goo.gl/maps/ANsh2','url':'','note':'Cornelius Pass Roadhouse; standard McMenamin food and drinks. The Rubinator (Ruby + Terminator) is a common favorite, as are the rotating nitro offerings.\n\nHappy hour foods aren\'t that thrilling; tots, fries, etc.','disabled':0,'beerlist':''},
|
||||
{'id':2,'name':'Orenco Taphouse','location':'Couple blocks off Cornell in Orenco Station area.','map':'http://goo.gl/maps/qoOxl','url':'http://orencotaphouse.com','note':'A wide variety of frequently changing taps; a good place to have a beer or two. \n\nNo food or appetizers, or happy hour pricing. If its crowded, or the TVs are all on, it can be a little loud...','disabled':0,'beerlist':'http://orencotaphouse.com/?page_id=5'},
|
||||
{'id':3,'name':'Dugout','location':'Just down the street from Jones Farm, across Cornell in the strip mall near the Dollar Store','map':'https://goo.gl/HXc5oq','url':'https://www.facebook.com/TheDugoutGourmetDeliBeerBarInc','note':'','disabled':0,'beerlist':''},
|
||||
{'id':4,'name':'Raccoon Lodge','location':'Beaverton Hillsdale Hwy a couple miles east of 217.','map':'http://goo.gl/maps/fbFAa','url':'http://www.raclodge.com','note':'OMG! The fruit beers! This is the west-side spot to drink Cascade Brewing\'s various beers. In addition to the sours, they have a wide variety of other beer types.\n\nHappy hour prices aren\'t that great, and only apply to the "standard" Cascade Brewing beers--not the sours :(','disabled':0,'beerlist':'http://www.raclodge.com/PDFs/cascade_brewing_ales_new.do.do.do.doc_oct_20.3.1.docuse.doc.docx'},
|
||||
{'id':5,'name':'OHBP','location':'Cornell Rd just north of Hwy 26','map':'http://goo.gl/maps/mGwul','url':'','note':'Conveniently located for most of America, the Oak Hills Brew Pub is a regional favorite. This is due primarily to the number of people that either live near it, or drive by it on their way home.\n\nA small McMenamin pub, OHBP offers the same food and beverage listings as the others from the local pub chain.','disabled':0,'beerlist':''},
|
||||
{'id':6,'name':'Golden Valley Brewing','location':'Just south of 26 on Bethany.','map':'','url':'http://www.goldenvalleybrewery.com','note':'','disabled':0,'beerlist':'http://www.goldenvalleybrewery.com/beer/'},
|
||||
{'id':7,'name':'Monteaux\'s Public House','location':'A quarter mile west of the 158th and Walker Rd intersection in Beaverton (across Walker from Fred Meyer.)','map':'http://goo.gl/maps/Oubb0','url':'http://www.monteauxs.com','note':'With good food, and happy hour running from 3-6, Monteaux\'s is a good place to kick back and have a pint with some friends (or co-workers; whichever you have available.)','disabled':1,'beerlist':'http://www.taplister.com/bars/410c3280f964a520ad0b1fe3'},
|
||||
{'id':8,'name':'Coyote\'s','location':'','map':'','url':'','note':'','disabled':0,'beerlist':''},
|
||||
{'id':9,'name':'Bugatti\'s','location':'','map':'','url':'','note':'','disabled':0,'beerlist':''},
|
||||
{'id':10,'name':'BJ\'s','location':'Cornell Rd near the intersection with Cornelius Pass Rd.','map':'http://goo.gl/maps/o5wJc','url':'','note':'A few really good beers (Tatonka Stout) and some tasty appetizers. Plus Tuesday gets you half off wine. What\'s not to like?\n\nReasonably located for most of the world, BJ\'s has climbed the ladder as a frequent Beer Tuesday target.','disabled':0,'beerlist':''},
|
||||
{'id':11,'name':'Oregon Brewer\'s Festival','location':'Downtown Portland (waterfront)','map':'http://goo.gl/maps/jb622','url':'http://oregonbrewfest.com','note':'Instead of the July 23rd (or in addition to), add a Beer Thursday for the 25th.\n\nWe\'ll head down *early* afternoon to beat the crowds.','disabled':1,'beerlist':''},
|
||||
{'id':12,'name':'Tug Boat','location':'Downtown, a block from Burnside on Ankeny (just off of Broadway)','map':'http://goo.gl/maps/I83Oj','url':'http://www.d2m.com/tugwebsite/','note':'A "quaint" location, Tug Boat offers a reasonable set of beers in a unique setting. Its a great spot to finish a downtown hack session at the Collective Agency.','disabled':0,'beerlist':'http://www.taplister.com/bars/40b13b00f964a5200df61ee3'},
|
||||
{'id':13,'name':'Deschutes Brewery','location':'Downtown Bend. And more conveniently located on 11th a block off Burnside next to Powell\'s Books.','map':'http://goo.gl/maps/2r2Eh','url':'http://www.deschutesbrewery.com/locations/portland','note':'Beer. Good, wholesome, beer. Obsidian Stout on Nitro. Can\'t go wrong there, unless you don\'t like stout... if that be the case, mayhaps you\'d prefer the Chainbreaker or Mirror Pond. Or even one of the seasonals on tap. A good location after a day at the Collective Agency, or any other reason to be downtown.','disabled':0,'beerlist':'http://www.deschutesbrewery.com/on-tap/portland'},
|
||||
{'id':14,'name':'Ridge Pub','location':'Progress Ridge, between Ava Roasteria and Cinetopia.','map':'http://goo.gl/maps/Uckva','url':'http://www.theridgepub.com/','note':'A good location if you\'ll be catching an evening show at Cinetopia, or if you happen to be heading toward Tigard for any reason.','disabled':0,'beerlist':''},
|
||||
{'id':15,'name':'Stanford\'s','location':'Off of 185th and Cornell, walking distance from the Evergreen theater.','map':'http://goo.gl/maps/NKLOI','url':'http://www.stanfords.com','note':'Tasty appetizers with happy hour running to 6pm. The Wood-Fire Grilled Portobello\nMushroom is awesome.','disabled':0,'beerlist':'http://www.stanfords.com/menu.php?c=tanasbourne&id=Bar%20Menu'},
|
||||
{'id':16,'name':'Old Chicago','location':'Along Evergreen Parkway, between 185th and Cornell.','map':'http://goo.gl/maps/Blj9U','url':'http://oldchicago.com/locations/beaverton-tanasbourne?action=view','note':'A reasonable establishment to share a pint or two with your fellow coworker. Old Chicago has some tasty food, and a wide variety of beers, some ciders, and other beverages.','disabled':0,'beerlist':'http://oldchicago.com/beverages/hand-crafted-beers'},
|
||||
{'id':17,'name':'Rock Creek','location':'A couple minutes north of highway 26 on Cornelius Pass Rd','map':'http://goo.gl/maps/NwYhC','url':'http://www.mcmenamins.com/RockCreek','note':'McMenamin Ales. Good friends. Nice building. A win all around, especially if you hang round until the Blue Grass kicks in at 7PM on Tuesdays.','disabled':0,'beerlist':'http://www.mcmenamins.com/532-rock-creek-tavern-ales'},
|
||||
{'id':18,'name':'Thirsty Lion - Tanasbourne','location':'In the Streets of Tanasbourne, just minutes from shopping, beer, and food.','map':'https://maps.google.com/maps?q=2290+NW+Allie+Avenue,+Hillsboro,+Oregon+97124&hl=en&sll=37.6,-95.665&sspn=60.181414,50.185547&hnear=2290+NW+Allie+Ave,+Hillsboro,+Oregon+97124&t=m&z=16','url':'https://www.facebook.com/thirstyliontanasbourne','note':'A gastropub. Reasonable food. Good beers. Fun times.','disabled':0,'beerlist':'http://thirstylionpub.com/tanasbourne/menu'},
|
||||
{'id':19,'name':'Metropolitan Bistro & Bar','location':'In the small commercial complex where Baseline turns into Jenkins, just east of 170th you will find the Metropolitan Bistro & Bar, previously known as Mireille\'s Bistro. It\'s quaint, quiet, and the service is friendly. Worth hanging out on an afternoon.','map':'https://maps.google.com/maps?q=16755+SW+Baseline+Rd.,+Beaverton,+Oregon+97006&hl=en&ll=45.512106,-122.849207&spn=0.0103,0.022123&sll=45.512001,-122.849596&sspn=0.001295,0.002765&hnear=16755+SW+Baseline+Rd,+Beaverton,+Oregon+97006&t=m&z=16','url':'https://www.facebook.com/mireillesbistro','note':'It isn\'t a brewery or pub, and doesn\'t have the largest beer selection. However it is nice and quiet, and the staff is very friendly.\n\nThe food is pretty good too.\n\n*AND* Tuesday night is Trivia night (6:30-8:00)!','disabled':1,'beerlist':'http://www.beermenus.com/places/10862-mireille-s-bistro'},
|
||||
{'id':20,'name':'ABV Public House','location':'Conveniently located just a rock\'s throw from the corner of Brookwood and Hwy 26. ','map':'http://goo.gl/maps/WwjDT','url':'http://www.abvpub.com/','note':'Fantabulous! Recently opened, this brew pub / tap house is sure to become the next big thing for Beer Tuesday. Check out the chicken fried portobello mushroom sandwich. ','disabled':0,'beerlist':'http://www.abvpub.com/taps/'},
|
||||
{'id':21,'name':'Three Mugs Brewing Company','location':'Right behind Brew Brothers just off Cornelius Pass Road, south of Hwy 26 and kitty corner from Kohls.','map':'https://maps.google.com/maps?q=2020+NW+Aloclek+Dr+Ste+108,+Hillsboro,+Oregon&hl=en&sll=45.532072,-122.935317&sspn=0.165705,0.306931&hnear=2020+NW+Aloclek+Dr+%23108,+Hillsboro,+Oregon+97124&t=m&z=16','url':'http://www.threemugsbrewing.com/','note':'Beers, Ciders, however no food...','disabled':0,'beerlist':'http://www.threemugsbrewingco.com/#!about2/c166u'},
|
||||
{'id':22,'name':'APEX','location':'Just 30 minutes from the farm (without traffic) and you\'re there! -- 1216 SE Division St.','map':'http://tinyurl.com/koldwj5','url':'http://www.apexbar.com/','note':'If it\'s beer you want, it\'s beer they have! A bit of a jug from the farm, however they have the juice that will cure what ales you once you land at their bar.\n\nSee what I did there? Punny, eh?','disabled':0,'beerlist':'http://www.apexbar.com/menu'},
|
||||
{'id':23,'name':'Vagabond Brewing','location':'It may be a bit of a drive, however the beer is good, and the company is fantastic!\n\nLocated in north Salem, they are a short 50 minute drive from Farm to Beer (without traffic)','map':'http://tinyurl.com/vegabondbrewing','url':'http://www.vagabondbrewing.com/','note':'If you hit up Vagabond, make sure you say hi to the brewmaster -- James Cardwell. In addition to sharing the same first name as James Ketrenos, the two are also cousins.','disabled':0,'beerlist':'http://www.vagabondbrewing.com/#!beers/clg4'},
|
||||
{'id':24,'name':'McNally\'s Taproom','location':'If it\'s west you want to go, then McNally\'s has the location for you -- on the corner of 4th and East Main St in downtown Hillsboro.','map':'http://tinyurl.com/mcnallystaproom','url':'http://mcnallystaproom.com/','note':'','disabled':0,'beerlist':'http://mcnallystaproom.com/taplist/'},
|
||||
{'id':25,'name':'Brannons Pub and Brewery','location':'A couple miles south of 26 on Cedar Hills Blvd near where the old Westgate theater used to be.','map':'http://goo.gl/yq7gLl','url':'http://www.brannonsbrewery.com','note':'','disabled':1,'beerlist':'http://www.brannonsbrewery.com/brews'},
|
||||
{'id':26,'name':'Ambacht Brewing','location':'Ambacht brewing on 25th, about 10 minutes walk from JF Campus.','map':'http://goo.gl/f4tUUn','url':'http://www.ambacht.us','note':'','disabled':0,'beerlist':'http://www.ambacht.us/ambacht_ales.html'},
|
||||
{'id':27,'name':'Copper River Grill','location':'Next door to BJ\'s where \'On the Border\' used to be.','map':'https://www.google.com/maps/dir/2500+NE+25th+Ave,+Hillsboro,+OR+97124/45.5388207,-122.9029725/@45.5417113,-122.951877,14z/data=!3m1!4b1!4m8!4m7!1m5!1m1!1s0x5495053f6bb8f389:0xa39991f76a1278a2!2m2!1d-122.957124!2d45.5431728!1m0','url':'http://www.copperriverrestaurant.com/','note':'','disabled':0,'beerlist':'http://www.copperriverrestaurant.com/beer--wine.html'},
|
||||
{'id':28,'name':'Growlerie','location':'Progress Ridge - just a quick 14 miles away!','map':'https://goo.gl/umqffZ','url':'http://thegrowlerie.com','note':'Just down the stairs from Cinetopia. Have a pint, or a pitcher, then go watch a movie! It\'s a perfect Beer Tuesday!','disabled':0,'beerlist':'http://www.thegrowlerie.com/#new-page-section'},
|
||||
{'id':30,'name':'Imperial Bottle Shop and Tap Room','location':'Want some good food and some beer? Go to Pok Pok and then wander over to the Imperial Bottle Shop and Taproom. It may be a drive to get to the other side of the known universe, however it could be worth your while.\n\nAnd if they do not have the beer you want, you are not that far from APEX where Boulder Shake is ALWAYS on Nitro.','map':'https://goo.gl/l6ek5w','url':'http://imperialbottleshop.com/','note':'','disabled':0,'beerlist':'http://imperialbottleshop.com/'},
|
||||
{'id':31,'name':'Iron Tap Station','location':'Across Hall Blvd from Washington Square, in a strip mall just a few doors down from Kitchen Kaboodle and Lamps Plus.','map':'https://goo.gl/SDWgWB','url':'http://www.irontapstation.com/','note':'','disabled':0,'beerlist':'http://www.irontapstation.com/#menu-section'},
|
||||
{'id':32,'name':'Craft Pour House','location':'16055 SW Regatta Ln #700\nBeaverton, OR 97006\n\nNext door to where Monteaux\'s used to be.','map':'https://goo.gl/maps/VJpMpFS5RPC2','url':'http://craftpourhouse.com/','note':'They\'re new!','disabled':0,'beerlist':'http://craftpourhouse.com/'},
|
||||
{'id':33,'name':'Vertigo Brewing','location':'Located in the back of an industrial complex, this brewer is not to be missed!\n\n21420 NW Nicholas Ct.\nSuite D-6 & D-7\nHillsboro, OR 97124','map':'https://goo.gl/ABTbnD','url':'http://www.vertigobrew.com/','note':'','disabled':0,'beerlist':'http://www.vertigobrew.com/the-beer/'}];
|
@ -1,9 +1,7 @@
|
||||
const express = require('express'),
|
||||
router = express.Router(),
|
||||
crypto = require('crypto');
|
||||
router = express.Router();
|
||||
|
||||
router.get('/', async (req, res/*, next*/) => {
|
||||
console.log('GET /groups/', req.session.userId);
|
||||
return res.status(200).send(
|
||||
[ {
|
||||
id: 1,
|
||||
@ -16,26 +14,14 @@ router.get('/', async (req, res/*, next*/) => {
|
||||
|
||||
router.post('/:id', async (req, res) => {
|
||||
const { id } = req.params;
|
||||
|
||||
let userId;
|
||||
if (!req.cookies.user) {
|
||||
userId = crypto.randomBytes(16).toString('hex');
|
||||
res.cookie('user', userId);
|
||||
} else {
|
||||
userId = req.cookies.user;
|
||||
if (!id) {
|
||||
return res.status(400).send({ message: `Invalid group.`});
|
||||
}
|
||||
|
||||
|
||||
const group = {
|
||||
id: 1
|
||||
id
|
||||
};
|
||||
|
||||
if (id) {
|
||||
console.log(`[${userId.substring(0,8)}]: Attempting load of ${id}`);
|
||||
} else {
|
||||
console.log(`[${userId.substring(0,8)}]: Creating new group.`);
|
||||
}
|
||||
console.log(`[${userId.substring(0,8)}]: ${group.id} loaded.`);
|
||||
|
||||
return res.status(200).send({ id: group.id });
|
||||
});
|
||||
|
||||
|
@ -9,8 +9,6 @@ const router = express.Router();
|
||||
const autoAuthenticate = 1;
|
||||
|
||||
router.get('/', (req, res/*, next*/) => {
|
||||
console.log('GET /users/');
|
||||
|
||||
return getSessionUser(req).then((user) => {
|
||||
if (typeof user === 'string') {
|
||||
return res.status(403).send({ message: user });
|
||||
@ -20,7 +18,6 @@ router.get('/', (req, res/*, next*/) => {
|
||||
});
|
||||
|
||||
router.put('/password', async (req, res) => {
|
||||
console.log('/users/password');
|
||||
const db = req.app.locals.db;
|
||||
|
||||
const changes = {
|
||||
@ -80,12 +77,10 @@ router.put('/password', async (req, res) => {
|
||||
|
||||
router.get('/csrf', (req, res) => {
|
||||
const token = req.csrfToken();
|
||||
console.log('/users/csrf', token);
|
||||
res.json({ csrfToken: token });
|
||||
});
|
||||
|
||||
router.post('/signup', function(req, res) {
|
||||
console.log('/users/signup');
|
||||
const db = req.app.locals.db;
|
||||
|
||||
const user = {
|
||||
@ -163,7 +158,6 @@ router.post('/signup', function(req, res) {
|
||||
const getSessionUser = async (req) => {
|
||||
const db = req.app.locals.db;
|
||||
|
||||
console.log(req.session);
|
||||
if (!req.session || !req.session.userId) {
|
||||
return 'Unauthorized. You must be logged in.';
|
||||
}
|
||||
@ -205,7 +199,6 @@ const getSessionUser = async (req) => {
|
||||
};
|
||||
|
||||
router.post('/verify-email', async (req, res) => {
|
||||
console.log('/users/verify-email');
|
||||
const key = req.body.token;
|
||||
const db = req.app.locals.db;
|
||||
|
||||
@ -268,7 +261,6 @@ router.post('/verify-email', async (req, res) => {
|
||||
});
|
||||
|
||||
router.post('/signin', (req, res) => {
|
||||
console.log('/users/signin');
|
||||
const db = req.app.locals.db;
|
||||
|
||||
let { email, password } = req.body;
|
||||
@ -327,7 +319,6 @@ router.post('/signin', (req, res) => {
|
||||
});
|
||||
|
||||
router.post('/signout', (req, res) => {
|
||||
console.log('/users/signout');
|
||||
if (req.session && req.session.userId) {
|
||||
req.session.userId = null;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user