Skip to content

Commit

Permalink
Fix: 코드 리뷰 반영
Browse files Browse the repository at this point in the history
  • Loading branch information
HotoRas committed Oct 21, 2024
1 parent 2436087 commit fd8a902
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 10 deletions.
15 changes: 9 additions & 6 deletions packages/backend/src/server/api/SignupApiService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,9 @@ export class SignupApiService {
}

if (this.meta.emailRequiredForSignup) {
if (!emailAddress) {
throw new FastifyReplyError(400, 'EMAIL_NOT_PROVIDED');
}
if (await this.usersRepository.exists({ where: { usernameLower: username.toLowerCase(), host: IsNull() } })) {
throw new FastifyReplyError(400, 'DUPLICATED_USERNAME');
}
Expand All @@ -197,15 +200,15 @@ export class SignupApiService {
const pendingUser = await this.userPendingsRepository.insertOne({
id: this.idService.gen(),
code,
email: emailAddress!,
email: emailAddress,
username: username,
password: hash,
reason: reason,
});

const link = `${this.config.url}/signup-complete/${code}`;

this.emailService.sendEmail(emailAddress!, 'Signup',
this.emailService.sendEmail(emailAddress, 'Signup',
`To complete signup, please click this link:<br><a href="${link}">${link}</a>`,
`To complete signup, please click this link: ${link}`);

Expand All @@ -225,8 +228,8 @@ export class SignupApiService {

if (emailAddress) {
this.emailService.sendEmail(emailAddress, 'Approval pending',
'Congratulations! Your account is now pending approval. You will get notified when you have been accepted.',
'Congratulations! Your account is now pending approval. You will get notified when you have been accepted.');
'Your account is now pending approval.<br>You will get notified when you have been accepted.',
'Your account is now pending approval. You will get notified when you have been accepted.');
}

if (ticket) {
Expand Down Expand Up @@ -323,8 +326,8 @@ export class SignupApiService {
if (this.meta.approvalRequiredForSignup) {
if (pendingUser.email) {
this.emailService.sendEmail(pendingUser.email, 'Approval pending',
'Congratulations! Your account is now pending approval. You will get notified when you have been accepted.',
'Congratulations! Your account is now pending approval. You will get notified when you have been accepted.');
'Your account is now pending approval. You will get notified when you have been accepted.',
'Your account is now pending approval. You will get notified when you have been accepted.');
}

const moderators = await this.roleService.getModerators();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-

if (profile?.email) {
this.emailService.sendEmail(profile.email, 'Account Approved',
'Your Account has been approved have fun socializing!',
'Your Account has been approved have fun socializing!');
'Your Account has been approved!<br>Have fun socializing!',
'Your Account has been approved! Have fun socializing!');
}

this.moderationLogService.log(me, 'approve', {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
case 'available': query.where('user.isSuspended = FALSE'); break;
case 'alive': query.where('user.updatedAt > :date', { date: new Date(Date.now() - 1000 * 60 * 60 * 24 * 5) }); break;
case 'suspended': query.where('user.isSuspended = TRUE'); break;
case 'approved': query.where('user.approved = FALSE'); break;
case 'approved': query.where('user.approved = TRUE'); break;
case 'admin': {
const adminIds = await this.roleService.getAdministratorIds();
if (adminIds.length === 0) return [];
Expand Down
2 changes: 1 addition & 1 deletion packages/backend/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ export type ModerationLogPayloads = {
approve: {
userId: string;
userUsername: string;
userHost: string | null;
//userHost: string | null; // User approval is local action
};
unsuspend: {
userId: string;
Expand Down

0 comments on commit fd8a902

Please sign in to comment.