Skip to content

Commit 67ee752

Browse files
susnuxAndyScherzinger
authored andcommitted
fix(core): adjust fronend code for changes in webauthn library
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
1 parent 2182494 commit 67ee752

File tree

3 files changed

+36
-31
lines changed

3 files changed

+36
-31
lines changed

apps/settings/src/service/WebAuthnRegistrationSerice.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* SPDX-License-Identifier: AGPL-3.0-or-later
44
*/
55

6-
import type { RegistrationResponseJSON } from '@simplewebauthn/types'
6+
import type { PublicKeyCredentialCreationOptionsJSON, RegistrationResponseJSON } from '@simplewebauthn/types'
77

88
import { translate as t } from '@nextcloud/l10n'
99
import { generateUrl } from '@nextcloud/router'
@@ -21,9 +21,9 @@ export async function startRegistration() {
2121

2222
try {
2323
logger.debug('Fetching webauthn registration data')
24-
const { data } = await axios.get(url)
24+
const { data } = await axios.get<PublicKeyCredentialCreationOptionsJSON>(url)
2525
logger.debug('Start webauthn registration')
26-
const attrs = await registerWebAuthn(data)
26+
const attrs = await registerWebAuthn({ optionsJSON: data })
2727
return attrs
2828
} catch (e) {
2929
logger.error(e as Error)

core/src/components/login/PasswordLessLoginForm.vue

Lines changed: 32 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,27 @@
55
<template>
66
<form v-if="(isHttps || isLocalhost) && supportsWebauthn"
77
ref="loginForm"
8+
aria-labelledby="password-less-login-form-title"
9+
class="password-less-login-form"
810
method="post"
911
name="login"
1012
@submit.prevent="submit">
11-
<h2>{{ t('core', 'Log in with a device') }}</h2>
12-
<fieldset>
13-
<NcTextField required
14-
:value="user"
15-
:autocomplete="autoCompleteAllowed ? 'on' : 'off'"
16-
:error="!validCredentials"
17-
:label="t('core', 'Login or email')"
18-
:placeholder="t('core', 'Login or email')"
19-
:helper-text="!validCredentials ? t('core', 'Your account is not setup for passwordless login.') : ''"
20-
@update:value="changeUsername" />
13+
<h2 id="password-less-login-form-title">
14+
{{ t('core', 'Log in with a device') }}
15+
</h2>
2116

22-
<LoginButton v-if="validCredentials"
23-
:loading="loading"
24-
@click="authenticate" />
25-
</fieldset>
17+
<NcTextField required
18+
:value="user"
19+
:autocomplete="autoCompleteAllowed ? 'on' : 'off'"
20+
:error="!validCredentials"
21+
:label="t('core', 'Login or email')"
22+
:placeholder="t('core', 'Login or email')"
23+
:helper-text="!validCredentials ? t('core', 'Your account is not setup for passwordless login.') : ''"
24+
@update:value="changeUsername" />
25+
26+
<LoginButton v-if="validCredentials"
27+
:loading="loading"
28+
@click="authenticate" />
2629
</form>
2730
<div v-else-if="!supportsWebauthn" class="update">
2831
<InformationIcon size="70" />
@@ -40,9 +43,11 @@
4043
</div>
4144
</template>
4245

43-
<script>
46+
<script type="ts">
4447
import { browserSupportsWebAuthn } from '@simplewebauthn/browser'
48+
import { defineComponent } from 'vue'
4549
import {
50+
NoValidCredentials,
4651
startAuthentication,
4752
finishAuthentication,
4853
} from '../../services/WebAuthnAuthenticationService.ts'
@@ -52,7 +57,7 @@ import LockOpenIcon from 'vue-material-design-icons/LockOpen.vue'
5257
import NcTextField from '@nextcloud/vue/dist/Components/NcTextField.js'
5358
import logger from '../../logger'
5459
55-
export default {
60+
export default defineComponent({
5661
name: 'PasswordLessLoginForm',
5762
components: {
5863
LoginButton,
@@ -138,21 +143,21 @@ export default {
138143
// noop
139144
},
140145
},
141-
}
146+
})
142147
</script>
143148

144149
<style lang="scss" scoped>
145-
fieldset {
146-
display: flex;
147-
flex-direction: column;
148-
gap: 0.5rem;
150+
.password-less-login-form {
151+
display: flex;
152+
flex-direction: column;
153+
gap: 0.5rem;
149154
150-
:deep(label) {
151-
text-align: initial;
152-
}
155+
:deep(label) {
156+
text-align: initial;
153157
}
158+
}
154159
155-
.update {
156-
margin: 0 auto;
157-
}
160+
.update {
161+
margin: 0 auto;
162+
}
158163
</style>

core/src/services/WebAuthnAuthenticationService.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export async function startAuthentication(loginName: string) {
2727
logger.error('No valid credentials returned for webauthn')
2828
throw new NoValidCredentials()
2929
}
30-
return await startWebauthnAuthentication(data)
30+
return await startWebauthnAuthentication({ optionsJSON: data })
3131
}
3232

3333
/**

0 commit comments

Comments
 (0)