mirror of
https://github.com/casdoor/casdoor.git
synced 2025-07-03 12:30:19 +08:00
feat: integrate Storage config into providers (#198)
Signed-off-by: Kininaru <shiftregister233@outlook.com>
This commit is contained in:
@ -237,6 +237,8 @@ func (c *ApiController) UploadAvatar() {
|
||||
var resp Response
|
||||
|
||||
user := object.GetUser(userId)
|
||||
application := object.GetApplicationByUser(user)
|
||||
provider := application.GetStorageProvider()
|
||||
|
||||
avatarBase64 := c.Ctx.Request.Form.Get("avatarfile")
|
||||
index := strings.Index(avatarBase64, ",")
|
||||
@ -248,14 +250,14 @@ func (c *ApiController) UploadAvatar() {
|
||||
}
|
||||
|
||||
dist, _ := base64.StdEncoding.DecodeString(avatarBase64[index+1:])
|
||||
msg := object.UploadAvatar(user.GetId(), dist)
|
||||
msg := object.UploadAvatar(provider, user.GetId(), dist)
|
||||
if msg != "" {
|
||||
resp = Response{Status: "error", Msg: msg}
|
||||
c.Data["json"] = resp
|
||||
c.ServeJSON()
|
||||
return
|
||||
}
|
||||
user.Avatar = fmt.Sprintf("%s%s.png?time=%s", object.GetAvatarPath(), user.GetId(), util.GetCurrentUnixTime())
|
||||
user.Avatar = fmt.Sprintf("%s%s.png?time=%s", object.GetAvatarPath(provider), user.GetId(), util.GetCurrentUnixTime())
|
||||
object.UpdateUser(user.GetId(), user)
|
||||
resp = Response{Status: "ok", Msg: ""}
|
||||
c.Data["json"] = resp
|
||||
|
@ -264,7 +264,7 @@ func (c *ApiController) Login() {
|
||||
//}
|
||||
|
||||
//if len(object.GetMemberAvatar(userId)) == 0 {
|
||||
// avatar := UploadAvatarToOSS(res.Avatar, userId)
|
||||
// avatar := UploadAvatarToStorage(res.Avatar, userId)
|
||||
// object.LinkMemberAccount(userId, "avatar", avatar)
|
||||
//}
|
||||
|
||||
@ -357,7 +357,7 @@ func (c *ApiController) Login() {
|
||||
resp = &Response{Status: "error", Msg: "Failed to link user account", Data: isLinked}
|
||||
}
|
||||
//if len(object.GetMemberAvatar(userId)) == 0 {
|
||||
// avatar := UploadAvatarToOSS(tempUserAccount.AvatarUrl, userId)
|
||||
// avatar := UploadAvatarToStorage(tempUserAccount.AvatarUrl, userId)
|
||||
// object.LinkUserAccount(userId, "avatar", avatar)
|
||||
//}
|
||||
}
|
||||
|
Reference in New Issue
Block a user