Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 75d7865

Browse files
committed
Change the UI flow
1 parent e9ba719 commit 75d7865

File tree

4 files changed

+220
-204
lines changed

4 files changed

+220
-204
lines changed

site/src/api/api.ts

+6-27
Original file line numberDiff line numberDiff line change
@@ -108,33 +108,12 @@ export const login = async (
108108
return response.data
109109
}
110110

111-
export const convertToOauth = async (
112-
email: string,
113-
password: string,
114-
to_login_type: string,
115-
): Promise<TypesGen.OauthConversionResponse | undefined> => {
116-
const payload = JSON.stringify({
117-
email,
118-
password,
119-
to_login_type,
120-
})
121-
122-
try {
123-
const response = await axios.post<TypesGen.OauthConversionResponse>(
124-
"/api/v2/users/convert-login",
125-
payload,
126-
{
127-
headers: { ...CONTENT_TYPE_JSON },
128-
},
129-
)
130-
return response.data
131-
} catch (error) {
132-
if (axios.isAxiosError(error) && error.response?.status === 401) {
133-
return undefined
134-
}
135-
136-
throw error
137-
}
111+
export const convertToOAUTH = async (request: TypesGen.ConvertLoginRequest) => {
112+
const response = await axios.post<TypesGen.OauthConversionResponse>(
113+
"/api/v2/users/convert-login",
114+
request,
115+
)
116+
return response.data
138117
}
139118

140119
export const logout = async (): Promise<void> => {

site/src/components/SettingsAccountForm/SettingsAccountForm.test.tsx

-6
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,6 @@ describe("AccountForm", () => {
2424
onSubmit={() => {
2525
return
2626
}}
27-
onChangeToOIDCAuth={() => {
28-
return
29-
}}
3027
/>,
3128
)
3229

@@ -57,9 +54,6 @@ describe("AccountForm", () => {
5754
onSubmit={() => {
5855
return
5956
}}
60-
onChangeToOIDCAuth={() => {
61-
return
62-
}}
6357
/>,
6458
)
6559

site/src/components/SettingsAccountForm/SettingsAccountForm.tsx

+2-8
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ import {
1010
import { LoadingButton } from "../LoadingButton/LoadingButton"
1111
import { ErrorAlert } from "components/Alert/ErrorAlert"
1212
import { Form, FormFields } from "components/Form/Form"
13-
import { Stack } from "components/Stack/Stack"
14-
import Button from "@mui/material/Button"
1513

1614
export interface AccountFormValues {
1715
username: string
@@ -36,7 +34,6 @@ export interface AccountFormProps {
3634
updateProfileError?: Error | unknown
3735
// initialTouched is only used for testing the error state of the form.
3836
initialTouched?: FormikTouched<AccountFormValues>
39-
onChangeToOIDCAuth: () => void
4037
}
4138

4239
export const AccountForm: FC<React.PropsWithChildren<AccountFormProps>> = ({
@@ -47,7 +44,6 @@ export const AccountForm: FC<React.PropsWithChildren<AccountFormProps>> = ({
4744
initialValues,
4845
updateProfileError,
4946
initialTouched,
50-
onChangeToOIDCAuth
5147
}) => {
5248
const form: FormikContextType<AccountFormValues> =
5349
useFormik<AccountFormValues>({
@@ -84,7 +80,7 @@ export const AccountForm: FC<React.PropsWithChildren<AccountFormProps>> = ({
8480
label={Language.usernameLabel}
8581
/>
8682

87-
<Stack direction="row">
83+
<div>
8884
<LoadingButton
8985
loading={isLoading}
9086
aria-disabled={!editable}
@@ -94,9 +90,7 @@ export const AccountForm: FC<React.PropsWithChildren<AccountFormProps>> = ({
9490
>
9591
{isLoading ? "" : Language.updateSettings}
9692
</LoadingButton>
97-
98-
<Button type="button" onClick={onChangeToOIDCAuth}>Use OIDC to authenticate</Button>
99-
</Stack>
93+
</div>
10094
</FormFields>
10195
</Form>
10296
</>

0 commit comments

Comments
 (0)