Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Sharkey
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
0
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
Dima Krasner
Sharkey
Commits
116dd097
Unverified
Commit
116dd097
authored
2 years ago
by
RyotaK
Committed by
GitHub
2 years ago
Browse files
Options
Downloads
Patches
Plain Diff
fix: 登録フォームにおける競合状態を修正 (#10267)
* fix: 登録フォームにおける競合状態を修正 * エラーを修正
parent
dd6569a1
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
cypress/e2e/basic.cy.js
+4
-0
4 additions, 0 deletions
cypress/e2e/basic.cy.js
packages/frontend/src/components/MkSignup.vue
+20
-6
20 additions, 6 deletions
packages/frontend/src/components/MkSignup.vue
packages/frontend/src/scripts/api.ts
+2
-1
2 additions, 1 deletion
packages/frontend/src/scripts/api.ts
with
26 additions
and
7 deletions
cypress/e2e/basic.cy.js
+
4
−
0
View file @
116dd097
...
...
@@ -62,6 +62,10 @@ describe('After setup instance', () => {
cy
.
get
(
'
[data-cy-signup-submit]
'
).
click
();
cy
.
wait
(
'
@signup
'
);
});
it
(
'
signup with duplicated username
'
,
()
=>
{
cy
.
registerUser
(
'
alice
'
,
'
alice1234
'
);
cy
.
visitHome
();
...
...
This diff is collapsed.
Click to expand it.
packages/frontend/src/components/MkSignup.vue
+
20
−
6
View file @
116dd097
...
...
@@ -110,6 +110,8 @@ let ToSAgreement: boolean = $ref(false);
let
hCaptchaResponse
=
$ref
(
null
);
let
reCaptchaResponse
=
$ref
(
null
);
let
turnstileResponse
=
$ref
(
null
);
let
usernameAbortController
:
null
|
AbortController
=
$ref
(
null
);
let
emailAbortController
:
null
|
AbortController
=
$ref
(
null
);
const
shouldDisableSubmitting
=
$computed
(():
boolean
=>
{
return
submitting
||
...
...
@@ -141,14 +143,20 @@ function onChangeUsername(): void {
}
}
if
(
usernameAbortController
!=
null
)
{
usernameAbortController
.
abort
();
}
usernameState
=
'
wait
'
;
usernameAbortController
=
new
AbortController
();
os
.
api
(
'
username/available
'
,
{
username
,
}).
then
(
result
=>
{
}
,
undefined
,
usernameAbortController
.
signal
).
then
(
result
=>
{
usernameState
=
result
.
available
?
'
ok
'
:
'
unavailable
'
;
}).
catch
(()
=>
{
usernameState
=
'
error
'
;
}).
catch
((
err
)
=>
{
if
(
err
.
name
!==
'
AbortError
'
)
{
usernameState
=
'
error
'
;
}
});
}
...
...
@@ -158,11 +166,15 @@ function onChangeEmail(): void {
return
;
}
if
(
emailAbortController
!=
null
)
{
emailAbortController
.
abort
();
}
emailState
=
'
wait
'
;
emailAbortController
=
new
AbortController
();
os
.
api
(
'
email-address/available
'
,
{
emailAddress
:
email
,
}).
then
(
result
=>
{
}
,
undefined
,
emailAbortController
.
signal
).
then
(
result
=>
{
emailState
=
result
.
available
?
'
ok
'
:
result
.
reason
===
'
used
'
?
'
unavailable:used
'
:
result
.
reason
===
'
format
'
?
'
unavailable:format
'
:
...
...
@@ -170,8 +182,10 @@ function onChangeEmail(): void {
result
.
reason
===
'
mx
'
?
'
unavailable:mx
'
:
result
.
reason
===
'
smtp
'
?
'
unavailable:smtp
'
:
'
unavailable
'
;
}).
catch
(()
=>
{
emailState
=
'
error
'
;
}).
catch
((
err
)
=>
{
if
(
err
.
name
!==
'
AbortError
'
)
{
emailState
=
'
error
'
;
}
});
}
...
...
This diff is collapsed.
Click to expand it.
packages/frontend/src/scripts/api.ts
+
2
−
1
View file @
116dd097
...
...
@@ -5,7 +5,7 @@ import { $i } from '@/account';
export
const
pendingApiRequestsCount
=
ref
(
0
);
// Implements Misskey.api.ApiClient.request
export
function
api
<
E
extends
keyof
Endpoints
,
P
extends
Endpoints
[
E
][
'
req
'
]
>
(
endpoint
:
E
,
data
:
P
=
{}
as
any
,
token
?:
string
|
null
|
undefined
):
Promise
<
Endpoints
[
E
][
'
res
'
]
>
{
export
function
api
<
E
extends
keyof
Endpoints
,
P
extends
Endpoints
[
E
][
'
req
'
]
>
(
endpoint
:
E
,
data
:
P
=
{}
as
any
,
token
?:
string
|
null
|
undefined
,
signal
?:
AbortSignal
):
Promise
<
Endpoints
[
E
][
'
res
'
]
>
{
pendingApiRequestsCount
.
value
++
;
const
onFinally
=
()
=>
{
...
...
@@ -26,6 +26,7 @@ export function api<E extends keyof Endpoints, P extends Endpoints[E]['req']>(en
headers
:
{
'
Content-Type
'
:
'
application/json
'
,
},
signal
,
}).
then
(
async
(
res
)
=>
{
const
body
=
res
.
status
===
204
?
null
:
await
res
.
json
();
...
...
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