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

Use code for email verification #25

Merged
merged 16 commits into from
Aug 19, 2024
Merged
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
29 changes: 0 additions & 29 deletions migration/1723583534955-AddUserEmailVerificationFields.ts

This file was deleted.

2 changes: 1 addition & 1 deletion src/adapters/notifications/MockNotificationAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export class MockNotificationAdapter implements NotificationAdapterInterface {
async sendUserEmailConfirmation(params: {
email: string;
user: User;
token: string;
code: string;
}) {
logger.debug('MockNotificationAdapter sendUserEmailConfirmation', params);
return Promise.resolve(undefined);
Expand Down
2 changes: 1 addition & 1 deletion src/adapters/notifications/NotificationAdapterInterface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export interface NotificationAdapterInterface {
sendUserEmailConfirmation(params: {
email: string;
user: User;
token: string;
code: string;
}): Promise<void>;

userSuperTokensCritical(params: {
Expand Down
6 changes: 3 additions & 3 deletions src/adapters/notifications/NotificationCenterAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,16 +95,16 @@ export class NotificationCenterAdapter implements NotificationAdapterInterface {
async sendUserEmailConfirmation(params: {
email: string;
user: User;
token: string;
code: string;
}): Promise<void> {
const { email, user, token } = params;
const { email, code } = params;
try {
await callSendNotification({
eventName: NOTIFICATIONS_EVENT_NAMES.SEND_EMAIL_CONFIRMATION,
segment: {
payload: {
email,
verificationLink: `${dappUrl}/verification/user/${user.walletAddress}/${token}`,
verificationLink: code, // todo: we just set this for test and we should change the schema
},
},
});
Expand Down
2 changes: 2 additions & 0 deletions src/entities/entities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,13 @@ import { ProjectFraud } from './projectFraud';
import { ProjectActualMatchingView } from './ProjectActualMatchingView';
import { ProjectSocialMedia } from './projectSocialMedia';
import { UserQfRoundModelScore } from './userQfRoundModelScore';
import { UserEmailVerification } from './userEmailVerification';

export const getEntities = (): DataSourceOptions['entities'] => {
return [
Organization,
User,
UserEmailVerification,
ReferredEvent,
Project,

Expand Down
10 changes: 1 addition & 9 deletions src/entities/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,15 +192,7 @@ export class User extends BaseEntity {
@Column({ default: false })
emailConfirmed: boolean;

@Field(_type => String, { nullable: true })
@Column('text', { nullable: true })
emailConfirmationToken: string | null;

@Field(_type => Date, { nullable: true })
@Column('timestamptz', { nullable: true })
emailConfirmationTokenExpiredAt: Date | null;

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

Expand Down
16 changes: 16 additions & 0 deletions src/entities/userEmailVerification.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { Entity, PrimaryGeneratedColumn, Column, BaseEntity } from 'typeorm';

@Entity()
export class UserEmailVerification extends BaseEntity {
@PrimaryGeneratedColumn()
id: number;

@Column()
userId: number;

@Column('text', { nullable: true })
emailVerificationCode: string | null;

@Column('timestamptz', { nullable: true })
emailVerificationCodeExpiredAt: Date | null;
}
Loading
Loading