Next.js application with:
- Login and registration by
login+password - Password hashing with
bcrypt - PostgreSQL storage
- Role-based session (
adminoranalyst)
Create database:
CREATE DATABASE diplom_db;Run schema from project root:
psql -U postgres -d diplom_db -f db/schema.sqlIf
psqlis not in PATH, run it using full path from your PostgreSQL installation.
Copy .env.example to .env:
cp .env.example .envThen set values in .env:
DATABASE_URL=postgresql://USER:PASSWORD@HOST:PORT/DB_NAMESESSION_SECRET=long_random_secret_string
Generate SESSION_SECRET example:
node -e "console.log(require('crypto').randomBytes(32).toString('base64'))"npm install
npm run dev- Allowed roles in DB:
admin,analyst - New users are created with role
analyst - To change role, update it manually in PostgreSQL:
UPDATE users SET role = 'admin' WHERE login = 'your_login';After next login, session will contain the updated role.
users structure:
id- auto-increment unique keylogin- unique loginpassword- hash (not plain text)role-adminoranalysttg_username- currently stored as empty string by default