Comments (1)
[22:51] <i>jack arthur null</i>: so i went down the route of looking into doing the auth via a validation middleware
[22:51] <i>jack arthur null</i>: but there's no real way for the controller to know if the session was set
[22:51] <i>jack arthur null</i>: so say if through some dev. error you miss out adding the middleware
[22:51] <i>jack arthur null</i>: there'd be no error on the end of the controller that gets called without the userId being set
[22:52] <i>jack arthur null</i>: tbh, since it's already only a single call to a function in the routes, i think keeping it as is for now is all we can do
[22:52] Mudkip: could you not hang the userid as a request param for all requests
[22:52] Mudkip: and then just have if !userid exit
[22:52] Mudkip: or wait
[22:52] <i>jack arthur null</i>: some routes don't need login though
[22:53] Mudkip: can middlewares not just 403 the requests themselves?
[22:53] <i>jack arthur null</i>: they can
[22:53] Mudkip: there must be some mechanism through the routes to exclude
[22:53] Mudkip: laravel has that :smile:
[22:55] <i>jack arthur null</i>: basically you'd still need a check in the controllers for having a valid session
[22:55] <i>jack arthur null</i>: which isn't much different than whats already there
[22:55] Mudkip: https://javascript.plainenglish.io/excluding-routes-from-calling-express-middleware-with-express-unless-3389ab4117ef
[22:55] Mudkip: Kinda meh it being a seperate package
[22:56] <i>jack arthur null</i>: like you'd have a route:
POST /bookmarks
that right now is just:
-> create bookmark controller
[22:56] <i>jack arthur null</i>: but if you added the middleware, you'd have
middleware -> create bookmark controller
[22:57] <i>jack arthur null</i>: but there's no compile time way to ensure that the first middle ware comes first
[22:57] <i>jack arthur null</i>: so you'd have to basically check to see if the previous middleware did the job of getting the userId setup
[22:57] Mudkip: wait what
[22:57] Mudkip: Middleware order is not enforced :/?
[22:58] Mudkip: compile time
[22:58] Mudkip: that sounds like such a weird problem, ngl
[22:58] <i>jack arthur null</i>: not really about order, but if you say forgot to add the first middleware, there'd be no way to verify
[22:58] Mudkip: But why would you forget to add a middleware
[22:58] Mudkip: You include all and do exclusions
[22:58] Mudkip: its an api
[22:59] Mudkip: idk, maybe im thkinking about it wrong
[22:59] Mudkip: I have implemented a similar setup before
[22:59] <i>jack arthur null</i>: if ensuring the users session was anything more than two lines of code i'd be down to middleware it, but since its just:
const userId = await expectUserId(req);
i think its ok to leave as is
[22:59] Mudkip: fair point
[22:59] <i>jack arthur null</i>: since expectUserId does all the job of throwing errors for you
from yamun.
Related Issues (20)
- user creation race condition
- hard code test data, with smaller subset and multiple semesters
- make configurable things configurable
- add / change tests to use things from semester2 HOT 1
- start and end times, duration are in incorrect format for ICS files
- user input in export ics
- fix ics such that it works with google calender HOT 1
- find all schedules for the logged in user
- Iteration 3 HOT 1
- after initial data pull, keep data up to date HOT 1
- add sensible limits to things around the app so things don't overflow HOT 1
- dockerize HOT 1
- run tests in ci HOT 1
- bake in newsline
- bookmarks ui
- crn -> sid
- use people api on frontend
- use uni. cal. api on frontend
- add filters that already exist for course searching to the frontend HOT 1
- replace mongodb lol HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from yamun.