Skip to content
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

Ask for password before adding entry instead of after #951

Merged
merged 4 commits into from
May 16, 2020

Conversation

ollybritton
Copy link
Contributor

@ollybritton ollybritton commented May 12, 2020

This hopefully fixes #799 because prviously it would allow you to create an entry using your editor and then attempt to open the journal. This behaviour is fine for unecrypted journals but with encrypted journals it means that if you get the password wrong three times then the entry you wrote is lost.

Swapping the code around so that it attempts to open the journal before it opens an editor means that this can't happen. This should solve #270, #256 and #284 too.

It appears that this was the behaviour in earlier versions of jrnl but I'm assuming that this got lost after a rewrite.

This is my first time contributing to open source so I apologise if I've formatted anything wrong or made a big mistake but I'm not really sure what the process is yet and would be happy to fix anything that I did incorrectly.

Checklist

  • The code change is tested and works locally.
  • Tests pass. Your PR cannot be merged unless tests pass. --
    poetry run behave
  • The code passes linting via
    black (consistent code styling). --
    poetry run black --check . --verbose --diff
  • The code passes linting via pyflakes
    (logically errors and unused imports). -- poetry run pyflakes jrnl features
  • There is no commented out code in this PR.
  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open
    Pull Requests for the same update/change?
  • Have you added an explanation of what your changes do and why you'd like
    us to include them?
  • Have you written new tests for your core changes, as applicable?

This fixes jrnl-org#799 because previously it would allow you to create an
entry using your editor and then attempt to open the journal. This
behaviour is fine for unencrypted journals but with encrypted journals
it means that if you get the password wrong three times then the entry
you just wrote is lost.

Swapping the order around so that the entry is opened first in the code
and then the editor is added means that this can't happen.
Copy link
Member

@micahellison micahellison left a comment

Choose a reason for hiding this comment

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

One small typo but otherwise looks great.

jrnl/cli.py Outdated
@@ -345,6 +345,13 @@ def run(manual_args=None):
else:
_exit_multiline_code = "press Ctrl+D"

# This is where we fi±nally open the journal!
Copy link
Member

Choose a reason for hiding this comment

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

This is really minor, but could please remove the typo in "finally"?

Copy link
Member

@micahellison micahellison left a comment

Choose a reason for hiding this comment

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

💯

@micahellison micahellison added the bug Something isn't working label May 16, 2020
@micahellison micahellison changed the title ask for password before adding entry (#799) Ask for password before adding entry instead of after May 16, 2020
@ollybritton
Copy link
Contributor Author

Thanks for making my first contribution to open source a good experience!

@micahellison micahellison merged commit 7d4afd1 into jrnl-org:develop May 16, 2020
@wren
Copy link
Member

wren commented May 16, 2020

Thanks for contributing! ❤️

@micahellison
Copy link
Member

Thanks for picking our project for your first contribution!

wren pushed a commit that referenced this pull request Jul 25, 2020
* ask for password before adding entry (#799)

This fixes #799 because previously it would allow you to create an
entry using your editor and then attempt to open the journal. This
behaviour is fine for unencrypted journals but with encrypted journals
it means that if you get the password wrong three times then the entry
you just wrote is lost.

Swapping the order around so that the entry is opened first in the code
and then the editor is added means that this can't happen.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Wrong password 3 times after closing editor results in loss of all changes
3 participants