From 189de646e1473c19d99a6d28a703daa54b48a54b Mon Sep 17 00:00:00 2001 From: Jae Yun Kim Date: Mon, 23 Mar 2026 07:22:22 +0900 Subject: [PATCH 1/6] Changed email files --- .../texera/web/resource/EmailTemplate.scala | 19 +++++++++++-------- .../texera/web/resource/GmailResource.scala | 7 ++++++- .../app/common/service/gmail/gmail.service.ts | 4 ++-- .../app/common/service/user/auth.service.ts | 2 +- 4 files changed, 20 insertions(+), 12 deletions(-) diff --git a/amber/src/main/scala/org/apache/texera/web/resource/EmailTemplate.scala b/amber/src/main/scala/org/apache/texera/web/resource/EmailTemplate.scala index 1ad3c57af7a..2f53cfc744c 100644 --- a/amber/src/main/scala/org/apache/texera/web/resource/EmailTemplate.scala +++ b/amber/src/main/scala/org/apache/texera/web/resource/EmailTemplate.scala @@ -42,22 +42,25 @@ object EmailTemplate { * @return an EmailMessage ready to be sent */ def userRegistrationNotification( - receiverEmail: String, - userEmail: Option[String], - toAdmin: Boolean - ): EmailMessage = { + receiverEmail: String, + userEmail: Option[String], + affiliation: Option[String], + reason: Option[String], + toAdmin: Boolean + ): EmailMessage = { if (toAdmin) { val subject = - s"New Account Request Pending Approval${if (deployment.nonEmpty) s" for [$deployment]" - else ""}" + s"New Account Request Pending Approval${if (deployment.nonEmpty) s" for [$deployment]" else ""}" val content = s""" |Hello Admin, | |A new user has attempted to log in or register, but their account is not yet approved. - |Please review the account request for the following email: + |Please review the account request for the following user: | - |${userEmail.getOrElse("Unknown")} + |Email: ${userEmail.getOrElse("Unknown")} + |Affiliation: ${affiliation.filter(_.trim.nonEmpty).getOrElse("Not provided")} + |Reason: ${reason.filter(_.trim.nonEmpty).getOrElse("Not provided")} | |Visit the admin panel at: $deployment | diff --git a/amber/src/main/scala/org/apache/texera/web/resource/GmailResource.scala b/amber/src/main/scala/org/apache/texera/web/resource/GmailResource.scala index 255567494fc..f7dc0f96d1a 100644 --- a/amber/src/main/scala/org/apache/texera/web/resource/GmailResource.scala +++ b/amber/src/main/scala/org/apache/texera/web/resource/GmailResource.scala @@ -35,7 +35,8 @@ import javax.mail.{Message, PasswordAuthentication, Session, Transport} import javax.ws.rs._ import scala.util.{Failure, Success, Try} -case class EmailMessage(receiver: String, subject: String, content: String) +case class EmailMessage(receiver: String, subject: String, content: String, affiliation: Option[String] = None, + reason: Option[String] = None) object GmailResource { private def context = @@ -169,6 +170,8 @@ class GmailResource { userRegistrationNotification( receiverEmail = adminEmail, userEmail = Some(emailMessage.receiver), + affiliation = emailMessage.affiliation, + reason = emailMessage.reason, toAdmin = true ), adminEmail @@ -184,6 +187,8 @@ class GmailResource { userRegistrationNotification( receiverEmail = emailMessage.receiver, userEmail = None, + affiliation = None, + reason = None, toAdmin = false ), emailMessage.receiver diff --git a/frontend/src/app/common/service/gmail/gmail.service.ts b/frontend/src/app/common/service/gmail/gmail.service.ts index 4645a694e76..c9286ad37ad 100644 --- a/frontend/src/app/common/service/gmail/gmail.service.ts +++ b/frontend/src/app/common/service/gmail/gmail.service.ts @@ -48,8 +48,8 @@ export class GmailService { }); } - public notifyUnauthorizedLogin(userEmail: string): void { - this.http.post(`${AppSettings.getApiEndpoint()}/gmail/notify-unauthorized`, { receiver: userEmail }).subscribe({ + public notifyUnauthorizedLogin(userEmail: string, affiliation: string, reason: string): void { + this.http.post(`${AppSettings.getApiEndpoint()}/gmail/notify-unauthorized`, { receiver: userEmail, affiliation, reason }).subscribe({ next: () => this.notificationService.success("An admin has been notified about your account request."), error: (error: unknown) => { if (error instanceof HttpErrorResponse) { diff --git a/frontend/src/app/common/service/user/auth.service.ts b/frontend/src/app/common/service/user/auth.service.ts index 5b7f38d5701..9c9d0587cc4 100644 --- a/frontend/src/app/common/service/user/auth.service.ts +++ b/frontend/src/app/common/service/user/auth.service.ts @@ -248,7 +248,7 @@ export class AuthService { try { await firstValueFrom(this.submitRegistration(uid, affiliation, reason)); - this.gmailService.notifyUnauthorizedLogin(email); + this.gmailService.notifyUnauthorizedLogin(email, affiliation, reason); } finally { this.logout(); } From a2e58d0faabbd3c2118bd4965ae62caadca0ae2c Mon Sep 17 00:00:00 2001 From: Jae Yun Kim Date: Mon, 6 Apr 2026 19:28:38 +0800 Subject: [PATCH 2/6] Final fix --- .../texera/web/resource/EmailTemplate.scala | 15 +++++++------- .../texera/web/resource/GmailResource.scala | 9 +++++++-- .../app/common/service/gmail/gmail.service.ts | 20 ++++++++++--------- 3 files changed, 26 insertions(+), 18 deletions(-) diff --git a/amber/src/main/scala/org/apache/texera/web/resource/EmailTemplate.scala b/amber/src/main/scala/org/apache/texera/web/resource/EmailTemplate.scala index 2f53cfc744c..1b7517b4cd1 100644 --- a/amber/src/main/scala/org/apache/texera/web/resource/EmailTemplate.scala +++ b/amber/src/main/scala/org/apache/texera/web/resource/EmailTemplate.scala @@ -42,15 +42,16 @@ object EmailTemplate { * @return an EmailMessage ready to be sent */ def userRegistrationNotification( - receiverEmail: String, - userEmail: Option[String], - affiliation: Option[String], - reason: Option[String], - toAdmin: Boolean - ): EmailMessage = { + receiverEmail: String, + userEmail: Option[String], + affiliation: Option[String], + reason: Option[String], + toAdmin: Boolean + ): EmailMessage = { if (toAdmin) { val subject = - s"New Account Request Pending Approval${if (deployment.nonEmpty) s" for [$deployment]" else ""}" + s"New Account Request Pending Approval${if (deployment.nonEmpty) s" for [$deployment]" + else ""}" val content = s""" |Hello Admin, diff --git a/amber/src/main/scala/org/apache/texera/web/resource/GmailResource.scala b/amber/src/main/scala/org/apache/texera/web/resource/GmailResource.scala index f7dc0f96d1a..f06f1f92102 100644 --- a/amber/src/main/scala/org/apache/texera/web/resource/GmailResource.scala +++ b/amber/src/main/scala/org/apache/texera/web/resource/GmailResource.scala @@ -35,8 +35,13 @@ import javax.mail.{Message, PasswordAuthentication, Session, Transport} import javax.ws.rs._ import scala.util.{Failure, Success, Try} -case class EmailMessage(receiver: String, subject: String, content: String, affiliation: Option[String] = None, - reason: Option[String] = None) +case class EmailMessage( + receiver: String, + subject: String, + content: String, + affiliation: Option[String] = None, + reason: Option[String] = None +) object GmailResource { private def context = diff --git a/frontend/src/app/common/service/gmail/gmail.service.ts b/frontend/src/app/common/service/gmail/gmail.service.ts index c9286ad37ad..925e7e3a39d 100644 --- a/frontend/src/app/common/service/gmail/gmail.service.ts +++ b/frontend/src/app/common/service/gmail/gmail.service.ts @@ -49,14 +49,16 @@ export class GmailService { } public notifyUnauthorizedLogin(userEmail: string, affiliation: string, reason: string): void { - this.http.post(`${AppSettings.getApiEndpoint()}/gmail/notify-unauthorized`, { receiver: userEmail, affiliation, reason }).subscribe({ - next: () => this.notificationService.success("An admin has been notified about your account request."), - error: (error: unknown) => { - if (error instanceof HttpErrorResponse) { - this.notificationService.error("Failed to notify admin about your account request."); - console.error("Notify error:", error.error); - } - }, - }); + this.http + .post(`${AppSettings.getApiEndpoint()}/gmail/notify-unauthorized`, { receiver: userEmail, affiliation, reason }) + .subscribe({ + next: () => this.notificationService.success("An admin has been notified about your account request."), + error: (error: unknown) => { + if (error instanceof HttpErrorResponse) { + this.notificationService.error("Failed to notify admin about your account request."); + console.error("Notify error:", error.error); + } + }, + }); } } From f11a8976066ca4622d4482030607655006597c24 Mon Sep 17 00:00:00 2001 From: Jae Yun Kim Date: Wed, 8 Apr 2026 14:12:29 +0800 Subject: [PATCH 3/6] New commit --- frontend/src/app/common/service/gmail/gmail.service.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/app/common/service/gmail/gmail.service.ts b/frontend/src/app/common/service/gmail/gmail.service.ts index 925e7e3a39d..81d7b134fdd 100644 --- a/frontend/src/app/common/service/gmail/gmail.service.ts +++ b/frontend/src/app/common/service/gmail/gmail.service.ts @@ -50,7 +50,7 @@ export class GmailService { public notifyUnauthorizedLogin(userEmail: string, affiliation: string, reason: string): void { this.http - .post(`${AppSettings.getApiEndpoint()}/gmail/notify-unauthorized`, { receiver: userEmail, affiliation, reason }) + .post(`${AppSettings.getApiEndpoint()}/gmail/notify-unauthorize`, { receiver: userEmail, affiliation, reason }) .subscribe({ next: () => this.notificationService.success("An admin has been notified about your account request."), error: (error: unknown) => { From 536402f9f75a63b907c1abeee94d0188568ee297 Mon Sep 17 00:00:00 2001 From: Jae Yun Kim Date: Wed, 8 Apr 2026 14:12:57 +0800 Subject: [PATCH 4/6] Commit test --- frontend/src/app/common/service/gmail/gmail.service.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/app/common/service/gmail/gmail.service.ts b/frontend/src/app/common/service/gmail/gmail.service.ts index 81d7b134fdd..925e7e3a39d 100644 --- a/frontend/src/app/common/service/gmail/gmail.service.ts +++ b/frontend/src/app/common/service/gmail/gmail.service.ts @@ -50,7 +50,7 @@ export class GmailService { public notifyUnauthorizedLogin(userEmail: string, affiliation: string, reason: string): void { this.http - .post(`${AppSettings.getApiEndpoint()}/gmail/notify-unauthorize`, { receiver: userEmail, affiliation, reason }) + .post(`${AppSettings.getApiEndpoint()}/gmail/notify-unauthorized`, { receiver: userEmail, affiliation, reason }) .subscribe({ next: () => this.notificationService.success("An admin has been notified about your account request."), error: (error: unknown) => { From d63e914ca7e455f219615b8af95217cea6300fec Mon Sep 17 00:00:00 2001 From: Jae Yun Kim Date: Thu, 9 Apr 2026 16:42:34 +0800 Subject: [PATCH 5/6] Test --- .../scala/org/apache/texera/web/resource/GmailResource.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/amber/src/main/scala/org/apache/texera/web/resource/GmailResource.scala b/amber/src/main/scala/org/apache/texera/web/resource/GmailResource.scala index f06f1f92102..535388d3d7c 100644 --- a/amber/src/main/scala/org/apache/texera/web/resource/GmailResource.scala +++ b/amber/src/main/scala/org/apache/texera/web/resource/GmailResource.scala @@ -191,7 +191,7 @@ class GmailResource { sendEmail( userRegistrationNotification( receiverEmail = emailMessage.receiver, - userEmail = None, + userEmail = None affiliation = None, reason = None, toAdmin = false From 67155d8a223441180ead048105e05c81880f3fd7 Mon Sep 17 00:00:00 2001 From: Jae Yun Kim Date: Thu, 9 Apr 2026 16:42:46 +0800 Subject: [PATCH 6/6] Final --- .../scala/org/apache/texera/web/resource/GmailResource.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/amber/src/main/scala/org/apache/texera/web/resource/GmailResource.scala b/amber/src/main/scala/org/apache/texera/web/resource/GmailResource.scala index 535388d3d7c..f06f1f92102 100644 --- a/amber/src/main/scala/org/apache/texera/web/resource/GmailResource.scala +++ b/amber/src/main/scala/org/apache/texera/web/resource/GmailResource.scala @@ -191,7 +191,7 @@ class GmailResource { sendEmail( userRegistrationNotification( receiverEmail = emailMessage.receiver, - userEmail = None + userEmail = None, affiliation = None, reason = None, toAdmin = false