8000 Add change-password command & support on server by TymanWasTaken · Pull Request #1615 · atuinsh/atuin · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Add change-password command & support on server #1615

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jan 29, 2024
Merged

Conversation

TymanWasTaken
Copy link
Contributor
@TymanWasTaken TymanWasTaken commented Jan 23, 2024

Fixes #1374

This PR both adds an API endpoint to the server (PATCH /account/password) and adds a corresponding cli command to use it. To change an account password, both a valid session and the current account password are necessary (the current password being verified to ensure it can't be changed without already knowing the password). This simply modifies the hash in the database, returning 200 on success. I tried to keep the code style similar to the surrounding code, so hopefully it is fine :)

By the way, while implementing this, I did notice that the delete account endpoint has no type of verification whatsoever, and doesn't even have a confirmation on the CLI, which kind of makes the required password for changing the password pointless as you can just delete re-register as a workaround. If you think that is something that should be added, I will gladly add it in this PR or another.

This is personally tested, but I recommend testing it yourself before merging, I may have missed something

@ellie
Copy link
Member
ellie commented Jan 23, 2024

This is great, thank you! Just two things

  1. I know our test coverage right now isn't amazing, but I'd like to improve that. Would it be possible to get a test for this endpoint please?

Something similar to the register test would be awesome 🙌

atuin/atuin/tests/sync.rs

Lines 102 to 127 in 2bd7114

async fn registration() {
let path = format!("/{}", uuid_v7().as_simple());
let (address, shutdown, server) = start_server(&path).await;
dbg!(&address);
// -- REGISTRATION --
let username = uuid_v7().as_simple().to_string();
let password = uuid_v7().as_simple().to_string();
let client = register_inner(&address, &username, &password).await;
// the session token works
let status = client.status().await.unwrap();
assert_eq!(status.username, username);
// -- LOGIN --
let client = login(&address, username.clone(), password).await;
// the session token works
let status = client.status().await.unwrap();
assert_eq!(status.username, username);
shutdown.send(()).unwrap();
server.await.unwrap();
}

  1. You're right - confirmation would be good. I don't think it should require the password though, as users may wish to delete an account they no longer have the password for (but maintain an active session for). Maybe just a 'Are you sure? [y/N]" type thing

@atuinsh atuinsh deleted a comment from atuin-bot Jan 25, 2024
@TymanWasTaken
Copy link
Contributor Author

I added a test that passes on my machine which should accurately test changing the password: it registers a user, changes the password on it, and attempts to login with the new password to confirm it actually worked.

Copy link
Member
@ellie ellie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fantastic, thank you! I pushed one commit that was just the output of cargo fmt, hope that's ok

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Change password
2 participants
0