Urgent.News

What's breaking now, across thousands of outlets.

Tech

Five functions decide who may read a row in our app, and the answer for somebody else's row is 404

Nakodo is a Next.js app with two halves. One half is 76 public pages that show the same thing to everybody, like how it works and pricing . The other half is behind a login and every row in it belongs to exactly one account. All of the second half's access control lives in one file, src/lib/auth.ts , 87 lines including comments. Thirty-seven files import it. There are five functions that answer…

The Nakodo app contains two halves: public pages accessible to all and a private section for individual accounts. All rows in the private section correspond to a single account. The access control for the private section resides in a single file, src/lib/auth.ts, consisting of 87 lines of code. This file includes five functions that determine whether a request can access a particular row.

The most noteworthy aspect is the behavior when a request is denied access. For some requests, a 404 response is returned, indicating that the requested row does not belong to the currently signed-in user.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

Why do we use primary keywords and hashtags in content creation and digital marketing?

Primary keyword This is the main phrase a page is built around, the thing you want it to rank for on Google. A write-up on your site might target “TryCloudflare phishing detection.” Why it matters…

  • Primary keywords centralize a page's focus to rank for specific search terms.
  • Hashtags categorize content on social media, expanding post reach and engagement.
  • Overuse of keywords or hashtags can negatively impact rankings and appear spammy.

I Optimized a Button From O(n) to O(1). The Speed Didn't Matter.

A bug report, a route map, and three rounds of making it faster — a story about what Big O really measures, why constants win at small n, and why the best algorithm is sometimes deleting the question.

  • Original button had O(n) time complexity
  • Optimized with hash map to O(1) average time
  • Author concluded best algorithm may be deleting question

Roughly organizing entities, value objects, services, and use cases.

Well, it's related to Rails, DDD (Domain-Driven Design), and Clean Architecture. Here is a list of terms: - Entities: things identified by ID - Examples: User, Case, Order - Value Objects: things…

  • Entities are core objects identified by unique IDs in Ruby on Rails.
  • Value objects are defined by attributes, not identity, like a ¥1000 note.
  • Service objects encapsulate specific actions, orchestrating entities and value objects.

More from Saturday 31 October →