SShortSingh.
Back to feed

How to Build a Secure Node.js Login System with Bcrypt and Sessions

0
·2 views

A technical guide published on DEV Community outlines how to implement a session-based authentication system using Node.js, Mongoose, and Bcrypt. The system verifies user credentials by querying MongoDB and comparing submitted passwords against stored hashes using Bcrypt's compare method. Both invalid usernames and wrong passwords return the same generic error message to prevent attackers from identifying valid accounts through enumeration. Passwords are never stored in plain text, and Bcrypt automatically handles salt generation to defend against rainbow table attacks. Authenticated users are tracked via server-side sessions, which reduces the token-theft risks associated with client-side storage approaches.

Read the full story at DEV Community

This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)

Log in to join the discussion and vote.

Log in

Related stories

0
ProgrammingDEV Community ·

Developer Rebuilds 1991 DOS Maze Algorithm in the Browser After 35 Years

A software developer has revived a maze-generation program originally written in Turbo Pascal on a DOS machine in 1991, porting it to the browser using TypeScript. The algorithm was not intentionally designed as a maze generator — it emerged from experiments with recursive tree-drawing routines, where branches arranged at 45-degree angles naturally produced cycle-free paths. The developer notes that the approach is functionally equivalent to randomized depth-first search, a technique that gained wider recognition through Jamis Buck's 2011 blog series on maze algorithms, roughly two decades after the original code was written. No invention claim is made; rather, the author describes independently arriving at the same method through visual and geometric thinking rather than formal algorithm study. Notable design choices from the original code — including a precomputed permutation table and using pixel color as the sole occupancy map — have been preserved in the modern rewrite.

0
ProgrammingDEV Community ·

Entire Launches Distributed Git Mirror Network Built for AI Agent Workloads

A startup called Entire has released a preview of a distributed Git network designed to handle the high-frequency clone and push operations generated by large fleets of AI coding agents. The system places regional mirrors in the US, EU, and Australia in front of an existing GitHub repository, absorbing read and write traffic without touching the origin or its existing CI and access controls. Initial benchmarks on a single repository recorded roughly 570,000 shallow clones per hour, 586 pushes per second, and a mixed clone-plus-push throughput of around 470 operations per second at 50–60 ms median latency. The product is currently available under a waitlist, and Entire has said it plans to open-source the underlying Git backend in the coming months. Future milestones include native repository hosting and a fully decentralized network to support enterprises with data residency and regulatory requirements.

0
ProgrammingDEV Community ·

How to Build a Real-Time Dashboard Using FastAPI, WebSockets, and Postgres

Traditional polling-based dashboards send repeated server requests every few seconds, wasting CPU, bandwidth, and delivering stale data to users. WebSockets offer a more efficient alternative by letting the server push updates to clients instantly over a single persistent connection. Using FastAPI's native WebSocket support alongside PostgreSQL's built-in LISTEN/NOTIFY feature and the asyncpg library, developers can build a lightweight real-time dashboard with minimal infrastructure. For single-instance deployments, this setup requires no external message brokers and is straightforward to maintain. When scaling horizontally across multiple backend pods, adding Redis pub/sub ensures all instances receive and broadcast every database event to their connected clients.

0
ProgrammingDEV Community ·

How IVF and HNSW Power Fast Vector Search in Modern AI Systems

Vector search underpins semantic AI applications like RAG pipelines, recommendation engines, and image search by finding the closest matching vectors among millions. Because high-dimensional embeddings suffer from the curse of dimensionality, exact nearest-neighbor methods break down and approximate nearest neighbor (ANN) search is used instead. ANN algorithms trade a correctness guarantee for speed, measuring quality through recall — the fraction of true top-k neighbors actually returned. Two algorithms, Inverted File Index (IVF) and Hierarchical Navigable Small World (HNSW), handle most of the work in popular libraries like pgvector, Qdrant, and FAISS. Understanding how each works under the hood helps engineers choose the right approach and tune the speed-versus-recall tradeoff for their use case.