func (u *UserCommand) Add(client *auth.TunClient) error {
	// if no local logins were specified, default to 'login'
	if u.allowedLogins == "" {
		u.allowedLogins = u.login
	}
	user := services.TeleportUser{
		Name:          u.login,
		AllowedLogins: strings.Split(u.allowedLogins, ","),
	}
	if len(u.identities) != 0 {
		for _, identityVar := range u.identities {
			vals := strings.SplitN(identityVar, ":", 2)
			if len(vals) != 2 {
				return trace.Errorf("bad flag --identity=%v, expected <connector-id>:<email> format", identityVar)
			}
			user.OIDCIdentities = append(user.OIDCIdentities, services.OIDCIdentity{ConnectorID: vals[0], Email: vals[1]})
		}
	}
	token, err := client.CreateSignupToken(&user)
	if err != nil {
		return err
	}
	proxies, err := client.GetProxies()
	if err != nil {
		return trace.Wrap(err)
	}
	hostname := "teleport-proxy"
	if len(proxies) == 0 {
		fmt.Printf("\x1b[1mWARNING\x1b[0m: this Teleport cluster does not have any proxy servers online.\nYou need to start some to be able to login.\n\n")
	} else {
		hostname = proxies[0].Hostname
	}

	// try to auto-suggest the activation link
	_, proxyPort, err := net.SplitHostPort(u.config.Proxy.WebAddr.Addr)
	if err != nil {
		proxyPort = strconv.Itoa(defaults.HTTPListenPort)
	}
	url := web.CreateSignupLink(net.JoinHostPort(hostname, proxyPort), token)
	fmt.Printf("Signup token has been created and is valid for %v seconds. Share this URL with the user:\n%v\n\nNOTE: make sure '%s' is accessible!\n", defaults.MaxSignupTokenTTL.Seconds(), url, hostname)
	return nil
}
// Add creates a new sign-up token and prints a token URL to stdout.
// A user is not created until he visits the sign-up URL and completes the process
Add creates a new sign-up token and prints a token URL to stdout.
A user is not created until he visits the sign-up URL and completes the process
// Add creates a new sign - up token and prints a token URL to stdout . // A user is not created until he visits the sign - up URL and completes the process
func (u *UserCommand) Add(client *auth.TunClient) error {
	if u.allowedLogins == "" {
		u.allowedLogins = u.login
	}
	user := services.TeleportUser{
		Name:          u.login,
		AllowedLogins: strings.Split(u.allowedLogins, ","),
	}
	if len(u.identities) != 0 {
		for _, identityVar := range u.identities {
			vals := strings.SplitN(identityVar, ":", 2)
			if len(vals) != 2 {
				return trace.Errorf("bad flag --identity=%v, expected <connector-id>:<email> format", identityVar)
			}
			user.OIDCIdentities = append(user.OIDCIdentities, services.OIDCIdentity{ConnectorID: vals[0], Email: vals[1]})
		}
	}
	token, err := client.CreateSignupToken(&user)
	if err != nil {
		return err
	}
	proxies, err := client.GetProxies()
	if err != nil {
		return trace.Wrap(err)
	}
	hostname := "teleport-proxy"
	if len(proxies) == 0 {
		fmt.Printf("\x1b[1mWARNING\x1b[0m: this Teleport cluster does not have any proxy servers online.\nYou need to start some to be able to login.\n\n")
	} else {
		hostname = proxies[0].Hostname
	}
	_, proxyPort, err := net.SplitHostPort(u.config.Proxy.WebAddr.Addr)
	if err != nil {
		proxyPort = strconv.Itoa(defaults.HTTPListenPort)
	}
	url := web.CreateSignupLink(net.JoinHostPort(hostname, proxyPort), token)
	fmt.Printf("Signup token has been created and is valid for %v seconds. Share this URL with the user:\n%v\n\nNOTE: make sure '%s' is accessible!\n", defaults.MaxSignupTokenTTL.Seconds(), url, hostname)
	return nil
}
func ( u * UserCommand ) Add ( client * auth . TunClient ) error { if u . allowedLogins == " " { u . allowedLogins = u . login } user := services . TeleportUser { Name : u . login , AllowedLogins : strings . Split ( u . allowedLogins , " " ) , } if len ( u . identities ) != 0 { for _ , identityVar := range u . identities { vals := strings . SplitN ( identityVar , " " , 2 ) if len ( vals ) != 2 { return trace . Errorf ( " " , identityVar ) } user . OIDCIdentities = append ( user . OIDCIdentities , services . OIDCIdentity { ConnectorID : vals [ 0 ] , Email : vals [ 1 ] } ) } } token , err := client . CreateSignupToken ( & user ) if err != nil { return err } proxies , err := client . GetProxies ( ) if err != nil { return trace . Wrap ( err ) } hostname := " " if len ( proxies ) == 0 { fmt . Printf ( " \x1b \x1b \n \n \n " ) } else { hostname = proxies [ 0 ] . Hostname } _ , proxyPort , err := net . SplitHostPort ( u . config . Proxy . WebAddr . Addr ) if err != nil { proxyPort = strconv . Itoa ( defaults . HTTPListenPort ) } url := web . CreateSignupLink ( net . JoinHostPort ( hostname , proxyPort ) , token ) fmt . Printf ( " \n \n \n \n " , defaults . MaxSignupTokenTTL . Seconds ( ) , url , hostname ) return nil }
Add creates a new sign-up token and prints a token URL to stdout.
Add creates a new sign - up token and prints a token URL to stdout .
// if no local logins were specified, default to 'login' // try to auto-suggest the activation link