Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit4006974

Browse files
fix: external auth device flow, check both queries for errors (#12367)
* fix: external auth device flow, check both queries for errors* Minor style update---------Co-authored-by: BrunoQuaresma <bruno_nonato_quaresma@hotmail.com>
1 parent9f3591a commit4006974

File tree

3 files changed

+35
-3
lines changed

3 files changed

+35
-3
lines changed

‎site/src/pages/ExternalAuthPage/ExternalAuthPage.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ const ExternalAuthPage: FC = () => {
5353
if(isAxiosError(exchangeExternalAuthDeviceQuery.failureReason)){
5454
deviceExchangeError=
5555
exchangeExternalAuthDeviceQuery.failureReason.response?.data;
56+
}elseif(isAxiosError(externalAuthDeviceQuery.failureReason)){
57+
deviceExchangeError=externalAuthDeviceQuery.failureReason.response?.data;
5658
}
5759

5860
if(

‎site/src/pages/ExternalAuthPage/ExternalAuthPageView.stories.tsx

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,27 @@ DeviceUnauthenticated.args = {
4949
},
5050
};
5151

52+
exportconstDevice429Error=Template.bind({});
53+
Device429Error.args={
54+
externalAuth:{
55+
display_name:"GitHub",
56+
authenticated:false,
57+
device:true,
58+
installations:[],
59+
app_install_url:"",
60+
app_installable:false,
61+
},
62+
// This is intentionally undefined.
63+
// If we get a 429 on the first /device call, then this
64+
// is undefined with a 429 error.
65+
externalAuthDevice:undefined,
66+
deviceExchangeError:{
67+
message:"Failed to authorize device.",
68+
detail:
69+
"rate limit hit, unable to authorize device. please try again later",
70+
},
71+
};
72+
5273
exportconstDeviceUnauthenticatedError=Template.bind({});
5374
DeviceUnauthenticatedError.args={
5475
externalAuth:{

‎site/src/pages/ExternalAuthPage/ExternalAuthPageView.tsx

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
import{typeInterpolation,typeTheme}from"@emotion/react";
22
importOpenInNewIconfrom"@mui/icons-material/OpenInNew";
33
importRefreshIconfrom"@mui/icons-material/Refresh";
4+
importAlertTitlefrom"@mui/material/AlertTitle";
45
importCircularProgressfrom"@mui/material/CircularProgress";
56
importLinkfrom"@mui/material/Link";
67
importTooltipfrom"@mui/material/Tooltip";
78
importtype{ApiErrorResponse}from"api/errors";
89
importtype{ExternalAuth,ExternalAuthDevice}from"api/typesGenerated";
9-
import{Alert}from"components/Alert/Alert";
10+
import{Alert,AlertDetail}from"components/Alert/Alert";
1011
import{Avatar}from"components/Avatar/Avatar";
1112
import{CopyButton}from"components/CopyButton/CopyButton";
1213
import{SignInLayout}from"components/SignInLayout/SignInLayout";
@@ -173,14 +174,22 @@ const GitDeviceAuth: FC<GitDeviceAuthProps> = ({
173174
default:
174175
status=(
175176
<Alertseverity="error">
176-
An unknown error occurred. Please try again:{" "}
177-
{deviceExchangeError.message}
177+
<AlertTitle>{deviceExchangeError.message}</AlertTitle>
178+
{deviceExchangeError.detail&&(
179+
<AlertDetail>{deviceExchangeError.detail}</AlertDetail>
180+
)}
178181
</Alert>
179182
);
180183
break;
181184
}
182185
}
183186

187+
// If the error comes from the `externalAuthDevice` query,
188+
// we cannot even display the user_code.
189+
if(deviceExchangeError&&!externalAuthDevice){
190+
return<div>{status}</div>;
191+
}
192+
184193
if(!externalAuthDevice){
185194
return<CircularProgress/>;
186195
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp