func SignUpPost(ctx *context.Context) {
	form := web.GetForm(ctx).(*forms.RegisterForm)
	ctx.Data["Title"] = ctx.Tr("sign_up")

	ctx.Data["SignUpLink"] = setting.AppSubURL + "/user/sign_up"

	ctx.Data["EnableCaptcha"] = setting.Service.EnableCaptcha
	ctx.Data["RecaptchaURL"] = setting.Service.RecaptchaURL
	ctx.Data["Captcha"] = context.GetImageCaptcha()
	ctx.Data["CaptchaType"] = setting.Service.CaptchaType
	ctx.Data["RecaptchaSitekey"] = setting.Service.RecaptchaSitekey
	ctx.Data["HcaptchaSitekey"] = setting.Service.HcaptchaSitekey
	ctx.Data["PageIsSignUp"] = true

	//Permission denied if DisableRegistration or AllowOnlyExternalRegistration options are true
	if setting.Service.DisableRegistration || setting.Service.AllowOnlyExternalRegistration {
		ctx.Error(http.StatusForbidden)
		return
	}

	if ctx.HasError() {
		ctx.HTML(http.StatusOK, tplSignUp)
		return
	}

	if setting.Service.EnableCaptcha {
		var valid bool
		var err error
		switch setting.Service.CaptchaType {
		case setting.ImageCaptcha:
			valid = context.GetImageCaptcha().VerifyReq(ctx.Req)
		case setting.ReCaptcha:
			valid, err = recaptcha.Verify(ctx, form.GRecaptchaResponse)
		case setting.HCaptcha:
			valid, err = hcaptcha.Verify(ctx, form.HcaptchaResponse)
		default:
			ctx.ServerError("Unknown Captcha Type", fmt.Errorf("Unknown Captcha Type: %s", setting.Service.CaptchaType))
			return
		}
		if err != nil {
			log.Debug("%s", err.Error())
		}

		if !valid {
			ctx.Data["Err_Captcha"] = true
			ctx.RenderWithErr(ctx.Tr("form.captcha_incorrect"), tplSignUp, &form)
			return
		}
	}

	if !form.IsEmailDomainAllowed() {
		ctx.RenderWithErr(ctx.Tr("auth.email_domain_blacklisted"), tplSignUp, &form)
		return
	}

	if form.Password != form.Retype {
		ctx.Data["Err_Password"] = true
		ctx.RenderWithErr(ctx.Tr("form.password_not_match"), tplSignUp, &form)
		return
	}
	if len(form.Password) < setting.MinPasswordLength {
		ctx.Data["Err_Password"] = true
		ctx.RenderWithErr(ctx.Tr("auth.password_too_short", setting.MinPasswordLength), tplSignUp, &form)
		return
	}
	if !password.IsComplexEnough(form.Password) {
		ctx.Data["Err_Password"] = true
		ctx.RenderWithErr(password.BuildComplexityError(ctx), tplSignUp, &form)
		return
	}
	pwned, err := password.IsPwned(ctx, form.Password)
	if pwned {
		errMsg := ctx.Tr("auth.password_pwned")
		if err != nil {
			log.Error(err.Error())
			errMsg = ctx.Tr("auth.password_pwned_err")
		}
		ctx.Data["Err_Password"] = true
		ctx.RenderWithErr(errMsg, tplSignUp, &form)
		return
	}

	u := &models.User{
		Name:     form.UserName,
		Email:    form.Email,
		Passwd:   form.Password,
		IsActive: !(setting.Service.RegisterEmailConfirm || setting.Service.RegisterManualConfirm),
	}

	if !createAndHandleCreatedUser(ctx, tplSignUp, form, u, nil, false) {
		// error already handled
		return
	}

	ctx.Flash.Success(ctx.Tr("auth.sign_up_successful"))
	handleSignInFull(ctx, u, false, true)
}
// SignUpPost response for sign up information submission
SignUpPost response for sign up information submission
// SignUpPost response for sign up information submission
func SignUpPost(ctx *context.Context) {
	form := web.GetForm(ctx).(*forms.RegisterForm)
	ctx.Data["Title"] = ctx.Tr("sign_up")
	ctx.Data["SignUpLink"] = setting.AppSubURL + "/user/sign_up"
	ctx.Data["EnableCaptcha"] = setting.Service.EnableCaptcha
	ctx.Data["RecaptchaURL"] = setting.Service.RecaptchaURL
	ctx.Data["Captcha"] = context.GetImageCaptcha()
	ctx.Data["CaptchaType"] = setting.Service.CaptchaType
	ctx.Data["RecaptchaSitekey"] = setting.Service.RecaptchaSitekey
	ctx.Data["HcaptchaSitekey"] = setting.Service.HcaptchaSitekey
	ctx.Data["PageIsSignUp"] = true
	if setting.Service.DisableRegistration || setting.Service.AllowOnlyExternalRegistration {
		ctx.Error(http.StatusForbidden)
		return
	}
	if ctx.HasError() {
		ctx.HTML(http.StatusOK, tplSignUp)
		return
	}
	if setting.Service.EnableCaptcha {
		var valid bool
		var err error
		switch setting.Service.CaptchaType {
		case setting.ImageCaptcha:
			valid = context.GetImageCaptcha().VerifyReq(ctx.Req)
		case setting.ReCaptcha:
			valid, err = recaptcha.Verify(ctx, form.GRecaptchaResponse)
		case setting.HCaptcha:
			valid, err = hcaptcha.Verify(ctx, form.HcaptchaResponse)
		default:
			ctx.ServerError("Unknown Captcha Type", fmt.Errorf("Unknown Captcha Type: %s", setting.Service.CaptchaType))
			return
		}
		if err != nil {
			log.Debug("%s", err.Error())
		}
		if !valid {
			ctx.Data["Err_Captcha"] = true
			ctx.RenderWithErr(ctx.Tr("form.captcha_incorrect"), tplSignUp, &form)
			return
		}
	}
	if !form.IsEmailDomainAllowed() {
		ctx.RenderWithErr(ctx.Tr("auth.email_domain_blacklisted"), tplSignUp, &form)
		return
	}
	if form.Password != form.Retype {
		ctx.Data["Err_Password"] = true
		ctx.RenderWithErr(ctx.Tr("form.password_not_match"), tplSignUp, &form)
		return
	}
	if len(form.Password) < setting.MinPasswordLength {
		ctx.Data["Err_Password"] = true
		ctx.RenderWithErr(ctx.Tr("auth.password_too_short", setting.MinPasswordLength), tplSignUp, &form)
		return
	}
	if !password.IsComplexEnough(form.Password) {
		ctx.Data["Err_Password"] = true
		ctx.RenderWithErr(password.BuildComplexityError(ctx), tplSignUp, &form)
		return
	}
	pwned, err := password.IsPwned(ctx, form.Password)
	if pwned {
		errMsg := ctx.Tr("auth.password_pwned")
		if err != nil {
			log.Error(err.Error())
			errMsg = ctx.Tr("auth.password_pwned_err")
		}
		ctx.Data["Err_Password"] = true
		ctx.RenderWithErr(errMsg, tplSignUp, &form)
		return
	}
	u := &models.User{
		Name:     form.UserName,
		Email:    form.Email,
		Passwd:   form.Password,
		IsActive: !(setting.Service.RegisterEmailConfirm || setting.Service.RegisterManualConfirm),
	}
	if !createAndHandleCreatedUser(ctx, tplSignUp, form, u, nil, false) {
		return
	}
	ctx.Flash.Success(ctx.Tr("auth.sign_up_successful"))
	handleSignInFull(ctx, u, false, true)
}
func SignUpPost ( ctx * context . Context ) { form := web . GetForm ( ctx ) . ( * forms . RegisterForm ) ctx . Data [ " " ] = ctx . Tr ( " " ) ctx . Data [ " " ] = setting . AppSubURL + " " ctx . Data [ " " ] = setting . Service . EnableCaptcha ctx . Data [ " " ] = setting . Service . RecaptchaURL ctx . Data [ " " ] = context . GetImageCaptcha ( ) ctx . Data [ " " ] = setting . Service . CaptchaType ctx . Data [ " " ] = setting . Service . RecaptchaSitekey ctx . Data [ " " ] = setting . Service . HcaptchaSitekey ctx . Data [ " " ] = true if setting . Service . DisableRegistration || setting . Service . AllowOnlyExternalRegistration { ctx . Error ( http . StatusForbidden ) return } if ctx . HasError ( ) { ctx . HTML ( http . StatusOK , tplSignUp ) return } if setting . Service . EnableCaptcha { var valid bool var err error switch setting . Service . CaptchaType { case setting . ImageCaptcha : valid = context . GetImageCaptcha ( ) . VerifyReq ( ctx . Req ) case setting . ReCaptcha : valid , err = recaptcha . Verify ( ctx , form . GRecaptchaResponse ) case setting . HCaptcha : valid , err = hcaptcha . Verify ( ctx , form . HcaptchaResponse ) default : ctx . ServerError ( " " , fmt . Errorf ( " " , setting . Service . CaptchaType ) ) return } if err != nil { log . Debug ( " " , err . Error ( ) ) } if ! valid { ctx . Data [ " " ] = true ctx . RenderWithErr ( ctx . Tr ( " " ) , tplSignUp , & form ) return } } if ! form . IsEmailDomainAllowed ( ) { ctx . RenderWithErr ( ctx . Tr ( " " ) , tplSignUp , & form ) return } if form . Password != form . Retype { ctx . Data [ " " ] = true ctx . RenderWithErr ( ctx . Tr ( " " ) , tplSignUp , & form ) return } if len ( form . Password ) < setting . MinPasswordLength { ctx . Data [ " " ] = true ctx . RenderWithErr ( ctx . Tr ( " " , setting . MinPasswordLength ) , tplSignUp , & form ) return } if ! password . IsComplexEnough ( form . Password ) { ctx . Data [ " " ] = true ctx . RenderWithErr ( password . BuildComplexityError ( ctx ) , tplSignUp , & form ) return } pwned , err := password . IsPwned ( ctx , form . Password ) if pwned { errMsg := ctx . Tr ( " " ) if err != nil { log . Error ( err . Error ( ) ) errMsg = ctx . Tr ( " " ) } ctx . Data [ " " ] = true ctx . RenderWithErr ( errMsg , tplSignUp , & form ) return } u := & models . User { Name : form . UserName , Email : form . Email , Passwd : form . Password , IsActive : ! ( setting . Service . RegisterEmailConfirm || setting . Service . RegisterManualConfirm ) , } if ! createAndHandleCreatedUser ( ctx , tplSignUp , form , u , nil , false ) { return } ctx . Flash . Success ( ctx . Tr ( " " ) ) handleSignInFull ( ctx , u , false , true ) }
SignUpPost response for sign up information submission
SignUpPost response for sign up information submission
//Permission denied if DisableRegistration or AllowOnlyExternalRegistration options are true // error already handled