-
-
Notifications
You must be signed in to change notification settings - Fork 50
Support user login and registration #495
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
base: oauth-phase-2
Are you sure you want to change the base?
Changes from all commits
fafb366
31ce07d
39c838c
cb1ef8a
84b4cef
4c166c5
26e20ec
7b1ea12
9796769
5313857
d0b79f3
9719e00
51ff574
11de8fd
4a58226
94089fd
08f3f9b
97b065a
003106d
f4d8f41
f45d8e9
e6e60f1
f0a3e14
5d01e69
a3cd03d
a733c1c
da8e04c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| BEGIN; | ||
|
|
||
| CREATE TABLE "user" ( | ||
| id INTEGER GENERATED BY DEFAULT AS IDENTITY, | ||
| name TEXT NOT NULL, | ||
| password TEXT NOT NULL, | ||
| email TEXT UNIQUE, | ||
| unconfirmed_email TEXT, | ||
| email_confirmed_at TIMESTAMP WITH TIME ZONE, | ||
| member_since TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(), | ||
| last_login_at TIMESTAMP WITH TIME ZONE, | ||
| last_updated TIMESTAMP WITH TIME ZONE, | ||
| deleted BOOLEAN | ||
| ); | ||
|
|
||
| ALTER TABLE "user" ADD CONSTRAINT user_pkey PRIMARY KEY (id); | ||
|
|
||
| COMMIT; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| BEGIN; | ||
|
|
||
| ALTER TABLE supporter ADD COLUMN user_id INTEGER; | ||
| UPDATE supporter SET user_id = musicbrainz_row_id; | ||
|
|
||
| ALTER TABLE supporter ADD CONSTRAINT supporter_user_id_fkey | ||
| FOREIGN KEY (user_id) REFERENCES "user" (id) | ||
| ON UPDATE CASCADE ON DELETE SET NULL; | ||
|
|
||
| COMMIT; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| CREATE TYPE moderation_action_type AS ENUM ('block', 'unblock'); | ||
|
|
||
| BEGIN; | ||
|
|
||
| ALTER TABLE "user" ADD COLUMN is_blocked BOOLEAN NOT NULL DEFAULT FALSE; | ||
| CREATE TABLE moderation_log ( | ||
| id INTEGER GENERATED BY DEFAULT AS IDENTITY, | ||
| user_id INTEGER NOT NULL, | ||
| moderator_id INTEGER NOT NULL, | ||
| action moderation_action_type NOT NULL, | ||
| reason TEXT NOT NULL, | ||
| timestamp TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW() | ||
| ); | ||
| ALTER TABLE moderation_log ADD CONSTRAINT moderation_log_pkey PRIMARY KEY (id); | ||
| ALTER TABLE moderation_log ADD CONSTRAINT moderation_log_user_id_fkey FOREIGN KEY (user_id) REFERENCES "user" (id); | ||
| ALTER TABLE moderation_log ADD CONSTRAINT moderation_log_moderator_id_fkey FOREIGN KEY (moderator_id) REFERENCES "user" (id); | ||
| CREATE INDEX moderation_log_user_id_idx ON moderation_log (user_id); | ||
|
|
||
| ALTER TABLE "user" ADD COLUMN login_id UUID NOT NULL; | ||
| CREATE UNIQUE INDEX user_login_id_idx ON "user" (login_id); | ||
|
|
||
| COMMIT; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| ALTER TYPE moderation_action_type ADD VALUE 'comment'; | ||
| ALTER TYPE moderation_action_type ADD VALUE 'verify_email'; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| ALTER TYPE moderation_action_type ADD VALUE 'delete'; | ||
| ALTER TYPE moderation_action_type ADD VALUE 'edit_username'; | ||
|
|
||
| BEGIN; | ||
|
|
||
| CREATE TABLE old_username ( | ||
| id INTEGER GENERATED ALWAYS AS IDENTITY PRIMARY KEY, | ||
| username TEXT NOT NULL, | ||
| deleted_at TIMESTAMP NOT NULL DEFAULT NOW() | ||
| ); | ||
|
|
||
| CREATE INDEX old_username_username_idx ON old_username (username); | ||
| CREATE UNIQUE INDEX user_name_unq_idx ON "user" (name); | ||
|
|
||
| COMMIT; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| BEGIN; | ||
|
|
||
| ALTER TABLE supporter ALTER COLUMN contact_email DROP NOT NULL; | ||
|
|
||
| COMMIT; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,4 +2,6 @@ BEGIN; | |
|
|
||
| -- TODO: Add some, if needed. | ||
|
|
||
| CREATE INDEX moderation_log_user_id_idx ON moderation_log (user_id); | ||
|
|
||
| COMMIT; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,19 @@ | ||
| from datetime import timedelta | ||
|
|
||
| # CUSTOM CONFIGURATION | ||
|
|
||
| DEBUG = True # set to False in production mode | ||
|
|
||
| SECRET_KEY = "CHANGE_THIS" | ||
|
|
||
| EMAIL_VERIFICATION_SECRET_KEY = "CHANGE THIS" | ||
| EMAIL_VERIFICATION_EXPIRY = timedelta(hours=24) | ||
| EMAIL_RESET_PASSWORD_EXPIRY = timedelta(hours=24) | ||
|
|
||
| # Bcrypt | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What are these config items? Some explanation or a link to possible values would be good. |
||
| BCRYPT_HASH_PREFIX = "2a" | ||
| BCRYPT_LOG_ROUNDS = 12 | ||
|
|
||
| # DATABASE | ||
| SQLALCHEMY_DATABASE_URI = "postgresql://metabrainz:metabrainz@meb_db:5432/metabrainz" | ||
| SQLALCHEMY_MUSICBRAINZ_URI = "" | ||
|
|
@@ -100,9 +110,9 @@ MAIL_FROM_DOMAIN = "metabrainz.org" | |
|
|
||
| DEBUG_TB_INTERCEPT_REDIRECTS = False | ||
|
|
||
| # reCAPTCHA (https://www.google.com/recaptcha/) | ||
| RECAPTCHA_PUBLIC_KEY = "" | ||
| RECAPTCHA_PRIVATE_KEY = "" | ||
| # MTCaptcha (https://www.mtcaptcha.com/) | ||
| MTCAPTCHA_PUBLIC_KEY = "" | ||
| MTCAPTCHA_PRIVATE_KEY = "" | ||
|
|
||
| # List of email addresses | ||
| NOTIFICATION_RECIPIENTS = [ | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,7 +9,9 @@ services: | |
| context: .. | ||
| dockerfile: Dockerfile | ||
| target: metabrainz-dev | ||
| command: python manage.py runserver -h 0.0.0.0 -p 8000 | ||
| command: flask run --debug -h 0.0.0.0 -p 8000 | ||
| environment: | ||
| FLASK_APP: "metabrainz:create_app()" | ||
| volumes: | ||
| - ../data/replication_packets:/data/replication_packets | ||
| - ../data/json_dumps:/data/json_dumps | ||
|
|
@@ -23,26 +25,6 @@ services: | |
| ports: | ||
| - "8000:8000" | ||
|
|
||
| oauth: | ||
| build: | ||
| context: .. | ||
| dockerfile: Dockerfile | ||
| target: metabrainz-dev | ||
| command: flask run --debug -h 0.0.0.0 -p 8150 | ||
| environment: | ||
| FLASK_APP: "oauth:create_app()" | ||
| AUTHLIB_INSECURE_TRANSPORT: 1 | ||
| volumes: | ||
| - ..:/code/metabrainz | ||
| - ../frontend:/static | ||
| depends_on: | ||
| - meb_db | ||
| - redis | ||
| ports: | ||
| - "8150:8150" | ||
| expose: | ||
| - "8150" | ||
|
|
||
| meb_db: | ||
| image: postgres:12.3 | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Change would be out of scope for this specific PR, but even though this Compose file is for a dev environment, I still feel obliged to point out that Postgres 12 is well past end-of-life. 13 goes EoL in a few days as well, so 14 should be the minimum at this point. |
||
| volumes: | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cleanup?