Skip to content

Commit

Permalink
fix(sidebar/login): cannot select a name with the same email upon log…
Browse files Browse the repository at this point in the history
…in (#781)
  • Loading branch information
qwqcode committed Mar 4, 2024
1 parent 5322f90 commit 929faf0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
5 changes: 2 additions & 3 deletions server/handler/user_login.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ type ResponseUserLogin struct {
// @Accept json
// @Produce json
// @Success 200 {object} ResponseUserLogin
// @Failure 400 {object} Map{msg=string, data=object{need_name_select=[]string}} "Multiple users with the same email address are matched"
// @Failure 400 {object} Map{msg=string,data=object{need_name_select=[]string}} "Multiple users with the same email address are matched"
// @Failure 401 {object} Map{msg=string}
// @Failure 500 {object} Map{msg=string}
// @Router /user/access_token [post]
Expand Down Expand Up @@ -56,11 +56,10 @@ func UserLogin(app *core.App, router fiber.Router) {
for _, u := range users {
userNames = append(userNames, u.Name)
}
return common.RespData(c, common.Map{
return common.RespError(c, 400, "Need to select username", common.Map{
// 前端需做处理让用户选择用户名,
// 之后再发起带 name 参数的请求
"need_name_select": userNames,
"msg": "Need to select username",
})
}
} else {
Expand Down
5 changes: 3 additions & 2 deletions ui/artalk-sidebar/src/pages/login.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
</route>

<script setup lang="ts">
import type { ArtalkType } from 'artalk'
import { getArtalk } from '../global'
import { useUserStore } from '../stores/user'
Expand Down Expand Up @@ -54,11 +55,11 @@ function login(username?: string) {
})
useUserStore().sync()
router.replace('/')
}).catch((e) => {
}).catch((e: ArtalkType.FetchError) => {
if (e.data?.need_name_select) {
userSelector.value = e.data?.need_name_select
} else {
loginErr.value = e.msg || t('loginFailure')
loginErr.value = e.message || t('loginFailure')
}
})
}
Expand Down

0 comments on commit 929faf0

Please sign in to comment.