Problem
We don't track when someone authorizes using continue with Cal.com
Solution
- Add
users to OAuthClient model and each time someone authorizes using that client we track that in database similar like we do with PlatformOAuthClient.
- Update OAuth client card to have "users" button that takes to OAuth users page
settings/developer/oauth/:clientId/users that fetches all oauth users and displays them and also displays total count of them. Display user name, email and when they authorized and refreshed tokens (to know if user is active).
Implementation
- In
schema.prisma create a new table OAuthAuthorization that tracks each time user authorizes an OAuth client. We could have added users: User[] to OAuthClient model, but having this table allows us to track current scopes authorized, when authorization happened and last time tokens were refreshed to know if user is active or not.
- Relations:
- The
User table has oAuthAuthorizations OAuthAuthorization[] allowing to know what OAuth clients has each user authorized. Each user has only 1 authorization entry per OAuth client meaning that if they re-authorize we track the last scopes they have authorized. If we had multiple entries then it would be hard to display oauth users.
- And each
OAuthClient has authorizations OAuthAuthorization[] to know which users have authorized using it.
- Code populating database:
- The new repository
OAuthAuthorizationRepository.ts is used to upsert a new entry and update last refreshed at.
OAuthService.ts upserts a new entry when creating authorization code and updates refreshed at date when refreshing tokens.
- Frontend has been refactored to show "Users" button and "Settings" button:

when "Users" button is clicked we display OAuth client users:

in the future if we want we can also display scopes that user has authorized.
The code for this component is in oauth-client-users-view.tsx and it calls the new handler
Problem
We don't track when someone authorizes using
continue with Cal.comSolution
userstoOAuthClientmodel and each time someone authorizes using that client we track that in database similar like we do withPlatformOAuthClient.settings/developer/oauth/:clientId/usersthat fetches all oauth users and displays them and also displays total count of them. Display user name, email and when they authorized and refreshed tokens (to know if user is active).Implementation
schema.prismacreate a new tableOAuthAuthorizationthat tracks each time user authorizes an OAuth client. We could have addedusers: User[]toOAuthClientmodel, but having this table allows us to track current scopes authorized, when authorization happened and last time tokens were refreshed to know if user is active or not.Usertable hasoAuthAuthorizations OAuthAuthorization[]allowing to know what OAuth clients has each user authorized. Each user has only 1 authorization entry per OAuth client meaning that if they re-authorize we track the last scopes they have authorized. If we had multiple entries then it would be hard to display oauth users.OAuthClienthasauthorizations OAuthAuthorization[]to know which users have authorized using it.OAuthAuthorizationRepository.tsis used to upsert a new entry and update last refreshed at.OAuthService.tsupserts a new entry when creating authorization code and updates refreshed at date when refreshing tokens.when "Users" button is clicked we display OAuth client users:
in the future if we want we can also display scopes that user has authorized.
The code for this component is in
oauth-client-users-view.tsxand it calls the new handler