mirror of https://github.com/cloudreve/Cloudreve
i18n: user route
parent
96daed26b4
commit
9464ee2103
2
assets
2
assets
|
@ -1 +1 @@
|
||||||
Subproject commit a1028e7e0ae96be4bb67d8c117cf39e07c207473
|
Subproject commit 02d93206cc5b943c34b5f5ac86c23dd96f5ef603
|
|
@ -172,6 +172,20 @@ const (
|
||||||
CodeSlavePingMaster = 40060
|
CodeSlavePingMaster = 40060
|
||||||
// Cloudreve 版本不一致
|
// Cloudreve 版本不一致
|
||||||
CodeVersionMismatch = 40061
|
CodeVersionMismatch = 40061
|
||||||
|
// 积分不足
|
||||||
|
CodeInsufficientCredit = 40062
|
||||||
|
// 用户组冲突
|
||||||
|
CodeGroupConflict = 40063
|
||||||
|
// 当前已处于此用户组中
|
||||||
|
CodeGroupInvalid = 40064
|
||||||
|
// 兑换码无效
|
||||||
|
CodeInvalidGiftCode = 40065
|
||||||
|
// 已绑定了QQ账号
|
||||||
|
CodeQQBindConflict = 40066
|
||||||
|
// QQ账号已被绑定其他账号
|
||||||
|
CodeQQBindOtherAccount = 40067
|
||||||
|
// QQ 未绑定对应账号
|
||||||
|
CodeQQNotLinked = 40068
|
||||||
// CodeDBError 数据库操作失败
|
// CodeDBError 数据库操作失败
|
||||||
CodeDBError = 50001
|
CodeDBError = 50001
|
||||||
// CodeEncryptError 加密失败
|
// CodeEncryptError 加密失败
|
||||||
|
|
|
@ -20,7 +20,7 @@ func StartLoginAuthn(c *gin.Context) {
|
||||||
userName := c.Param("username")
|
userName := c.Param("username")
|
||||||
expectedUser, err := model.GetActiveUserByEmail(userName)
|
expectedUser, err := model.GetActiveUserByEmail(userName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.JSON(200, serializer.Err(serializer.CodeUserNotFound, "User not exist", err))
|
c.JSON(200, serializer.Err(serializer.CodeUserNotFound, "", err))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,7 +54,7 @@ func FinishLoginAuthn(c *gin.Context) {
|
||||||
userName := c.Param("username")
|
userName := c.Param("username")
|
||||||
expectedUser, err := model.GetActiveUserByEmail(userName)
|
expectedUser, err := model.GetActiveUserByEmail(userName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.JSON(200, serializer.Err(serializer.CodeUserNotFound, "User not exist", err))
|
c.JSON(200, serializer.Err(serializer.CodeUserNotFound, "", err))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,7 +88,7 @@ func StartRegAuthn(c *gin.Context) {
|
||||||
|
|
||||||
instance, err := authn.NewAuthnInstance()
|
instance, err := authn.NewAuthnInstance()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.JSON(200, serializer.Err(serializer.CodeInternalSetting, "无法初始化Authn", err))
|
c.JSON(200, serializer.Err(serializer.CodeInitializeAuthn, "Cannot initialize authn", err))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -121,7 +121,7 @@ func FinishRegAuthn(c *gin.Context) {
|
||||||
|
|
||||||
instance, err := authn.NewAuthnInstance()
|
instance, err := authn.NewAuthnInstance()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.JSON(200, serializer.Err(serializer.CodeInternalSetting, "无法初始化Authn", err))
|
c.JSON(200, serializer.Err(serializer.CodeInitializeAuthn, "Cannot initialize authn", err))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -271,26 +271,26 @@ func UploadAvatar(c *gin.Context) {
|
||||||
maxSize := model.GetIntSetting("avatar_size", 2097152)
|
maxSize := model.GetIntSetting("avatar_size", 2097152)
|
||||||
if c.Request.ContentLength == -1 || c.Request.ContentLength > int64(maxSize) {
|
if c.Request.ContentLength == -1 || c.Request.ContentLength > int64(maxSize) {
|
||||||
request.BlackHole(c.Request.Body)
|
request.BlackHole(c.Request.Body)
|
||||||
c.JSON(200, serializer.Err(serializer.CodeUploadFailed, "头像尺寸太大", nil))
|
c.JSON(200, serializer.Err(serializer.CodeFileTooLarge, "", nil))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// 取得上传的文件
|
// 取得上传的文件
|
||||||
file, err := c.FormFile("avatar")
|
file, err := c.FormFile("avatar")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.JSON(200, serializer.Err(serializer.CodeIOFailed, "无法读取头像数据", err))
|
c.JSON(200, serializer.ParamErr("Failed to read avatar file data", err))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// 初始化头像
|
// 初始化头像
|
||||||
r, err := file.Open()
|
r, err := file.Open()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.JSON(200, serializer.Err(serializer.CodeIOFailed, "无法读取头像数据", err))
|
c.JSON(200, serializer.ParamErr("Failed to read avatar file data", err))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
avatar, err := thumb.NewThumbFromFile(r, file.Filename)
|
avatar, err := thumb.NewThumbFromFile(r, file.Filename)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.JSON(200, serializer.Err(serializer.CodeIOFailed, "无法解析图像数据", err))
|
c.JSON(200, serializer.ParamErr("Invalid image", err))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -298,7 +298,7 @@ func UploadAvatar(c *gin.Context) {
|
||||||
u := CurrentUser(c)
|
u := CurrentUser(c)
|
||||||
err = avatar.CreateAvatar(u.ID)
|
err = avatar.CreateAvatar(u.ID)
|
||||||
if err != nil {
|
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
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -306,7 +306,7 @@ func UploadAvatar(c *gin.Context) {
|
||||||
if err := u.Update(map[string]interface{}{
|
if err := u.Update(map[string]interface{}{
|
||||||
"avatar": "file",
|
"avatar": "file",
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
c.JSON(200, serializer.Err(serializer.CodeDBError, "无法更新头像", err))
|
c.JSON(200, serializer.DBErr("Failed to update avatar attribute", err))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue