func handleUserCreated(ctx *context.Context, u *models.User, gothUser *goth.User) (ok bool) {
	// Auto-set admin for the only user.
	if models.CountUsers() == 1 {
		u.IsAdmin = true
		u.IsActive = true
		u.SetLastLogin()
		if err := models.UpdateUserCols(u, "is_admin", "is_active", "last_login_unix"); err != nil {
			ctx.ServerError("UpdateUser", err)
			return
		}
	}

	// update external user information
	if gothUser != nil {
		if err := models.UpdateExternalUser(u, *gothUser); err != nil {
			log.Error("UpdateExternalUser failed: %v", err)
		}
	}

	// Send confirmation email
	if !u.IsActive && u.ID > 1 {
		mailer.SendActivateAccountMail(ctx.Locale, u)

		ctx.Data["IsSendRegisterMail"] = true
		ctx.Data["Email"] = u.Email
		ctx.Data["ActiveCodeLives"] = timeutil.MinutesToFriendly(setting.Service.ActiveCodeLives, ctx.Locale.Language())
		ctx.HTML(http.StatusOK, TplActivate)

		if err := ctx.Cache.Put("MailResendLimit_"+u.LowerName, u.LowerName, 180); err != nil {
			log.Error("Set cache(MailResendLimit) fail: %v", err)
		}
		return
	}

	return true
}
// handleUserCreated does additional steps after a new user is created.
// It auto-sets admin for the only user, updates the optional external user and
// sends a confirmation email if required.
handleUserCreated does additional steps after a new user is created.
It auto-sets admin for the only user, updates the optional external user and
sends a confirmation email if required.
// handleUserCreated does additional steps after a new user is created . // It auto - sets admin for the only user updates the optional external user and // sends a confirmation email if required .
func handleUserCreated(ctx *context.Context, u *models.User, gothUser *goth.User) (ok bool) {
	if models.CountUsers() == 1 {
		u.IsAdmin = true
		u.IsActive = true
		u.SetLastLogin()
		if err := models.UpdateUserCols(u, "is_admin", "is_active", "last_login_unix"); err != nil {
			ctx.ServerError("UpdateUser", err)
			return
		}
	}
	if gothUser != nil {
		if err := models.UpdateExternalUser(u, *gothUser); err != nil {
			log.Error("UpdateExternalUser failed: %v", err)
		}
	}
	if !u.IsActive && u.ID > 1 {
		mailer.SendActivateAccountMail(ctx.Locale, u)
		ctx.Data["IsSendRegisterMail"] = true
		ctx.Data["Email"] = u.Email
		ctx.Data["ActiveCodeLives"] = timeutil.MinutesToFriendly(setting.Service.ActiveCodeLives, ctx.Locale.Language())
		ctx.HTML(http.StatusOK, TplActivate)
		if err := ctx.Cache.Put("MailResendLimit_"+u.LowerName, u.LowerName, 180); err != nil {
			log.Error("Set cache(MailResendLimit) fail: %v", err)
		}
		return
	}
	return true
}
func handleUserCreated ( ctx * context . Context , u * models . User , gothUser * goth . User ) ( ok bool ) { if models . CountUsers ( ) == 1 { u . IsAdmin = true u . IsActive = true u . SetLastLogin ( ) if err := models . UpdateUserCols ( u , " " , " " , " " ) ; err != nil { ctx . ServerError ( " " , err ) return } } if gothUser != nil { if err := models . UpdateExternalUser ( u , * gothUser ) ; err != nil { log . Error ( " " , err ) } } if ! u . IsActive && u . ID > 1 { mailer . SendActivateAccountMail ( ctx . Locale , u ) ctx . Data [ " " ] = true ctx . Data [ " " ] = u . Email ctx . Data [ " " ] = timeutil . MinutesToFriendly ( setting . Service . ActiveCodeLives , ctx . Locale . Language ( ) ) ctx . HTML ( http . StatusOK , TplActivate ) if err := ctx . Cache . Put ( " " + u . LowerName , u . LowerName , 180 ) ; err != nil { log . Error ( " " , err ) } return } return true }
handleUserCreated does additional steps after a new user is created.
handleUserCreated does additional steps after a new user is created .
// Auto-set admin for the only user. // update external user information // Send confirmation email