Skip to content

Commit

Permalink
Merge pull request #4273 from serlo/fix-auth-oidc-button
Browse files Browse the repository at this point in the history
Fix SSO button after upgrade of kratos in backend
  • Loading branch information
hugotiburtino authored Nov 13, 2024
2 parents 43084d0 + 079aec3 commit 537f9da
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 11 deletions.
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion apps/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"@fortawesome/react-fontawesome": "^0.2.0",
"@hello-pangea/dnd": "^16.6.0",
"@lumieducation/h5p-react": "^9.3.2",
"@ory/client": "^1.9.0",
"@ory/client": "^1.15.10",
"@ory/integrations": "^1.1.5",
"@radix-ui/react-dialog": "^1.1.1",
"@radix-ui/react-navigation-menu": "^1.1.4",
Expand Down
15 changes: 11 additions & 4 deletions apps/web/src/components/pages/auth/login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,16 @@ export function Login({ oauth }: { oauth?: boolean }) {
unwantedPaths: [verificationUrl, logoutUrl, loginUrl, recoveryUrl],
})

const hackedValues = // @ts-expect-error try
values.method === 'nbp' // @ts-expect-error try
? ({ ...values, provider: 'nbp' } as UpdateLoginFlowBody)
// We are currently not sure why this workaround is needed.
// values.method is supposed to be 'oidc' or 'password'
const provider = values.method as unknown as string
const hackedValues =
provider === 'nbp' || provider === 'vidis'
? ({
...values,
provider,
method: 'oidc',
} as UpdateLoginFlowBody)
: values

try {
Expand All @@ -188,7 +195,7 @@ export function Login({ oauth }: { oauth?: boolean }) {
FlowType.login,
setFlow,
strings
)(e as AxiosError<LoginFlow>)
)(e as AxiosError)
} catch (e: unknown) {
const err = e as AxiosError
if (err.response?.status === 400) {
Expand Down
15 changes: 14 additions & 1 deletion apps/web/src/components/pages/auth/registration.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,20 @@ export function Registration() {
}, [flowId, router, router.isReady, returnTo, flow, strings, checkInstance])

async function onSubmit(values: UpdateRegistrationFlowBody) {
const valuesWithLanguage = { ...values, 'traits.language': lang }
// We are currently not sure why this workaround is needed.
// values.method is supposed to be 'oidc' or 'password'
const provider = values.method as unknown as string
const hackedValues =
provider === 'nbp' || provider === 'vidis'
? ({
...values,
provider,
method: 'oidc',
} as UpdateRegistrationFlowBody)
: values

const valuesWithLanguage = { ...hackedValues, 'traits.language': lang }

nProgress.start()
return kratos
.updateRegistrationFlow({
Expand Down
10 changes: 5 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4174,12 +4174,12 @@ __metadata:
languageName: node
linkType: hard

"@ory/client@npm:^1.9.0":
version: 1.9.0
resolution: "@ory/client@npm:1.9.0"
"@ory/client@npm:^1.15.10":
version: 1.15.10
resolution: "@ory/client@npm:1.15.10"
dependencies:
axios: ^1.6.1
checksum: c732911c967a67a96ae8acbd5f83b3e5dc38ffbc8b2d8c8f865c2659533762939ee6fe5594540aef3cd91ea5be24af708a46950f338009b3ea2ed6356aeb7a5e
checksum: 35b5140c4f6d940807a6708abb3b5a3d33fc5e02470b82757f7a01b4634eb7343678f5ce0ce62e0f04f05090629605f18445322863f488a02d8abd75cf2d9b32
languageName: node
linkType: hard

Expand Down Expand Up @@ -5864,7 +5864,7 @@ __metadata:
"@hello-pangea/dnd": ^16.6.0
"@lumieducation/h5p-react": ^9.3.2
"@next/bundle-analyzer": ^13.5.6
"@ory/client": ^1.9.0
"@ory/client": ^1.15.10
"@ory/integrations": ^1.1.5
"@radix-ui/react-dialog": ^1.1.1
"@radix-ui/react-navigation-menu": ^1.1.4
Expand Down

0 comments on commit 537f9da

Please sign in to comment.