func Activate(ctx *context.Context) {
	code := ctx.Query("code")

	if len(code) == 0 {
		ctx.Data["IsActivatePage"] = true
		if ctx.User == nil || ctx.User.IsActive {
			ctx.NotFound("invalid user", nil)
			return
		}
		// Resend confirmation email.
		if setting.Service.RegisterEmailConfirm {
			if ctx.Cache.IsExist("MailResendLimit_" + ctx.User.LowerName) {
				ctx.Data["ResendLimited"] = true
			} else {
				ctx.Data["ActiveCodeLives"] = timeutil.MinutesToFriendly(setting.Service.ActiveCodeLives, ctx.Locale.Language())
				mailer.SendActivateAccountMail(ctx.Locale, ctx.User)

				if err := ctx.Cache.Put("MailResendLimit_"+ctx.User.LowerName, ctx.User.LowerName, 180); err != nil {
					log.Error("Set cache(MailResendLimit) fail: %v", err)
				}
			}
		} else {
			ctx.Data["ServiceNotEnabled"] = true
		}
		ctx.HTML(http.StatusOK, TplActivate)
		return
	}

	user := models.VerifyUserActiveCode(code)
	// if code is wrong
	if user == nil {
		ctx.Data["IsActivateFailed"] = true
		ctx.HTML(http.StatusOK, TplActivate)
		return
	}

	// if account is local account, verify password
	if user.LoginSource == 0 {
		ctx.Data["Code"] = code
		ctx.Data["NeedsPassword"] = true
		ctx.HTML(http.StatusOK, TplActivate)
		return
	}

	handleAccountActivation(ctx, user)
}
// Activate render activate user page
Activate render activate user page
// Activate render activate user page
func Activate(ctx *context.Context) {
	code := ctx.Query("code")
	if len(code) == 0 {
		ctx.Data["IsActivatePage"] = true
		if ctx.User == nil || ctx.User.IsActive {
			ctx.NotFound("invalid user", nil)
			return
		}
		if setting.Service.RegisterEmailConfirm {
			if ctx.Cache.IsExist("MailResendLimit_" + ctx.User.LowerName) {
				ctx.Data["ResendLimited"] = true
			} else {
				ctx.Data["ActiveCodeLives"] = timeutil.MinutesToFriendly(setting.Service.ActiveCodeLives, ctx.Locale.Language())
				mailer.SendActivateAccountMail(ctx.Locale, ctx.User)
				if err := ctx.Cache.Put("MailResendLimit_"+ctx.User.LowerName, ctx.User.LowerName, 180); err != nil {
					log.Error("Set cache(MailResendLimit) fail: %v", err)
				}
			}
		} else {
			ctx.Data["ServiceNotEnabled"] = true
		}
		ctx.HTML(http.StatusOK, TplActivate)
		return
	}
	user := models.VerifyUserActiveCode(code)
	if user == nil {
		ctx.Data["IsActivateFailed"] = true
		ctx.HTML(http.StatusOK, TplActivate)
		return
	}
	if user.LoginSource == 0 {
		ctx.Data["Code"] = code
		ctx.Data["NeedsPassword"] = true
		ctx.HTML(http.StatusOK, TplActivate)
		return
	}
	handleAccountActivation(ctx, user)
}
func Activate ( ctx * context . Context ) { code := ctx . Query ( " " ) if len ( code ) == 0 { ctx . Data [ " " ] = true if ctx . User == nil || ctx . User . IsActive { ctx . NotFound ( " " , nil ) return } if setting . Service . RegisterEmailConfirm { if ctx . Cache . IsExist ( " " + ctx . User . LowerName ) { ctx . Data [ " " ] = true } else { ctx . Data [ " " ] = timeutil . MinutesToFriendly ( setting . Service . ActiveCodeLives , ctx . Locale . Language ( ) ) mailer . SendActivateAccountMail ( ctx . Locale , ctx . User ) if err := ctx . Cache . Put ( " " + ctx . User . LowerName , ctx . User . LowerName , 180 ) ; err != nil { log . Error ( " " , err ) } } } else { ctx . Data [ " " ] = true } ctx . HTML ( http . StatusOK , TplActivate ) return } user := models . VerifyUserActiveCode ( code ) if user == nil { ctx . Data [ " " ] = true ctx . HTML ( http . StatusOK , TplActivate ) return } if user . LoginSource == 0 { ctx . Data [ " " ] = code ctx . Data [ " " ] = true ctx . HTML ( http . StatusOK , TplActivate ) return } handleAccountActivation ( ctx , user ) }
Activate render activate user page
Activate render activate user page
// Resend confirmation email. // if code is wrong // if account is local account, verify password