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

Feat/issue 4476 #1779

Open
wants to merge 7 commits into
base: staging
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions migration/1723764281125-add_email_verification_columns.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { MigrationInterface, QueryRunner } from 'typeorm';

export class AddEmailVerificationColumns1723764281125
implements MigrationInterface
{
public async up(queryRunner: QueryRunner): Promise<void> {
queryRunner.query(`
ALTER TABLE "user"
ADD COLUMN IF NOT EXISTS "verificationCode" VARCHAR,
ADD COLUMN IF NOT EXISTS "isEmailVerified" BOOLEAN DEFAULT false;
`);
}

public async down(queryRunner: QueryRunner): Promise<void> {
queryRunner.query(`
ALTER TABLE "user"
DROP COLUMN IF EXISTS "verificationCode",
DROP COLUMN IF EXISTS "isEmailVerified";
`);
}
}
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.

8 changes: 8 additions & 0 deletions src/adapters/notifications/MockNotificationAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@ export class MockNotificationAdapter implements NotificationAdapterInterface {
return Promise.resolve(undefined);
}

sendEmailConfirmationCodeFlow(params: { email: string }): Promise<void> {
logger.debug(
'MockNotificationAdapter sendEmailConfirmationCodeFlow',
params,
);
return Promise.resolve(undefined);
}

userSuperTokensCritical(): Promise<void> {
return Promise.resolve(undefined);
}
Expand Down
5 changes: 5 additions & 0 deletions src/adapters/notifications/NotificationAdapterInterface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ export interface NotificationAdapterInterface {
token: string;
}): Promise<void>;

sendEmailConfirmationCodeFlow(params: {
email: string;
user: User;
}): Promise<void>;

userSuperTokensCritical(params: {
user: User;
eventName: UserStreamBalanceWarning;
Expand Down
21 changes: 21 additions & 0 deletions src/adapters/notifications/NotificationCenterAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,27 @@ export class NotificationCenterAdapter implements NotificationAdapterInterface {
}
}

async sendEmailConfirmationCodeFlow(params: {
email: string;
user: User;
}): Promise<void> {
const { email, user } = params;
try {
await callSendNotification({
eventName: NOTIFICATIONS_EVENT_NAMES.SEND_EMAIL_CONFIRMATION_CODE_FLOW,
segment: {
payload: {
email,
verificationCode: user.verificationCode,
userId: user.id,
},
},
});
} catch (e) {
logger.error('sendEmailConfirmationCodeFlow >> error', e);
}
}

async userSuperTokensCritical(params: {
user: User;
eventName: UserStreamBalanceWarning;
Expand Down
1 change: 1 addition & 0 deletions src/analytics/analytics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,5 @@ export enum NOTIFICATIONS_EVENT_NAMES {
SUBSCRIBE_ONBOARDING = 'Subscribe onboarding',
CREATE_ORTTO_PROFILE = 'Create Ortto profile',
SEND_EMAIL_CONFIRMATION = 'Send email confirmation',
SEND_EMAIL_CONFIRMATION_CODE_FLOW = 'Send email confirmation code flow',
}
8 changes: 8 additions & 0 deletions src/entities/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export const publicSelectionFields = [
'user.totalReceived',
'user.passportScore',
'user.passportStamps',
'user.isEmailVerified',
];

export enum UserRole {
Expand Down Expand Up @@ -156,6 +157,13 @@ export class User extends BaseEntity {
@Column('bool', { default: false })
segmentIdentified: boolean;

@Field(_type => Boolean, { nullable: true })
@Column('bool', { default: false })
isEmailVerified: boolean;

@Column('varchar', { nullable: true, default: null })
verificationCode?: string | null;

// Admin Reviewing Forms
@Field(_type => [ProjectVerificationForm], { nullable: true })
@OneToMany(
Expand Down
4 changes: 4 additions & 0 deletions src/resolvers/types/userResolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,8 @@ import { User } from '../../entities/user';
export class UserByAddressResponse extends User {
@Field(_type => Boolean, { nullable: true })
isSignedIn?: boolean;
@Field(_type => Boolean, { nullable: true })
isEmailSent?: boolean;
@Field(_type => Boolean, { nullable: true })
useHasProject?: boolean;
}
Loading
Loading