Skip to content
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

Orion signup flow rework #321

Open
wants to merge 21 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
e2db206
Add graphql schema changes
zeeshanakram3 Mar 18, 2024
9289462
regenerate DB migrations
zeeshanakram3 Mar 18, 2024
1cd57ba
opdate openapi.yaml file
zeeshanakram3 Mar 18, 2024
6324de8
updated authHandler function
zeeshanakram3 Mar 18, 2024
65f5e20
remove /confirm-email auth api endpoint
zeeshanakram3 Mar 18, 2024
42f9b10
[auth-api] update /change-account endpoint implementation
zeeshanakram3 Mar 18, 2024
6c8de7a
[auth-api] update create account endpoint
zeeshanakram3 Mar 18, 2024
8b441ec
[auth-api] update /request-email-confirmation-token endpoint
zeeshanakram3 Mar 18, 2024
4bd1731
update mappings due to schema changes
zeeshanakram3 Mar 18, 2024
86c0ff0
update custon resolvers due to schema changes
zeeshanakram3 Mar 18, 2024
e2efa92
added createAccountMembership custom mutation
zeeshanakram3 Mar 18, 2024
b0daecb
update auth-server, mail scheduler and notification tests
zeeshanakram3 Mar 18, 2024
bb8f989
update auth-api docs
zeeshanakram3 Mar 18, 2024
3751a3f
Merge remote-tracking branch 'upstream/master' into orion_signup-flow…
zeeshanakram3 May 16, 2024
1389dfc
small refactor
zeeshanakram3 May 16, 2024
3a93392
fix: auth-api unit tests
zeeshanakram3 May 16, 2024
556ca20
fix: lint errors
zeeshanakram3 May 16, 2024
2fba0a5
move encryption_artifacts & session_encryption_artifacts to admin schema
zeeshanakram3 May 16, 2024
d580268
bump package version
zeeshanakram3 May 16, 2024
1be0059
fix: Members.MemberAccountsUpdated mappings bug
zeeshanakram3 May 16, 2024
3bfb7fd
[offchainState] add v5.0.0 migrations
zeeshanakram3 May 16, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,13 @@ APP_ASSET_STORAGE=https://raw.githubusercontent.com/Joystream/atlas-notification
APP_NAME_ALT=Gleev.xyz
NOTIFICATION_ASSET_ROOT=https://raw.githubusercontent.com/Joystream/atlas-notification-assets/main/icons

# =====================================================================================
# Faucet config
# =====================================================================================

FAUCET_URL=http://localhost:3002/register
FAUCET_CAPTCHA_BYPASS_KEY=faucet-captcha-bypass-key

# =====================================================================================
# Telemetry
# =====================================================================================
Expand Down
2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,5 @@ db/migrations/*-Views.js
schema.graphql
/scripts/orion-v1-migration/data
/db/export
src/auth-server/generated
src/auth-server/emails/templates/preview
20 changes: 10 additions & 10 deletions db/migrations/1708169663879-Data.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

49 changes: 49 additions & 0 deletions db/migrations/1710699134312-Data.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
module.exports = class Data1710699134312 {
name = 'Data1710699134312'

async up(db) {
await db.query(`ALTER TABLE "admin"."account" DROP CONSTRAINT "FK_601b93655bcbe73cb58d8c80cd3"`)
await db.query(`DROP INDEX "admin"."IDX_601b93655bcbe73cb58d8c80cd"`)
await db.query(`DROP INDEX "admin"."IDX_df4da05a7a80c1afd18b8f0990"`)
await db.query(`ALTER TABLE "membership" RENAME COLUMN "controller_account" TO "controller_account_id"`)
await db.query(`CREATE TABLE "blockchain_account" ("id" character varying NOT NULL, CONSTRAINT "PK_3d07d692a436bc34ef4093d9c60" PRIMARY KEY ("id"))`)
await db.query(`CREATE TABLE "admin"."email_confirmation_token" ("id" character varying NOT NULL, "issued_at" TIMESTAMP WITH TIME ZONE NOT NULL, "expiry" TIMESTAMP WITH TIME ZONE NOT NULL, "email" text NOT NULL, CONSTRAINT "PK_2fa8d5586af7e96201b84492131" PRIMARY KEY ("id"))`)
await db.query(`ALTER TABLE "admin"."account" DROP COLUMN "is_email_confirmed"`)
await db.query(`ALTER TABLE "admin"."account" DROP CONSTRAINT "Account_membership"`)
await db.query(`ALTER TABLE "admin"."account" DROP COLUMN "membership_id"`)
await db.query(`ALTER TABLE "admin"."account" DROP CONSTRAINT "Account_joystreamAccount"`)
await db.query(`ALTER TABLE "admin"."account" DROP COLUMN "joystream_account"`)
await db.query(`ALTER TABLE "admin"."account" DROP COLUMN "referrer_channel_id"`)
await db.query(`ALTER TABLE "admin"."account" ADD "joystream_account_id" character varying NOT NULL`)
await db.query(`ALTER TABLE "admin"."account" ADD CONSTRAINT "UQ_90debbc4217372d2464201c576a" UNIQUE ("joystream_account_id")`)
await db.query(`ALTER TABLE "membership" DROP COLUMN "controller_account_id"`)
await db.query(`ALTER TABLE "membership" ADD "controller_account_id" character varying`)
await db.query(`CREATE INDEX "IDX_58492b909a36e6a3e4dabd4674" ON "membership" ("controller_account_id") `)
await db.query(`CREATE INDEX "IDX_90debbc4217372d2464201c576" ON "admin"."account" ("joystream_account_id") `)
await db.query(`ALTER TABLE "membership" ADD CONSTRAINT "FK_58492b909a36e6a3e4dabd46743" FOREIGN KEY ("controller_account_id") REFERENCES "blockchain_account"("id") ON DELETE NO ACTION ON UPDATE NO ACTION DEFERRABLE INITIALLY DEFERRED`)
await db.query(`ALTER TABLE "admin"."account" ADD CONSTRAINT "FK_90debbc4217372d2464201c576a" FOREIGN KEY ("joystream_account_id") REFERENCES "blockchain_account"("id") ON DELETE NO ACTION ON UPDATE NO ACTION DEFERRABLE INITIALLY DEFERRED`)
}

async down(db) {
await db.query(`ALTER TABLE "admin"."account" ADD CONSTRAINT "FK_601b93655bcbe73cb58d8c80cd3" FOREIGN KEY ("membership_id") REFERENCES "membership"("id") ON DELETE NO ACTION ON UPDATE NO ACTION DEFERRABLE INITIALLY DEFERRED`)
await db.query(`CREATE INDEX "IDX_601b93655bcbe73cb58d8c80cd" ON "admin"."account" ("membership_id") `)
await db.query(`CREATE INDEX "IDX_df4da05a7a80c1afd18b8f0990" ON "admin"."account" ("joystream_account") `)
await db.query(`ALTER TABLE "membership" RENAME COLUMN "controller_account_id" TO "controller_account"`)
await db.query(`DROP TABLE "blockchain_account"`)
await db.query(`DROP TABLE "admin"."email_confirmation_token"`)
await db.query(`ALTER TABLE "admin"."account" ADD "is_email_confirmed" boolean NOT NULL`)
await db.query(`ALTER TABLE "admin"."account" ADD CONSTRAINT "Account_membership" UNIQUE ("membership_id")`)
await db.query(`ALTER TABLE "admin"."account" ADD "membership_id" character varying NOT NULL`)
await db.query(`ALTER TABLE "admin"."account" ADD CONSTRAINT "Account_joystreamAccount" UNIQUE ("joystream_account")`)
await db.query(`ALTER TABLE "admin"."account" ADD "joystream_account" text NOT NULL`)
await db.query(`ALTER TABLE "admin"."account" ADD "referrer_channel_id" text`)
await db.query(`ALTER TABLE "admin"."account" DROP COLUMN "joystream_account_id"`)
await db.query(`ALTER TABLE "admin"."account" DROP CONSTRAINT "UQ_90debbc4217372d2464201c576a"`)
await db.query(`ALTER TABLE "membership" ADD "controller_account_id" text NOT NULL`)
await db.query(`ALTER TABLE "membership" DROP COLUMN "controller_account_id"`)
await db.query(`DROP INDEX "public"."IDX_58492b909a36e6a3e4dabd4674"`)
await db.query(`DROP INDEX "admin"."IDX_90debbc4217372d2464201c576"`)
await db.query(`ALTER TABLE "membership" DROP CONSTRAINT "FK_58492b909a36e6a3e4dabd46743"`)
await db.query(`ALTER TABLE "admin"."account" DROP CONSTRAINT "FK_90debbc4217372d2464201c576a"`)
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@

const { getViewDefinitions } = require('../viewDefinitions')

module.exports = class Views1709641962433 {
name = 'Views1709641962433'
module.exports = class Views1710699134452 {
name = 'Views1710699134452'

async up(db) {
const viewDefinitions = getViewDefinitions(db);
Expand Down
1 change: 1 addition & 0 deletions docker.env
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ DB_HOST=orion_db
PROCESSOR_HOST=orion_processor
# Archive gateway host&port (can be overriden via local env)
ARCHIVE_GATEWAY_URL=${CUSTOM_ARCHIVE_GATEWAY_URL:-http://orion_archive_gateway:8000/graphql}
# ARCHIVE_GATEWAY_URL=${CUSTOM_ARCHIVE_GATEWAY_URL:-https://archive.joystream.org/graphql}
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "orion",
"version": "4.0.2",
"version": "5.0.0",
"engines": {
"node": ">=16"
},
Expand Down
40 changes: 26 additions & 14 deletions schema/auth.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ type User @entity @schema(name: "admin") {
nftFeaturingRequests: [NftFeaturingRequest!]! @derivedFrom(field: "user")
}

type EncryptionArtifacts @entity {
type EncryptionArtifacts @entity @schema(name: "admin") {
"ID / lookupKey"
id: ID!

Expand All @@ -55,7 +55,7 @@ type EncryptionArtifacts @entity {
encryptedSeed: String!
}

type SessionEncryptionArtifacts @entity {
type SessionEncryptionArtifacts @entity @schema(name: "admin") {
"Unique identifier"
id: ID!

Expand Down Expand Up @@ -112,31 +112,20 @@ type Account @entity @schema(name: "admin") {
"Gateway account's e-mail address"
email: String! @unique

"""
Indicates whether the gateway account's e-mail has been confirmed or not.
"""
isEmailConfirmed: Boolean!

"Indicates whether the access to the gateway account is blocked"
isBlocked: Boolean!

"Time when the gateway account was registered"
registeredAt: DateTime!

"On-chain membership associated with the gateway account"
membership: Membership! @unique

"Blockchain (joystream) account associated with the gateway account"
joystreamAccount: String! @unique
joystreamAccount: BlockchainAccount! @unique

"runtime notifications"
notifications: [Notification!]! @derivedFrom(field: "account")

"notification preferences for the account"
notificationPreferences: AccountNotificationPreferences!

"ID of the channel which referred the user to the platform"
referrerChannelId: String
}

type AccountNotificationPreferences {
Expand Down Expand Up @@ -214,3 +203,26 @@ type Token @entity @schema(name: "admin") {
"The account the token was issued for"
issuedFor: Account!
}

type EmailConfirmationToken @entity @schema(name: "admin") {
"The token itself (32-byte string, securely random)"
id: ID!

"When was the token issued"
issuedAt: DateTime!

"When does the token expire or when has it expired"
expiry: DateTime!

# "The User the token was issued for"
# issuedFor: User!

"The email the token was issued for"
email: String!

# "Indicates whether the token has been confirmed or not"
# isConfirmed: Boolean!

# "Time when the token was confirmed"
# confirmedAt: DateTime
}
10 changes: 9 additions & 1 deletion schema/membership.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@ type AvatarUri @variant {
avatarUri: String!
}

type BlockchainAccount @entity {
"The blockchain account id/address"
id: ID!

"Membership associated with the blockchain account (controllerAccount)"
memberships: [Membership!] @derivedFrom(field: "controllerAccount")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we support multiple memberships within Atlas? Seems, like an overkill. Besides that it is possible from runtime perspective, it will only complicate the membership dropdown (we already had some feedback that it is complicated @dmtrjsg)

}

union Avatar = AvatarObject | AvatarUri

type MemberMetadata @entity {
Expand Down Expand Up @@ -41,7 +49,7 @@ type Membership @entity {
metadata: MemberMetadata @derivedFrom(field: "member")

"Member's controller account id"
controllerAccount: String!
controllerAccount: BlockchainAccount!

"Auctions in which is this user whitelisted to participate"
whitelistedInAuctions: [AuctionWhitelistedMember!] @derivedFrom(field: "member")
Expand Down
1 change: 0 additions & 1 deletion src/auth-server/docs/.openapi-generator/FILES
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ Models/AnonymousUserAuthResponseData.md
Models/AnonymousUserAuthResponseData_allOf.md
Models/ChangeAccountRequestData.md
Models/ChangeAccountRequestData_allOf.md
Models/ConfirmEmailRequestData.md
Models/CreateAccountRequestData.md
Models/CreateAccountRequestData_allOf.md
Models/EncryptionArtifacts.md
Expand Down