mirror of
https://github.com/casdoor/casdoor.git
synced 2025-05-23 18:54:03 +08:00
Rename userObj to user.
This commit is contained in:
parent
39f2f609c3
commit
2934d6bdeb
@ -135,8 +135,8 @@ func (c *ApiController) GetAccount() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
username := c.GetSessionUser()
|
username := c.GetSessionUser()
|
||||||
userObj := object.GetUser(username)
|
user := object.GetUser(username)
|
||||||
resp = Response{Status: "ok", Msg: "", Data: userObj}
|
resp = Response{Status: "ok", Msg: "", Data: user}
|
||||||
|
|
||||||
c.Data["json"] = resp
|
c.Data["json"] = resp
|
||||||
c.ServeJSON()
|
c.ServeJSON()
|
||||||
@ -151,9 +151,9 @@ func (c *ApiController) GetAccount() {
|
|||||||
func (c *ApiController) UploadAvatar() {
|
func (c *ApiController) UploadAvatar() {
|
||||||
var resp Response
|
var resp Response
|
||||||
username := c.GetSessionUser()
|
username := c.GetSessionUser()
|
||||||
userObj := object.GetUser(username)
|
user := object.GetUser(username)
|
||||||
|
|
||||||
msg := object.CheckUserLogin(userObj.Owner+"/"+userObj.Name, c.Ctx.Request.Form.Get("password"))
|
msg := object.CheckUserLogin(user.Owner+"/"+user.Name, c.Ctx.Request.Form.Get("password"))
|
||||||
if msg != "" {
|
if msg != "" {
|
||||||
resp = Response{Status: "error", Msg: "Wrong password"}
|
resp = Response{Status: "error", Msg: "Wrong password"}
|
||||||
c.Data["json"] = resp
|
c.Data["json"] = resp
|
||||||
@ -171,15 +171,15 @@ func (c *ApiController) UploadAvatar() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dist, _ := base64.StdEncoding.DecodeString(avatarBase64[index+1:])
|
dist, _ := base64.StdEncoding.DecodeString(avatarBase64[index+1:])
|
||||||
msg = object.UploadAvatar(userObj.Name, dist)
|
msg = object.UploadAvatar(user.Name, dist)
|
||||||
if msg != "" {
|
if msg != "" {
|
||||||
resp = Response{Status: "error", Msg: msg}
|
resp = Response{Status: "error", Msg: msg}
|
||||||
c.Data["json"] = resp
|
c.Data["json"] = resp
|
||||||
c.ServeJSON()
|
c.ServeJSON()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
userObj.Avatar = object.GetAvatarPath() + userObj.Name + ".png?time=" + strconv.FormatInt(time.Now().UnixNano(), 10)
|
user.Avatar = object.GetAvatarPath() + user.Name + ".png?time=" + strconv.FormatInt(time.Now().UnixNano(), 10)
|
||||||
object.UpdateUser(userObj.Owner+"/"+userObj.Name, userObj)
|
object.UpdateUser(user.Owner+"/"+user.Name, user)
|
||||||
resp = Response{Status: "ok", Msg: "Successfully set avatar"}
|
resp = Response{Status: "ok", Msg: "Successfully set avatar"}
|
||||||
c.Data["json"] = resp
|
c.Data["json"] = resp
|
||||||
c.ServeJSON()
|
c.ServeJSON()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user