feat(login): use desktop app in new session

This commit is contained in:
iyear 2023-12-18 12:36:24 +08:00
parent 8127fb7a7b
commit 6470e57ff5

View File

@ -26,6 +26,11 @@ func Code(ctx context.Context) error {
if err != nil {
return errors.Wrap(err, "open kv")
}
if err = kvd.Set(key.App(), []byte(tclient.AppDesktop)); err != nil {
return errors.Wrap(err, "set app")
}
c, err := tclient.New(ctx, tclient.Options{
KV: kvd,
Proxy: viper.GetString(consts.FlagProxy),
@ -57,9 +62,6 @@ func Code(ctx context.Context) error {
}, backoff.NewConstantBackOff(time.Second))
}
color.Yellow("WARN: Using the built-in APP_ID & APP_HASH may increase the probability of blocking")
color.Blue("Login...")
flow := auth.NewFlow(termAuth{}, auth.SendCodeOptions{})
if err = c.Auth().IfNecessary(ctx, flow); err != nil {
return err
@ -70,10 +72,6 @@ func Code(ctx context.Context) error {
return err
}
if err = kvd.Set(key.App(), []byte(tclient.AppBuiltin)); err != nil {
return err
}
color.Green("Login successfully! ID: %d, Username: %s", user.ID, user.Username)
return nil