Skip to content

Commit 1f51883

Browse files
eddietejedaclaude
andcommitted
feat(auth): default register to GitHub, add --email flag
hotdata auth register now defaults to GitHub OAuth signup; pass --email to use email/password instead. The method query param is forwarded to the webapp cli_register endpoint. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 077c9c2 commit 1f51883

3 files changed

Lines changed: 11 additions & 5 deletions

File tree

src/auth.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ pub fn login() {
371371
}
372372
}
373373

374-
pub fn register() {
374+
pub fn register(use_email: bool) {
375375
let profile_config = config::load("default").unwrap_or_default();
376376
let app_url = profile_config.app_url.to_string();
377377

@@ -391,12 +391,14 @@ pub fn register() {
391391
tiny_http::Server::http("127.0.0.1:0").expect("failed to start local callback server");
392392
let port = server.server_addr().to_ip().unwrap().port();
393393

394+
let method = if use_email { "email" } else { "github" };
394395
let register_url = format!(
395396
"{app_url}/auth/cli-register/\
396397
?code_challenge={code_challenge}\
397398
&code_challenge_method=S256\
398399
&state={state}\
399-
&callback_port={port}",
400+
&callback_port={port}\
401+
&method={method}",
400402
app_url = app_url.trim_end_matches('/'),
401403
);
402404

src/command.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -274,8 +274,12 @@ pub enum AuthCommands {
274274
/// Log in via browser (same as `hotdata auth` with no subcommand)
275275
Login,
276276

277-
/// Create a new account via browser
278-
Register,
277+
/// Create a new account via browser (defaults to GitHub OAuth)
278+
Register {
279+
/// Sign up with email and password instead of GitHub
280+
#[arg(long)]
281+
email: bool,
282+
},
279283

280284
/// Remove authentication for a profile
281285
Logout,

src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ fn main() {
158158
Some(cmd) => match cmd {
159159
Commands::Auth { command } => match command {
160160
None | Some(AuthCommands::Login) => auth::login(),
161-
Some(AuthCommands::Register) => auth::register(),
161+
Some(AuthCommands::Register { email }) => auth::register(email),
162162
Some(AuthCommands::Status) => auth::status("default"),
163163
Some(AuthCommands::Logout) => auth::logout("default"),
164164
},

0 commit comments

Comments
 (0)