-
Notifications
You must be signed in to change notification settings - Fork 7
Add Multi-User Functionality #238
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
thomasb202
wants to merge
29
commits into
smarr:master
Choose a base branch
from
thomasb202:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
941bdc3
Added logic to replace html-characters.
thomasb202 28101f0
Added logic to replace html-characters.
thomasb202 9a210fc
Merge pull request #1 from thomasb202/issue_222
thomasb202 3b5ad71
Add test for filtering sign off lines
smarr ba2557d
Added test cases to test the escaping of html
thomasb202 166d470
Added Database changes.
thomasb202 425d203
Added Appuser table
thomasb202 2c0e1f0
Added Appuser table
thomasb202 71d0c9e
Added jwt, bcrypt,
thomasb202 fb248b1
Implemented method withUserContext
thomasb202 c00dc3a
Created Test-Cases for User and Project Membership
thomasb202 b5f5fe7
Created Test-Cases RLS-policies
thomasb202 21a4d05
Added db.withUserContext to appropriate methods
thomasb202 e88b71b
Added requireAuth to appropriate routes
thomasb202 ca8b093
Implement withUserContext
thomasb202 a867ddd
Implement UserContextStorage to store userId/token
thomasb202 acb22e1
Added db.withUserContext
thomasb202 bf60451
Middleware for jsonwebtoken
thomasb202 2c4cc7b
Methods for User-Authentication
thomasb202 3a88c72
Methods for User-handling in db
thomasb202 5fed7b0
Minimal version of login page.
thomasb202 28e5ee4
Added jwt secret to docker-compose.yml
thomasb202 3d19ec2
Remove app_current_user_id() is NULL bypass
thomasb202 894d956
Remove app_currenr_user_id() is NULL bypass
thomasb202 ac9c156
Add minimal login page
thomasb202 108fec2
Redirect to login page
thomasb202 ff24900
Merge remote-tracking branch 'origin/M1_Database' into M1_Database
thomasb202 2099670
Merge branch 'master' into M1_Database
thomasb202 e68b383
Merge pull request #2 from thomasb202/M1_Database
thomasb202 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| import type { Database } from '../db/db.js'; | ||
|
|
||
| export interface AppUser { | ||
| id: number; | ||
| username: string; | ||
| email: string; | ||
| password_hash: string; | ||
| created_at: Date; | ||
| is_active: boolean; | ||
| } | ||
|
|
||
| export async function getUserByUsername( | ||
| db: Database, | ||
| username: string | ||
| ): Promise<AppUser | null> { | ||
| const result = await db.query<AppUser>({ | ||
| name: 'getUserByUsername', | ||
| text: 'SELECT * FROM appuser WHERE username = $1', | ||
| values: [username] | ||
| }); | ||
| return result.rows[0] ?? null; | ||
| } | ||
|
|
||
| export async function getUserByEmail( | ||
| db: Database, | ||
| email: string | ||
| ): Promise<AppUser | null> { | ||
| const result = await db.query<AppUser>({ | ||
| name: 'getUserByEmail', | ||
| text: 'SELECT * FROM appuser WHERE email = $1', | ||
| values: [email] | ||
| }); | ||
| return result.rows[0] ?? null; | ||
| } | ||
|
|
||
| export async function createUser( | ||
| db: Database, | ||
| username: string, | ||
| email: string, | ||
| passwordHash: string | ||
| ): Promise<AppUser> { | ||
| const result = await db.query<AppUser>({ | ||
| name: 'createUser', | ||
| text: `INSERT INTO appuser (username, email, password_hash) | ||
| VALUES ($1, $2, $3) | ||
| RETURNING *`, | ||
| values: [username, email, passwordHash] | ||
| }); | ||
| return result.rows[0]; | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.