Skip to content

Commit

Permalink
Merge pull request #25 from GeneralMagicio/UseCodeForEmailVerification
Browse files Browse the repository at this point in the history
Use code for email verification
  • Loading branch information
ae2079 authored Aug 19, 2024
2 parents c9203c6 + 10fa30e commit 19399ac
Show file tree
Hide file tree
Showing 15 changed files with 408 additions and 231 deletions.
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

0 comments on commit 19399ac

Please sign in to comment.