Skip to content

Handle mismatch between token user and logged-in user #7384

Closed

Description

@fregante

Some Refined GitHub users switch between multiple accounts. This is not well-supported.

Detection

  1. Cache the result of the API call from Show token owner in options page #7380
    • Not perfect because the token can be updated via browser sync, and it won't reach it
  2. If getUsername() returns something (it reads the current page), compare it to the token's know owner

Action

  • Mark API calls that are "write" calls
  • Compare the user before the call (synchronously, do not query /user every time)
  • if it doesn't match, throw an error, show an alert
  • Maybe do this as part of the expectToken call, but without the alert
  • Suggest to use multiple browser profiles instead of logging in and out

Related

Activity

  1. added
    meta
    on Jun 2, 2024
  2. changed the title [-]Prevent mutation API calls if the current user does not match the token user[/-] [+]Handle mismatch between token user and logged-in user[/+] on Oct 2, 2024
  3. fregante commented on Oct 2, 2024

    @fregante
    MemberAuthor
    • Suggest to use multiple browser profiles instead of logging in and out

    It looks like this is now a native GitHub feature so we should implement it sooner:

    Screenshot
  4. tuta-amb commented on Oct 10, 2024

    @tuta-amb

    This would be great to have, having to switch tokens every time when switching accounts is a major issue.

  5. fregante commented on Oct 10, 2024

    @fregante
    MemberAuthor

    See #6446

    This issue isn't about supporting multiple tokens, it's simply to warn the user that the token doesn't match the current user

  6. fregante commented on Oct 11, 2024

    @fregante
    MemberAuthor

    I think we just need this:

    Screenshot

    And then add a banner in the dropdown:

    Screenshot 1

    Red bubble demo CSS:

    .Button-label::before {
    	content: "";
    	display: block;
    	border-radius: 50%;
    	background-color: red;
    	width: 8px;
    	height: 8px;
    	margin-bottom: -8px;
    	z-index: 1;
    	position: relative;
    }

    This is suddenly much easier to implement. PR welcome

  7. added
    small
    and removed on Oct 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    acceptedmetasmall

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions