mirror of
https://github.com/casdoor/casdoor.git
synced 2025-07-03 12:30:19 +08:00
Fix avatar upload.
This commit is contained in:
@ -241,6 +241,10 @@ func (c *ApiController) UploadAvatar() {
|
||||
user := object.GetUser(userId)
|
||||
application := object.GetApplicationByUser(user)
|
||||
provider := application.GetStorageProvider()
|
||||
if provider == nil {
|
||||
c.ResponseError("No storage provider is found")
|
||||
return
|
||||
}
|
||||
|
||||
avatarBase64 := c.Ctx.Request.Form.Get("avatarfile")
|
||||
index := strings.Index(avatarBase64, ",")
|
||||
@ -259,8 +263,10 @@ func (c *ApiController) UploadAvatar() {
|
||||
c.ServeJSON()
|
||||
return
|
||||
}
|
||||
user.Avatar = fmt.Sprintf("%s%s.png?time=%s", object.GetAvatarPath(provider), user.GetId(), util.GetCurrentUnixTime())
|
||||
|
||||
user.Avatar = fmt.Sprintf("%s/%s.png?time=%s", util.UrlJoin(provider.Domain, "/avatar"), user.GetId(), util.GetCurrentUnixTime())
|
||||
object.UpdateUser(user.GetId(), user)
|
||||
|
||||
resp = Response{Status: "ok", Msg: ""}
|
||||
c.Data["json"] = resp
|
||||
c.ServeJSON()
|
||||
|
@ -43,7 +43,7 @@ func (c *ApiController) SendEmail() {
|
||||
|
||||
provider := app.GetEmailProvider()
|
||||
if provider == nil {
|
||||
c.ResponseError("No Email provider for this application.")
|
||||
c.ResponseError("No Email provider is found")
|
||||
return
|
||||
}
|
||||
|
||||
@ -112,7 +112,7 @@ func (c *ApiController) SendSms() {
|
||||
|
||||
provider := app.GetSmsProvider()
|
||||
if provider == nil {
|
||||
c.ResponseError("No SMS provider for this application.")
|
||||
c.ResponseError("No SMS provider is found")
|
||||
return
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user