Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Sharkey
Manage
Activity
Members
Labels
Plan
Issues
339
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
24
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TransFem.org
Sharkey
Commits
a4ca127e
Unverified
Commit
a4ca127e
authored
2 years ago
by
RyotaK
Committed by
GitHub
2 years ago
Browse files
Options
Downloads
Patches
Plain Diff
fix: 登録メール送信時に重複確認を行う (#10231)
* fix: 登録メール送信時に重複確認を行う * try-catchを使う必要はない * Remove spaces
parent
4835f0fb
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
packages/backend/src/server/api/SignupApiService.ts
+19
-6
19 additions, 6 deletions
packages/backend/src/server/api/SignupApiService.ts
with
19 additions
and
6 deletions
packages/backend/src/server/api/SignupApiService.ts
+
19
−
6
View file @
a4ca127e
...
...
@@ -2,7 +2,7 @@ import { Inject, Injectable } from '@nestjs/common';
import
rndstr
from
'
rndstr
'
;
import
bcrypt
from
'
bcryptjs
'
;
import
{
DI
}
from
'
@/di-symbols.js
'
;
import
type
{
RegistrationTicketsRepository
,
UserPendingsRepository
,
UserProfilesRepository
,
UsersRepository
}
from
'
@/models/index.js
'
;
import
type
{
RegistrationTicketsRepository
,
UsedUsernamesRepository
,
UserPendingsRepository
,
UserProfilesRepository
,
UsersRepository
}
from
'
@/models/index.js
'
;
import
type
{
Config
}
from
'
@/config.js
'
;
import
{
MetaService
}
from
'
@/core/MetaService.js
'
;
import
{
CaptchaService
}
from
'
@/core/CaptchaService.js
'
;
...
...
@@ -15,6 +15,7 @@ import { FastifyReplyError } from '@/misc/fastify-reply-error.js';
import
{
bindThis
}
from
'
@/decorators.js
'
;
import
{
SigninService
}
from
'
./SigninService.js
'
;
import
type
{
FastifyRequest
,
FastifyReply
}
from
'
fastify
'
;
import
{
IsNull
}
from
'
typeorm
'
;
@
Injectable
()
export
class
SignupApiService
{
...
...
@@ -31,6 +32,9 @@ export class SignupApiService {
@
Inject
(
DI
.
userPendingsRepository
)
private
userPendingsRepository
:
UserPendingsRepository
,
@
Inject
(
DI
.
usedUsernamesRepository
)
private
usedUsernamesRepository
:
UsedUsernamesRepository
,
@
Inject
(
DI
.
registrationTicketsRepository
)
private
registrationTicketsRepository
:
RegistrationTicketsRepository
,
...
...
@@ -124,12 +128,21 @@ export class SignupApiService {
}
if
(
instance
.
emailRequiredForSignup
)
{
if
(
await
this
.
usersRepository
.
findOneBy
({
usernameLower
:
username
.
toLowerCase
(),
host
:
IsNull
()
}))
{
throw
new
FastifyReplyError
(
400
,
'
DUPLICATED_USERNAME
'
);
}
// Check deleted username duplication
if
(
await
this
.
usedUsernamesRepository
.
findOneBy
({
username
:
username
.
toLowerCase
()
}))
{
throw
new
FastifyReplyError
(
400
,
'
USED_USERNAME
'
);
}
const
code
=
rndstr
(
'
a-z0-9
'
,
16
);
// Generate hash of password
const
salt
=
await
bcrypt
.
genSalt
(
8
);
const
hash
=
await
bcrypt
.
hash
(
password
,
salt
);
await
this
.
userPendingsRepository
.
insert
({
id
:
this
.
idService
.
genId
(),
createdAt
:
new
Date
(),
...
...
@@ -138,13 +151,13 @@ export class SignupApiService {
username
:
username
,
password
:
hash
,
});
const
link
=
`
${
this
.
config
.
url
}
/signup-complete/
${
code
}
`
;
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
}
`
);
reply
.
code
(
204
);
return
;
}
else
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment