예제 #1
0
파일: settings.go 프로젝트: varding/wetalk
// Profile implemented user profile settings page.
func (this *SettingsRouter) Profile() {
	this.Data["IsUserSettingPage"] = true
	this.TplNames = "settings/profile.html"

	// need login
	if this.CheckLoginRedirect() {
		return
	}

	form := auth.ProfileForm{Locale: this.Locale}

	form.SetFromUser(&this.User)
	this.SetFormSets(&form)
}
예제 #2
0
파일: settings.go 프로젝트: varding/wetalk
// ProfileSave implemented save user profile.
func (this *SettingsRouter) ProfileSave() {
	this.Data["IsUserSettingPage"] = true
	this.TplNames = "settings/profile.html"
	if this.CheckLoginRedirect() {
		return
	}

	action := this.GetString("action")
	if this.IsAjax() {
		switch action {
		case "send-verify-email":
			if this.User.IsActive {
				this.Data["json"] = false
			} else {
				auth.SendActiveMail(this.Locale, &this.User)
				this.Data["json"] = true
			}

			this.ServeJson()
			return
		}
		return
	}

	profileForm := auth.ProfileForm{Locale: this.Locale}
	profileForm.SetFromUser(&this.User)

	this.Data["Form"] = profileForm

	if this.ValidFormSets(&profileForm) {
		if err := profileForm.SaveUserProfile(&this.User); err != nil {
			beego.Error("ProfileSave: save-profile", err)
		}
		this.FlashRedirect("/settings/profile", 302, "ProfileSave")
		return
	}

}