diff --git a/src/definition/accessors/IEmailCreator.ts b/src/definition/accessors/IEmailCreator.ts index 1e7921376..a94ad371f 100644 --- a/src/definition/accessors/IEmailCreator.ts +++ b/src/definition/accessors/IEmailCreator.ts @@ -3,6 +3,7 @@ export interface IEmailCreator { * Sends an OTP through the configured SMTP server within Rocket.Chat * * @param email the email that will recieve the TOTP + * @param channel from which type of channel is the visitor verifying */ - sendOTPThroughSMTP(email: string): Promise; + sendOTPThroughSMTP(email: string, channel: string): Promise; } diff --git a/src/definition/accessors/IEmailReader.ts b/src/definition/accessors/IEmailReader.ts index c0bd679f1..233f3c2dc 100644 --- a/src/definition/accessors/IEmailReader.ts +++ b/src/definition/accessors/IEmailReader.ts @@ -4,6 +4,7 @@ export interface IEmailReader { * * @param code the code that is going to be verified * @param email the email the code was sent + * @param channel from which channel is the visitor verifying */ - verifyOTPCode(code: string, email: string): Promise; + verifyOTPCode(code: string, email: string, channel: string): Promise; } diff --git a/src/server/accessors/EmailCreator.ts b/src/server/accessors/EmailCreator.ts index 0bb1413f2..f029daa98 100644 --- a/src/server/accessors/EmailCreator.ts +++ b/src/server/accessors/EmailCreator.ts @@ -4,7 +4,7 @@ import type { IEmailCreator } from '../../definition/accessors/IEmailCreator'; export class EmailCreator implements IEmailCreator { constructor(private readonly bridges: AppBridges, private readonly appId: string) {} - public async sendOTPThroughSMTP(email: string): Promise { - return this.bridges.getEmailBridge().doSendOtpCodeThroughSMTP(email, this.appId); + public async sendOTPThroughSMTP(email: string, channel: string): Promise { + return this.bridges.getEmailBridge().doSendOtpCodeThroughSMTP(email, channel, this.appId); } } diff --git a/src/server/accessors/EmailReader.ts b/src/server/accessors/EmailReader.ts index 96a06c398..b893d9c1b 100644 --- a/src/server/accessors/EmailReader.ts +++ b/src/server/accessors/EmailReader.ts @@ -4,7 +4,7 @@ import type { AppBridges } from '../bridges'; export class EmailReader implements IEmailReader { constructor(private readonly bridges: AppBridges, private readonly appId: string) {} - public async verifyOTPCode(code: string, email: string): Promise { - return this.bridges.getEmailBridge().doVerifyOTPCode(code, email, this.appId); + public async verifyOTPCode(code: string, channel: string, email: string): Promise { + return this.bridges.getEmailBridge().doVerifyOTPCode(code, email, channel, this.appId); } } diff --git a/src/server/bridges/EmailBridge.ts b/src/server/bridges/EmailBridge.ts index bd7c6c81c..b358eb9e2 100644 --- a/src/server/bridges/EmailBridge.ts +++ b/src/server/bridges/EmailBridge.ts @@ -4,21 +4,21 @@ import { AppPermissions } from '../permissions/AppPermissions'; import { BaseBridge } from './BaseBridge'; export abstract class EmailBridge extends BaseBridge { - public async doSendOtpCodeThroughSMTP(email: string, appId: string): Promise { + public async doSendOtpCodeThroughSMTP(email: string, channel: string, appId: string): Promise { if (this.hasWritePermission(appId)) { - return this.sendOtpCodeThroughSMTP(email, appId); + return this.sendOtpCodeThroughSMTP(email, channel, appId); } } - public async doVerifyOTPCode(code: string, email: string, appId: string): Promise { + public async doVerifyOTPCode(code: string, email: string, channel: string, appId: string): Promise { if (this.hasReadPermission(appId)) { - return this.verifyOTPCode(code, email, appId); + return this.verifyOTPCode(code, email, channel, appId); } } - protected abstract sendOtpCodeThroughSMTP(email: string, appId: string): Promise; + protected abstract sendOtpCodeThroughSMTP(email: string, channel: string, appId: string): Promise; - protected abstract verifyOTPCode(code: string, email: string, appId: string): Promise; + protected abstract verifyOTPCode(code: string, email: string, channel: string, appId: string): Promise; private hasWritePermission(appId: string): boolean { if (AppPermissionManager.hasPermission(appId, AppPermissions.email.sendOTP)) { diff --git a/tests/test-data/bridges/emailBridge.ts b/tests/test-data/bridges/emailBridge.ts index 71aa80c1d..89085dc87 100644 --- a/tests/test-data/bridges/emailBridge.ts +++ b/tests/test-data/bridges/emailBridge.ts @@ -1,11 +1,11 @@ import { EmailBridge } from '../../../src/server/bridges/EmailBridge'; export class TestsEmailBridge extends EmailBridge { - protected verifyOTPCode(code: string, email: string, appId: string): Promise { + protected verifyOTPCode(code: string, channel: string, email: string, appId: string): Promise { throw new Error('Method not implemented.'); } - protected sendOtpCodeThroughSMTP(email: string, appId: string): Promise { + protected sendOtpCodeThroughSMTP(email: string, channel: string, appId: string): Promise { throw new Error('Method not implemented.'); } }