Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ユーザー登録のエラーメッセージをいい感じに #4103

Merged
merged 1 commit into from Oct 23, 2023

Conversation

mehm8128
Copy link
Member

@mehm8128 mehm8128 commented Oct 18, 2023

close #4093

ここらへん参考にしたり実際に叩いてみていくつか日本語化しました
https://github.com/traPtitech/traQ/blob/89883358779100687fedc38ac321625242dfda2b/router/v3/users.go#L63-L86
https://github.com/traPtitech/traQ/blob/89883358779100687fedc38ac321625242dfda2b/utils/validator/rules.go#L20-L40

} catch (e) {
const err = e as AxiosError<{ message: string }>
if (!err.response) return
// TODO 修正
const message: string = err.response.data.message
const status = err.response.status
switch (message) {
case 'name: cannot be blank; password: cannot be blank.':
state.error = 'IDとパスワードを入力してください'
break
case 'password: cannot be blank.':
state.error = 'パスワードを入力してください'
break
case 'name: cannot be blank.':
state.error = 'IDを入力してください'
break
case 'invalid name':
state.error = `"${state.name}" は存在しないユーザーIDです`
break
case 'password or id is wrong':
state.error = 'IDまたはパスワードが誤っています'
break
case 'You have already logged in. Please logout once.':
state.error = 'ログイン済みでした。リロードします'
// 起きないようにするのがよいが (https://github.com/traPtitech/traQ_S-UI/issues/2260)
// とりあえずリロードする
location.reload()
break
default:
state.error = `${status}: ${message}`
}

バリデーションのしかたは何も考えずにここから取ってきてます

@mehm8128 mehm8128 self-assigned this Oct 18, 2023
@github-actions
Copy link

@codecov
Copy link

codecov bot commented Oct 18, 2023

Codecov Report

All modified lines are covered by tests ✅

📢 Thoughts on this report? Let us know!.

@mehm8128 mehm8128 marked this pull request as ready for review October 18, 2023 13:44
Copy link
Contributor

@nokhnaton nokhnaton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

良さそうです!

@mehm8128 mehm8128 merged commit b15f57e into master Oct 23, 2023
12 checks passed
@mehm8128 mehm8128 deleted the fix/register_error_message branch October 23, 2023 14:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

新規ユーザー作成の際のエラーメッセージが分かりにくい
2 participants