Skip to content

Commit

Permalink
clients/oauth: show oauth usernames if exists
Browse files Browse the repository at this point in the history
  • Loading branch information
zegl committed Feb 5, 2024
1 parent eb339d4 commit 7c682fc
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import {

interface AuthenticationMethodProps {
icon: React.ReactNode
title: string
subtitle: string
title: React.ReactNode
subtitle: React.ReactNode
action: React.ReactNode
}

Expand Down Expand Up @@ -65,7 +65,21 @@ const GitHubAuthenticationMethod: React.FC<GitHubAuthenticationMethodProps> = ({
/>
</svg>
}
title={oauthAccount ? oauthAccount.account_email : 'Connect GitHub'}
title={
oauthAccount ? (
<>
{oauthAccount.account_username ? (
<>
{oauthAccount.account_username} ({oauthAccount.account_email})
</>
) : (
oauthAccount.account_email
)}
</>
) : (
'Connect GitHub'
)
}
subtitle={
oauthAccount
? 'You can sign in with your GitHub account.'
Expand Down
20 changes: 17 additions & 3 deletions clients/apps/web/src/components/Settings/ConnectedAppSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import { useEffect } from 'react'

interface ConnectedAppProps {
icon: React.ReactNode
title: string
subtitle: string
title: React.ReactNode
subtitle: React.ReactNode
action: React.ReactNode
}

Expand Down Expand Up @@ -63,7 +63,21 @@ const DiscordConnectedApp: React.FC<DiscordConnectedAppProps> = ({
</g>
</svg>
}
title={oauthAccount ? oauthAccount.account_email : 'Connect Discord'}
title={
oauthAccount ? (
<>
{oauthAccount.account_username ? (
<>
{oauthAccount.account_username} ({oauthAccount.account_email})
</>
) : (
oauthAccount.account_email
)}
</>
) : (
'Connect Discord'
)
}
subtitle={
oauthAccount
? 'Your Discord account is connected.'
Expand Down
6 changes: 6 additions & 0 deletions clients/packages/sdk/src/client/models/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3269,6 +3269,12 @@ export interface OAuthAccountRead {
* @memberof OAuthAccountRead
*/
account_email: string;
/**
*
* @type {string}
* @memberof OAuthAccountRead
*/
account_username: string;
}

/**
Expand Down
1 change: 1 addition & 0 deletions server/polar/user/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class OAuthAccountRead(TimestampedSchema):
platform: OAuthPlatform
account_id: str
account_email: str
account_username: str | None


class UserRead(UserBase, TimestampedSchema):
Expand Down

0 comments on commit 7c682fc

Please sign in to comment.