コード例 #1
0
ファイル: settings.go プロジェクト: trigrass2/wego
// Profile implemented user profile settings page.
func (this *ProfileRouter) Get() error {
	this.Data["IsUserSettingPage"] = true

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

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

	form.SetFromUser(&this.User)
	this.SetFormSets(&form)
	return this.Render("settings/profile.html", this.Data)
}
コード例 #2
0
ファイル: settings.go プロジェクト: trigrass2/wego
// ProfileSave implemented save user profile.
func (this *ProfileRouter) Post() {
	this.Data["IsUserSettingPage"] = true
	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(this.Data)
			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 {
			log.Error("ProfileSave: save-profile", err)
		}
		this.FlashRedirect("/settings/profile", 302, "ProfileSave")
		return
	}

	this.Render("settings/profile.html", this.Data)
}