Skip to content

feat: delete API token in /logout API #1770

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 19 commits into from
May 27, 2022

Conversation

AbhineetJain
Copy link
Contributor

@AbhineetJain AbhineetJain commented May 26, 2022

This PR deletes the API token from the database on logout via the API. Should fix this for both UI and CLI.

Subtasks

  • add DeleteAPIKeyByID query
  • delete API Key on logout request
  • call /logout from CLI
  • add and fix unit tests

Fixes #1714

@AbhineetJain AbhineetJain requested a review from Emyrk May 26, 2022 01:39
@AbhineetJain
Copy link
Contributor Author

Updated the error messaging with the CLI logout flow. It collects all the errors and spits them out at the end:

Failed to log out.                                                                
        remove URL file: remove /home/coder/.config/coderv2/url: permission denied        
        remove session file: remove /home/coder/.config/coderv2/session: permission denied
Run 'coder logout --help' for usage. 

@AbhineetJain
Copy link
Contributor Author

Getting this error for Windows:

panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x0 addr=0x18 pc=0x1f703df]

@AbhineetJain AbhineetJain marked this pull request as ready for review May 27, 2022 17:18
@AbhineetJain AbhineetJain merged commit d623eeb into main May 27, 2022
@AbhineetJain AbhineetJain deleted the abhineetjain/delete-session-token-api branch May 27, 2022 20:47
kylecarbs pushed a commit that referenced this pull request Jun 10, 2022
* delete API token in logout api

* add deleteapikeybyid to databasefake

* set blank cookie on logout always

* refactor logout flow, add unit tests

* update logout messsage

* use read-only file mode for windows

* fix file mode on windows for cleanup

* change file permissions on windows

* assert error is not nil

* refactor cli

* try different file mode on windows

* try different file mode on windows

* try keeping the files open on Windows

* fix the error message on Windows
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.

feat: API endpoint to delete the session token on server side
3 participants