예제 #1
0
파일: settings.go 프로젝트: netxfly/wetalk
func (this *SettingsRouter) AvatarSetting() {
	this.Data["IsUserSettingPage"] = true
	this.TplNames = "settings/user_avatar.html"
	//need login
	if this.CheckLoginRedirect() {
		return
	}

	form := auth.UserAvatarForm{}
	form.SetFromUser(&this.User)
	this.SetFormSets(&form)
}
예제 #2
0
파일: settings.go 프로젝트: netxfly/wetalk
func (this *SettingsRouter) AvatarUpload() {
	this.Data["IsUserSettingPage"] = true
	this.TplNames = "settings/user_avatar.html"
	//need login and active
	if this.CheckLoginRedirect() {
		return
	}

	// get file object
	file, handler, err := this.Ctx.Request.FormFile("avatar")
	if err != nil {
		return
	}
	defer file.Close()
	mime := handler.Header.Get("Content-Type")
	if err := auth.UploadUserAvatarToQiniu(file, handler.Filename, mime, setting.QiniuAvatarBucket, &this.User); err != nil {
		return
	}

	userAvatarForm := auth.UserAvatarForm{}
	userAvatarForm.SetFromUser(&this.User)
	this.SetFormSets(&userAvatarForm)
	this.FlashRedirect("/settings/avatar", 302, "AvatarUploadSuccess")
}