diff --git a/libs/model/src/models/address.ts b/libs/model/src/models/address.ts index 960349cd405..aa8e273340c 100644 --- a/libs/model/src/models/address.ts +++ b/libs/model/src/models/address.ts @@ -52,7 +52,6 @@ export default ( defaultValue: false, }, wallet_id: { type: Sequelize.STRING, allowNull: true }, - wallet_sso_source: { type: Sequelize.STRING, allowNull: true }, block_info: { type: Sequelize.STRING, allowNull: true }, is_banned: { type: Sequelize.BOOLEAN, diff --git a/libs/schemas/src/entities/user.schemas.ts b/libs/schemas/src/entities/user.schemas.ts index 3ec8b40980b..17e82143c97 100644 --- a/libs/schemas/src/entities/user.schemas.ts +++ b/libs/schemas/src/entities/user.schemas.ts @@ -1,4 +1,4 @@ -import { Roles, WalletId, WalletSsoSource } from '@hicommonwealth/shared'; +import { Roles, WalletId } from '@hicommonwealth/shared'; import { z } from 'zod'; import { PG_INT } from '../utils'; @@ -61,9 +61,6 @@ export const Address = z.object({ block_info: z.string().max(255).nullish(), is_user_default: z.boolean().default(false), role: z.enum(Roles).default('member'), - wallet_sso_source: z - .union([z.nativeEnum(WalletSsoSource), z.literal('')]) - .nullish(), is_banned: z.boolean().default(false), hex: z.string().max(64).nullish(), diff --git a/packages/commonwealth/server/migrations/20240905195339-clean-wallet-sso-source.js b/packages/commonwealth/server/migrations/20240905195339-clean-wallet-sso-source.js index 1d444f90e75..dced8f3b39c 100644 --- a/packages/commonwealth/server/migrations/20240905195339-clean-wallet-sso-source.js +++ b/packages/commonwealth/server/migrations/20240905195339-clean-wallet-sso-source.js @@ -3,11 +3,7 @@ /** @type {import('sequelize-cli').Migration} */ module.exports = { async up(queryInterface, Sequelize) { - await queryInterface.sequelize.query(` - UPDATE "Addresses" - SET wallet_sso_source = NULL - WHERE wallet_sso_source = ''; - `); + await queryInterface.removeColumn('Addresses', 'wallet_sso_source'); }, async down(queryInterface, Sequelize) {}, diff --git a/packages/commonwealth/server/passport/magic.ts b/packages/commonwealth/server/passport/magic.ts index 83bb0376aff..3dccaf9a537 100644 --- a/packages/commonwealth/server/passport/magic.ts +++ b/packages/commonwealth/server/passport/magic.ts @@ -14,7 +14,6 @@ import { CANVAS_TOPIC, ChainBase, WalletId, - WalletSsoSource, deserializeCanvas, getSessionSignerForAddress, } from '@hicommonwealth/shared'; @@ -37,7 +36,6 @@ type MagicLoginContext = { existingUserInstance?: UserInstance; loggedInUser?: UserInstance; profileMetadata?: { username?: string; avatarUrl?: string }; - walletSsoSource: WalletSsoSource; }; const DEFAULT_ETH_COMMUNITY_ID = 'ethereum'; @@ -47,7 +45,6 @@ async function createMagicAddressInstances( models: DB, generatedAddresses: Array<{ address: string; community_id: string }>, user: UserAttributes, - walletSsoSource: WalletSsoSource, decodedMagicToken: MagicUser, t?: Transaction, ): Promise { @@ -91,16 +88,6 @@ async function createMagicAddressInstances( if (!created) { // Update used magic token to prevent replay attacks addressInstance.verification_token = decodedMagicToken.claim.tid; - - if ( - addressInstance.wallet_sso_source === WalletSsoSource.Unknown || - // set wallet_sso_source if it was unknown before - addressInstance.wallet_sso_source === undefined || - addressInstance.wallet_sso_source === null - ) { - addressInstance.wallet_sso_source = walletSsoSource; - } - await addressInstance.save({ transaction: t }); } addressInstances.push(addressInstance); @@ -115,7 +102,6 @@ async function createNewMagicUser({ magicUserMetadata, generatedAddresses, profileMetadata, - walletSsoSource, }: MagicLoginContext): Promise { // completely new user: create user, profile, addresses return sequelize.transaction(async (transaction) => { @@ -151,7 +137,6 @@ async function createNewMagicUser({ models, generatedAddresses, newUser, - walletSsoSource, decodedMagicToken, transaction, ); @@ -235,7 +220,6 @@ async function loginExistingMagicUser({ existingUserInstance, decodedMagicToken, generatedAddresses, - walletSsoSource, }: MagicLoginContext): Promise { if (!existingUserInstance) { throw new Error('No user provided to sign in'); @@ -273,7 +257,6 @@ async function loginExistingMagicUser({ models, generatedAddresses, existingUserInstance, - walletSsoSource, decodedMagicToken, transaction, ); @@ -346,15 +329,12 @@ async function addMagicToUser({ generatedAddresses, loggedInUser, decodedMagicToken, - walletSsoSource, }: MagicLoginContext): Promise { // create new address on logged-in user const addressInstances = await createMagicAddressInstances( models, generatedAddresses, - // @ts-expect-error StrictNullChecks - loggedInUser, - walletSsoSource, + loggedInUser!, decodedMagicToken, ); @@ -386,7 +366,6 @@ async function magicLoginRoute( signature: string; session?: string; magicAddress?: string; // optional because session keys are feature-flagged - walletSsoSource: WalletSsoSource; }>, decodedMagicToken: MagicUser, cb: DoneFunc, @@ -394,7 +373,6 @@ async function magicLoginRoute( log.trace(`MAGIC TOKEN: ${JSON.stringify(decodedMagicToken, null, 2)}`); let communityToJoin: CommunityInstance, error, loggedInUser: UserInstance; - const walletSsoSource = req.body.walletSsoSource; const generatedAddresses = [ { address: decodedMagicToken.publicAddress, @@ -596,7 +574,6 @@ async function magicLoginRoute( models, generatedAddresses, loggedInUser, - walletSsoSource, decodedMagicToken, ); return cb(null, existingUserInstance); @@ -616,7 +593,6 @@ async function magicLoginRoute( username: req.body.username, avatarUrl: req.body.avatarUrl, }, - walletSsoSource, }; try { // @ts-expect-error StrictNullChecks diff --git a/packages/commonwealth/server/routes/linkExistingAddressToCommunity.ts b/packages/commonwealth/server/routes/linkExistingAddressToCommunity.ts index 808c49316c6..3ba9dea2cf2 100644 --- a/packages/commonwealth/server/routes/linkExistingAddressToCommunity.ts +++ b/packages/commonwealth/server/routes/linkExistingAddressToCommunity.ts @@ -164,7 +164,6 @@ const linkExistingAddressToCommunity = async ( verification_token_expires: verificationTokenExpires, verified: originalAddress.verified, wallet_id: originalAddress.wallet_id, - wallet_sso_source: originalAddress.wallet_sso_source, last_active: new Date(), role: 'member', is_user_default: false,