func LinkAccount(ctx *context.Context) {
	ctx.Data["DisablePassword"] = !setting.Service.RequireExternalRegistrationPassword || setting.Service.AllowOnlyExternalRegistration
	ctx.Data["Title"] = ctx.Tr("link_account")
	ctx.Data["LinkAccountMode"] = true
	ctx.Data["EnableCaptcha"] = setting.Service.EnableCaptcha && setting.Service.RequireExternalRegistrationCaptcha
	ctx.Data["Captcha"] = context.GetImageCaptcha()
	ctx.Data["CaptchaType"] = setting.Service.CaptchaType
	ctx.Data["RecaptchaURL"] = setting.Service.RecaptchaURL
	ctx.Data["RecaptchaSitekey"] = setting.Service.RecaptchaSitekey
	ctx.Data["HcaptchaSitekey"] = setting.Service.HcaptchaSitekey
	ctx.Data["DisableRegistration"] = setting.Service.DisableRegistration
	ctx.Data["AllowOnlyInternalRegistration"] = setting.Service.AllowOnlyInternalRegistration
	ctx.Data["ShowRegistrationButton"] = false

	// use this to set the right link into the signIn and signUp templates in the link_account template
	ctx.Data["SignInLink"] = setting.AppSubURL + "/user/link_account_signin"
	ctx.Data["SignUpLink"] = setting.AppSubURL + "/user/link_account_signup"

	gothUser := ctx.Session.Get("linkAccountGothUser")
	if gothUser == nil {
		ctx.ServerError("UserSignIn", errors.New("not in LinkAccount session"))
		return
	}

	gu, _ := gothUser.(goth.User)
	uname := getUserName(&gu)
	email := gu.Email
	ctx.Data["user_name"] = uname
	ctx.Data["email"] = email

	if len(email) != 0 {
		u, err := models.GetUserByEmail(email)
		if err != nil && !models.IsErrUserNotExist(err) {
			ctx.ServerError("UserSignIn", err)
			return
		}
		if u != nil {
			ctx.Data["user_exists"] = true
		}
	} else if len(uname) != 0 {
		u, err := models.GetUserByName(uname)
		if err != nil && !models.IsErrUserNotExist(err) {
			ctx.ServerError("UserSignIn", err)
			return
		}
		if u != nil {
			ctx.Data["user_exists"] = true
		}
	}

	ctx.HTML(http.StatusOK, tplLinkAccount)
}
// LinkAccount shows the page where the user can decide to login or create a new account
LinkAccount shows the page where the user can decide to login or create a new account
// LinkAccount shows the page where the user can decide to login or create a new account
func LinkAccount(ctx *context.Context) {
	ctx.Data["DisablePassword"] = !setting.Service.RequireExternalRegistrationPassword || setting.Service.AllowOnlyExternalRegistration
	ctx.Data["Title"] = ctx.Tr("link_account")
	ctx.Data["LinkAccountMode"] = true
	ctx.Data["EnableCaptcha"] = setting.Service.EnableCaptcha && setting.Service.RequireExternalRegistrationCaptcha
	ctx.Data["Captcha"] = context.GetImageCaptcha()
	ctx.Data["CaptchaType"] = setting.Service.CaptchaType
	ctx.Data["RecaptchaURL"] = setting.Service.RecaptchaURL
	ctx.Data["RecaptchaSitekey"] = setting.Service.RecaptchaSitekey
	ctx.Data["HcaptchaSitekey"] = setting.Service.HcaptchaSitekey
	ctx.Data["DisableRegistration"] = setting.Service.DisableRegistration
	ctx.Data["AllowOnlyInternalRegistration"] = setting.Service.AllowOnlyInternalRegistration
	ctx.Data["ShowRegistrationButton"] = false
	ctx.Data["SignInLink"] = setting.AppSubURL + "/user/link_account_signin"
	ctx.Data["SignUpLink"] = setting.AppSubURL + "/user/link_account_signup"
	gothUser := ctx.Session.Get("linkAccountGothUser")
	if gothUser == nil {
		ctx.ServerError("UserSignIn", errors.New("not in LinkAccount session"))
		return
	}
	gu, _ := gothUser.(goth.User)
	uname := getUserName(&gu)
	email := gu.Email
	ctx.Data["user_name"] = uname
	ctx.Data["email"] = email
	if len(email) != 0 {
		u, err := models.GetUserByEmail(email)
		if err != nil && !models.IsErrUserNotExist(err) {
			ctx.ServerError("UserSignIn", err)
			return
		}
		if u != nil {
			ctx.Data["user_exists"] = true
		}
	} else if len(uname) != 0 {
		u, err := models.GetUserByName(uname)
		if err != nil && !models.IsErrUserNotExist(err) {
			ctx.ServerError("UserSignIn", err)
			return
		}
		if u != nil {
			ctx.Data["user_exists"] = true
		}
	}
	ctx.HTML(http.StatusOK, tplLinkAccount)
}
func LinkAccount ( ctx * context . Context ) { ctx . Data [ " " ] = ! setting . Service . RequireExternalRegistrationPassword || setting . Service . AllowOnlyExternalRegistration ctx . Data [ " " ] = ctx . Tr ( " " ) ctx . Data [ " " ] = true ctx . Data [ " " ] = setting . Service . EnableCaptcha && setting . Service . RequireExternalRegistrationCaptcha ctx . Data [ " " ] = context . GetImageCaptcha ( ) ctx . Data [ " " ] = setting . Service . CaptchaType ctx . Data [ " " ] = setting . Service . RecaptchaURL ctx . Data [ " " ] = setting . Service . RecaptchaSitekey ctx . Data [ " " ] = setting . Service . HcaptchaSitekey ctx . Data [ " " ] = setting . Service . DisableRegistration ctx . Data [ " " ] = setting . Service . AllowOnlyInternalRegistration ctx . Data [ " " ] = false ctx . Data [ " " ] = setting . AppSubURL + " " ctx . Data [ " " ] = setting . AppSubURL + " " gothUser := ctx . Session . Get ( " " ) if gothUser == nil { ctx . ServerError ( " " , errors . New ( " " ) ) return } gu , _ := gothUser . ( goth . User ) uname := getUserName ( & gu ) email := gu . Email ctx . Data [ " " ] = uname ctx . Data [ " " ] = email if len ( email ) != 0 { u , err := models . GetUserByEmail ( email ) if err != nil && ! models . IsErrUserNotExist ( err ) { ctx . ServerError ( " " , err ) return } if u != nil { ctx . Data [ " " ] = true } } else if len ( uname ) != 0 { u , err := models . GetUserByName ( uname ) if err != nil && ! models . IsErrUserNotExist ( err ) { ctx . ServerError ( " " , err ) return } if u != nil { ctx . Data [ " " ] = true } } ctx . HTML ( http . StatusOK , tplLinkAccount ) }
LinkAccount shows the page where the user can decide to login or create a new account
LinkAccount shows the page where the user can decide to login or create a new account
// use this to set the right link into the signIn and signUp templates in the link_account template