Skip to content

Throw conflict on authorising new Garmin user if external_user_id already exists #305

@yatharthranjan

Description

@yatharthranjan

This should be unique and should throw a conflict exception. This is because Garmin will PUSH the data and our system wouldn't know which ID to map it to if more than one user is authorised on same external garmin user ID.

Example database entries

 id  | project_id |               user_id                |              source_id               | source_type |     start_date      |      end_date       |      
     external_user_id           | authorized |             access_token             |            refresh_token            | expires_in |         expires_at      
   | token_type |            version             | times_reset |         created_at         
-----+------------+--------------------------------------+--------------------------------------+-------------+---------------------+---------------------+------
--------------------------------+------------+--------------------------------------+-------------------------------------+------------+-------------------------
---+------------+--------------------------------+-------------+----------------------------
 285 | NSHD       | 6b1a5591-e0e5-45e1-9ea0-56673f86ea59 | f2f8d1ac-3981-4818-a445-079e59f25409 | Garmin      | 2023-10-23 23:00:00 | 2025-10-23 23:00:00 | 86e2d
28b-d362-4c41-8f54-d607800ea9ad | t          | 1a8*****************ad3452 |*********** | 2147483647 | 2091-11-11 18:10:00.2177
68 |            | 2023-10-24T15:00:43.478475883Z |           0 | 2023-10-24 15:00:43.478476
 777 | NSHD       | efb5a8bc-1db1-4e14-a2bb-e527cf4bb83b | f98e17b0-8d9a-462d-8715-7423a3628ab8 | Garmin      | 2024-09-08 23:00:00 | 2025-07-30 23:00:00 | 86e2d
28b-d362-4c41-8f54-d607800ea9ad | t          | 346************cd045 | ******** | 2147483647 | 2092-09-27 18:26:14.6147
44 |            | 2024-09-09T15:17:01.718895813Z |           0 | 2024-09-09 15:17:01.718896

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions