i18n: user route

pull/1491/head
HFO4 2 years ago
parent 96daed26b4
commit 9464ee2103

@ -1 +1 @@
Subproject commit a1028e7e0ae96be4bb67d8c117cf39e07c207473
Subproject commit 02d93206cc5b943c34b5f5ac86c23dd96f5ef603

@ -172,6 +172,20 @@ const (
CodeSlavePingMaster = 40060
// Cloudreve 版本不一致
CodeVersionMismatch = 40061
// 积分不足
CodeInsufficientCredit = 40062
// 用户组冲突
CodeGroupConflict = 40063
// 当前已处于此用户组中
CodeGroupInvalid = 40064
// 兑换码无效
CodeInvalidGiftCode = 40065
// 已绑定了QQ账号
CodeQQBindConflict = 40066
// QQ账号已被绑定其他账号
CodeQQBindOtherAccount = 40067
// QQ 未绑定对应账号
CodeQQNotLinked = 40068
// CodeDBError 数据库操作失败
CodeDBError = 50001
// CodeEncryptError 加密失败

@ -20,7 +20,7 @@ func StartLoginAuthn(c *gin.Context) {
userName := c.Param("username")
expectedUser, err := model.GetActiveUserByEmail(userName)
if err != nil {
c.JSON(200, serializer.Err(serializer.CodeUserNotFound, "User not exist", err))
c.JSON(200, serializer.Err(serializer.CodeUserNotFound, "", err))
return
}
@ -54,7 +54,7 @@ func FinishLoginAuthn(c *gin.Context) {
userName := c.Param("username")
expectedUser, err := model.GetActiveUserByEmail(userName)
if err != nil {
c.JSON(200, serializer.Err(serializer.CodeUserNotFound, "User not exist", err))
c.JSON(200, serializer.Err(serializer.CodeUserNotFound, "", err))
return
}
@ -88,7 +88,7 @@ func StartRegAuthn(c *gin.Context) {
instance, err := authn.NewAuthnInstance()
if err != nil {
c.JSON(200, serializer.Err(serializer.CodeInternalSetting, "无法初始化Authn", err))
c.JSON(200, serializer.Err(serializer.CodeInitializeAuthn, "Cannot initialize authn", err))
return
}
@ -121,7 +121,7 @@ func FinishRegAuthn(c *gin.Context) {
instance, err := authn.NewAuthnInstance()
if err != nil {
c.JSON(200, serializer.Err(serializer.CodeInternalSetting, "无法初始化Authn", err))
c.JSON(200, serializer.Err(serializer.CodeInitializeAuthn, "Cannot initialize authn", err))
return
}
@ -271,26 +271,26 @@ func UploadAvatar(c *gin.Context) {
maxSize := model.GetIntSetting("avatar_size", 2097152)
if c.Request.ContentLength == -1 || c.Request.ContentLength > int64(maxSize) {
request.BlackHole(c.Request.Body)
c.JSON(200, serializer.Err(serializer.CodeUploadFailed, "头像尺寸太大", nil))
c.JSON(200, serializer.Err(serializer.CodeFileTooLarge, "", nil))
return
}
// 取得上传的文件
file, err := c.FormFile("avatar")
if err != nil {
c.JSON(200, serializer.Err(serializer.CodeIOFailed, "无法读取头像数据", err))
c.JSON(200, serializer.ParamErr("Failed to read avatar file data", err))
return
}
// 初始化头像
r, err := file.Open()
if err != nil {
c.JSON(200, serializer.Err(serializer.CodeIOFailed, "无法读取头像数据", err))
c.JSON(200, serializer.ParamErr("Failed to read avatar file data", err))
return
}
avatar, err := thumb.NewThumbFromFile(r, file.Filename)
if err != nil {
c.JSON(200, serializer.Err(serializer.CodeIOFailed, "无法解析图像数据", err))
c.JSON(200, serializer.ParamErr("Invalid image", err))
return
}
@ -298,7 +298,7 @@ func UploadAvatar(c *gin.Context) {
u := CurrentUser(c)
err = avatar.CreateAvatar(u.ID)
if err != nil {
c.JSON(200, serializer.Err(serializer.CodeIOFailed, "无法创建头像", err))
c.JSON(200, serializer.Err(serializer.CodeIOFailed, "Failed to create avatar file", err))
return
}
@ -306,7 +306,7 @@ func UploadAvatar(c *gin.Context) {
if err := u.Update(map[string]interface{}{
"avatar": "file",
}); err != nil {
c.JSON(200, serializer.Err(serializer.CodeDBError, "无法更新头像", err))
c.JSON(200, serializer.DBErr("Failed to update avatar attribute", err))
return
}

Loading…
Cancel
Save