Skip to content

Commit

Permalink
fix(platform-server): github no email error
Browse files Browse the repository at this point in the history
  • Loading branch information
EYHN committed Sep 2, 2022
1 parent 1a0b093 commit b477eee
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
4 changes: 4 additions & 0 deletions packages/platform-server/src/modules/auth/oauth.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,10 @@ export class OAuth2Controller {
return connectedUser
}

if (!externAccount.email) {
throw new Error('GITHUB_NO_PUBLIC_EMAIL')
}

// find registered user by email
let user = await this.user.findUserByEmail(externAccount.email)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ limitations under the License.

export interface ExternalAccountUser {
username: string
email: string
email?: string
avatarUrl: string
}

Expand Down
12 changes: 11 additions & 1 deletion packages/platform/src/modules/login/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import { useModule, useModuleState } from '@sigi/react'
import { useEffect } from 'react'
import { Link } from 'react-router-dom'

import { BodyContainer, useQueryString } from '@perfsee/components'
import { BodyContainer, ForeignLink, useQueryString } from '@perfsee/components'
import { staticPath } from '@perfsee/shared/routes'

import { UserModule } from '../shared'
Expand Down Expand Up @@ -59,6 +59,16 @@ const StatusText = {
message: 'The account has been connected to others, try logging in.',
type: MessageBarType.error,
},
GITHUB_NO_PUBLIC_EMAIL: {
message: (
<>
Your Github account does not have a public email address, please go to{' '}
<ForeignLink href="https://github.com/settings/profile">your profile</ForeignLink> to set a public email
address, or use <Link to={staticPath.register}>email to register</Link>.
</>
),
type: MessageBarType.error,
},
}

export const Login = () => {
Expand Down

0 comments on commit b477eee

Please sign in to comment.