remove membership from user
This commit is contained in:
committed by
Jackson Harper
parent
ea9d98aa95
commit
bab96aaa1e
@ -12,7 +12,6 @@ import { exclude, Partialize, PickTuple } from '../../util'
|
||||
// source_user_id | text | | not null |
|
||||
// created_at | timestamp with time zone | | not null | CURRENT_TIMESTAMP
|
||||
// updated_at | timestamp with time zone | | not null | CURRENT_TIMESTAMP
|
||||
// membership | omnivore.membership_tier | | not null | 'WAIT_LIST'::omnivore.membership_tier
|
||||
|
||||
// Table "omnivore.user_profile"
|
||||
// Column | Type | Collation | Nullable | Default
|
||||
@ -30,7 +29,6 @@ export interface UserData {
|
||||
id: string
|
||||
name: string
|
||||
source: string
|
||||
membership: string
|
||||
email?: string | null
|
||||
phone?: string | null
|
||||
sourceUserId: string
|
||||
@ -47,11 +45,6 @@ export interface UserData {
|
||||
status?: StatusType
|
||||
}
|
||||
|
||||
export enum MembershipTier {
|
||||
WaitList = 'WAIT_LIST',
|
||||
Beta = 'BETA',
|
||||
}
|
||||
|
||||
export enum RegistrationType {
|
||||
Google = 'GOOGLE',
|
||||
Apple = 'APPLE',
|
||||
@ -67,7 +60,6 @@ export const keys = [
|
||||
'id',
|
||||
'name',
|
||||
'source',
|
||||
'membership',
|
||||
'email',
|
||||
'phone',
|
||||
'sourceUserId',
|
||||
|
||||
@ -7,11 +7,7 @@ import {
|
||||
PrimaryGeneratedColumn,
|
||||
UpdateDateColumn,
|
||||
} from 'typeorm'
|
||||
import {
|
||||
MembershipTier,
|
||||
RegistrationType,
|
||||
StatusType,
|
||||
} from '../datalayer/user/model'
|
||||
import { RegistrationType, StatusType } from '../datalayer/user/model'
|
||||
import { NewsletterEmail } from './newsletter_email'
|
||||
import { Profile } from './profile'
|
||||
import { Label } from './label'
|
||||
@ -34,9 +30,6 @@ export class User {
|
||||
@Column('text')
|
||||
sourceUserId!: string
|
||||
|
||||
@Column({ type: 'enum', enum: MembershipTier })
|
||||
membership!: string
|
||||
|
||||
@CreateDateColumn()
|
||||
createdAt!: Date
|
||||
|
||||
|
||||
@ -86,7 +86,6 @@ export class IdentifySegmentUser implements EntitySubscriberInterface<Profile> {
|
||||
traits: {
|
||||
name: profile.user.name,
|
||||
email: profile.user.email,
|
||||
plan: profile.user.membership,
|
||||
source: profile.user.source,
|
||||
env: env.server.apiEnv,
|
||||
},
|
||||
|
||||
@ -33,7 +33,6 @@ import { corsConfig } from '../../utils/corsConfig'
|
||||
import cors from 'cors'
|
||||
|
||||
import {
|
||||
MembershipTier,
|
||||
RegistrationType,
|
||||
StatusType,
|
||||
UserData,
|
||||
@ -297,7 +296,7 @@ export function authRouter() {
|
||||
|
||||
res.setHeader('set-cookie', result.headers['set-cookie'])
|
||||
|
||||
handleSuccessfulLogin(req, res, user, data.googleLogin.newUser)
|
||||
await handleSuccessfulLogin(req, res, user, data.googleLogin.newUser)
|
||||
})
|
||||
|
||||
async function handleSuccessfulLogin(
|
||||
@ -333,10 +332,6 @@ export function authRouter() {
|
||||
)
|
||||
}
|
||||
|
||||
if (user.membership === MembershipTier.WaitList) {
|
||||
return res.redirect(`${env.client.url}/waitlist`)
|
||||
}
|
||||
|
||||
return res.redirect(
|
||||
url.resolve(env.client.url, decodeURIComponent(redirectUri || 'home'))
|
||||
)
|
||||
|
||||
@ -1,11 +1,10 @@
|
||||
import { JsonResponsePayload, UserProfile } from '../auth_types'
|
||||
import {
|
||||
decodePendingUserToken,
|
||||
createMobileAuthPayload,
|
||||
decodePendingUserToken,
|
||||
} from './../jwt_helpers'
|
||||
import { createUser } from '../../../services/create_user'
|
||||
import { SignupErrorCode } from '../../../generated/graphql'
|
||||
import { MembershipTier } from '../../../datalayer/user/model'
|
||||
|
||||
export async function createMobileAccountCreationResponse(
|
||||
pendingUserToken?: string,
|
||||
@ -34,7 +33,6 @@ export async function createMobileAccountCreationResponse(
|
||||
username: userProfile.username,
|
||||
pictureUrl: undefined,
|
||||
bio: userProfile.bio || undefined,
|
||||
membershipTier: MembershipTier.Beta,
|
||||
})
|
||||
|
||||
const mobileAuthPayload = await createMobileAuthPayload(user.id)
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import { AuthProvider } from '../routers/auth/auth_types'
|
||||
import { MembershipTier, StatusType } from '../datalayer/user/model'
|
||||
import { StatusType } from '../datalayer/user/model'
|
||||
import { EntityManager } from 'typeorm'
|
||||
import { User } from '../entity/user'
|
||||
import { Profile } from '../entity/profile'
|
||||
@ -22,7 +22,6 @@ export const createUser = async (input: {
|
||||
pictureUrl?: string
|
||||
bio?: string
|
||||
groups?: [string]
|
||||
membershipTier?: MembershipTier
|
||||
inviteCode?: string
|
||||
password?: string
|
||||
pendingConfirmation?: boolean
|
||||
@ -65,9 +64,6 @@ export const createUser = async (input: {
|
||||
}
|
||||
const user = await t.getRepository(User).save({
|
||||
source: input.provider,
|
||||
membership:
|
||||
input.membershipTier ||
|
||||
(hasInvite ? MembershipTier.Beta : MembershipTier.WaitList),
|
||||
name: input.name,
|
||||
email: input.email,
|
||||
sourceUserId: input.sourceUserId,
|
||||
|
||||
@ -7,11 +7,7 @@ import {
|
||||
ResolverFn,
|
||||
} from '../generated/graphql'
|
||||
import { Claims, WithDataSourcesContext } from '../resolvers/types'
|
||||
import {
|
||||
MembershipTier,
|
||||
RegistrationType,
|
||||
UserData,
|
||||
} from '../datalayer/user/model'
|
||||
import { RegistrationType, UserData } from '../datalayer/user/model'
|
||||
import crypto from 'crypto'
|
||||
import slugify from 'voca/slugify'
|
||||
import { Merge } from '../util'
|
||||
@ -128,7 +124,6 @@ export const userDataToUser = (
|
||||
id: string
|
||||
name: string
|
||||
source: RegistrationType
|
||||
membership: MembershipTier
|
||||
email?: string | null
|
||||
phone?: string | null
|
||||
picture?: string | null
|
||||
@ -149,11 +144,10 @@ export const userDataToUser = (
|
||||
...user,
|
||||
name: user.name,
|
||||
source: user.source as RegistrationType,
|
||||
membership: user.membership as MembershipTier,
|
||||
createdAt: user.createdAt || new Date(),
|
||||
friendsCount: user.friendsCount || 0,
|
||||
followersCount: user.followersCount || 0,
|
||||
isFullUser: isFullUser(user.membership as MembershipTier),
|
||||
isFullUser: true,
|
||||
viewerIsFollowing: user.viewerIsFollowing || user.isFriend || false,
|
||||
picture: user.profile.picture_url,
|
||||
sharedArticles: [],
|
||||
@ -166,10 +160,6 @@ export const userDataToUser = (
|
||||
},
|
||||
})
|
||||
|
||||
export const isFullUser = (membership: MembershipTier): boolean => {
|
||||
return membership != MembershipTier.WaitList
|
||||
}
|
||||
|
||||
export const generateSlug = (title: string): string => {
|
||||
return slugify(title).substring(0, 64) + '-' + Date.now().toString(16)
|
||||
}
|
||||
|
||||
@ -169,9 +169,9 @@ describe('auth router', () => {
|
||||
password = correctPassword
|
||||
})
|
||||
|
||||
it('redirects to waitlist page', async () => {
|
||||
it('redirects to home page', async () => {
|
||||
const res = await loginRequest(email, password).expect(302)
|
||||
expect(res.header.location).to.endWith('/waitlist')
|
||||
expect(res.header.location).to.endWith('/home')
|
||||
})
|
||||
|
||||
it('set auth token in cookie', async () => {
|
||||
|
||||
@ -42,7 +42,7 @@ describe('create user', () => {
|
||||
expect(await getUserFollowing(user)).to.eql([adminUser])
|
||||
expect(await getUserFollowers(adminUser)).to.eql([user])
|
||||
expect(await getUserFollowing(adminUser)).to.eql([user])
|
||||
}).timeout(10000)
|
||||
})
|
||||
|
||||
it('creates profile when user exists but profile not', async () => {
|
||||
after(async () => {
|
||||
|
||||
12
packages/db/migrations/0089.do.drop_membership_from_user.sql
Executable file
12
packages/db/migrations/0089.do.drop_membership_from_user.sql
Executable file
@ -0,0 +1,12 @@
|
||||
-- Type: DO
|
||||
-- Name: drop_membership_from_user
|
||||
-- Description: drop membership column from user table
|
||||
|
||||
BEGIN;
|
||||
|
||||
ALTER TABLE omnivore.user
|
||||
DROP column membership;
|
||||
|
||||
DROP TYPE omnivore.membership_tier;
|
||||
|
||||
COMMIT;
|
||||
14
packages/db/migrations/0089.undo.drop_membership_from_user.sql
Executable file
14
packages/db/migrations/0089.undo.drop_membership_from_user.sql
Executable file
@ -0,0 +1,14 @@
|
||||
-- Type: UNDO
|
||||
-- Name: drop_membership_from_user
|
||||
-- Description: drop membership column from user table
|
||||
|
||||
BEGIN;
|
||||
|
||||
CREATE TYPE omnivore.membership_tier AS ENUM ('WAIT_LIST', 'BETA');
|
||||
|
||||
ALTER TABLE omnivore.user
|
||||
ADD column membership omnivore.membership_tier NOT NULL DEFAULT 'WAIT_LIST';
|
||||
|
||||
UPDATE omnivore.user SET membership = 'BETA';
|
||||
|
||||
COMMIT;
|
||||
Reference in New Issue
Block a user