2 files changed
+12
-6
crates/cli/src/account/login/process.rs
+9
-6
@@ -1,5 +1,5 @@
1
use {
2
- crate::account::signup::process_signup,
2
+ crate::account::signup::signup_with_email,
3
crate::account::{
4
lib::{authorize_github, is_logged_in, save_token},
5
signup::{do_signup, SignupMethod},
@@ -295,7 +295,7 @@ async fn login_with_email(env: Environment) -> Result<CommandResult> {
295
spinners::Spinners::SimpleDotsScrolling,
296
succeed_message("Checking email"),
297
);
298
- verify_or_set_password(&env, spinner, auth).await
298
+ after_checking_email_step(&env, spinner, auth, Some(username)).await
299
} else {
300
let password = match Password::with_theme(&ColorfulTheme::default())
301
.with_prompt("Password")
@@ -361,7 +361,7 @@ async fn do_process_login(env: Environment, args: LoginArgs) -> Result<CommandRe
361
// Account found but email not verified / password not set
362
let result: SmbAuthorization = response.json().await?;
363
// println!("Result: {:#?}", &result);
364
- verify_or_set_password(&env, spinner, result).await
364
+ after_checking_email_step(&env, spinner, result, None).await
365
}
366
_ => Err(anyhow!(fail_message(
367
"Login failed. Check your username and password."
@@ -369,10 +369,11 @@ async fn do_process_login(env: Environment, args: LoginArgs) -> Result<CommandRe
369
}
370
}
371
372
-async fn verify_or_set_password(
372
+async fn after_checking_email_step(
373
env: &Environment,
374
mut spinner: Spinner,
375
result: SmbAuthorization,
376
+ username: Option<String>,
377
) -> Result<CommandResult> {
378
match result.error_code {
379
Some(error_code) => {
@@ -381,9 +382,11 @@ async fn verify_or_set_password(
382
ErrorCode::EmailNotFound => {
383
spinner.stop_and_persist(
384
&succeed_symbol(),
384
- succeed_message("Email not found. Please register."),
385
+ succeed_message(
386
+ "Account not found. Please continue with setting up your account.",
387
+ ),
388
);
386
- process_signup(env.to_owned()).await
389
+ signup_with_email(env.to_owned(), username).await
390
}
391
ErrorCode::EmailUnverified => {
392
spinner.stop_and_persist(
crates/cli/src/account/signup/process.rs
+3
@@ -53,7 +53,10 @@ pub async fn signup_with_email(env: Environment, email: Option<String>) -> Resul
53
.interact()
54
.unwrap()
55
};
56
+ signup_input_password_step(env, email).await
57
+}
58
59
+async fn signup_input_password_step(env: Environment, email: String) -> Result<CommandResult> {
60
let password = Password::with_theme(&ColorfulTheme::default())
61
.with_prompt("Password")
62
.validate_with(|input: &String| -> Result<(), &str> {