File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 4949import { NcButton } from ' @nextcloud/vue'
5050import { browserSupportsWebAuthn , startAuthentication } from ' @simplewebauthn/browser'
5151import logger from ' ../logger.js'
52- import { mapState } from ' pinia'
53- import { useMainStore } from ' ../store.js'
5452
5553export default {
5654 name: ' Challenge' ,
@@ -59,6 +57,13 @@ export default {
5957 NcButton,
6058 },
6159
60+ props: {
61+ credentialRequestOptions: {
62+ type: Object ,
63+ required: true ,
64+ },
65+ },
66+
6267 data () {
6368 return {
6469 challenge: ' ' ,
@@ -67,7 +72,6 @@ export default {
6772 },
6873
6974 computed: {
70- ... mapState (useMainStore, [' credentialRequestOptions' ]),
7175 httpWarning () {
7276 return document .location .protocol !== ' https:'
7377 },
Original file line number Diff line number Diff line change 44 */
55
66import { createApp } from 'vue'
7- import { createPinia } from 'pinia'
87import Nextcloud from './mixins/Nextcloud.js'
98import Challenge from './components/Challenge.vue'
109import { loadState } from '@nextcloud/initial-state'
11- import { useMainStore } from './store.js'
12-
13- const pinia = createPinia ( )
1410
1511const credentialRequestOptions = loadState ( 'twofactor_webauthn' , 'credential-request-options' )
16- const mainStore = useMainStore ( pinia )
17- mainStore . $patch ( {
18- credentialRequestOptions,
19- } )
2012
21- const app = createApp ( Challenge )
13+ const app = createApp ( Challenge , { credentialRequestOptions } )
2214app . mixin ( Nextcloud )
23- app . use ( pinia )
2415app . mount ( '#twofactor-webauthn-challenge' )
Original file line number Diff line number Diff line change @@ -8,7 +8,6 @@ import * as RegistrationService from './services/RegistrationService.js'
88
99export const useMainStore = defineStore ( 'main' , {
1010 state : ( ) => ( {
11- credentialRequestOptions : { } ,
1211 devices : [ ] ,
1312 } ) ,
1413 actions : {
Original file line number Diff line number Diff line change 1+ /**
2+ * SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
3+ * SPDX-License-Identifier: AGPL-3.0-or-later
4+ */
5+
6+ import { shallowMount } from '@vue/test-utils'
7+ import Nextcloud from '../../../mixins/Nextcloud.js'
8+ import Challenge from '../../../components/Challenge.vue'
9+
10+ describe ( 'Challenge' , ( ) => {
11+ it ( 'receives credentialRequestOptions as a prop' , ( ) => {
12+ const credentialRequestOptions = {
13+ allowCredentials : [ { id : 'abc' , transports : [ 'usb' ] } ] ,
14+ }
15+
16+ const challenge = shallowMount ( Challenge , {
17+ global : {
18+ mixins : [ Nextcloud ] ,
19+ } ,
20+ props : {
21+ credentialRequestOptions,
22+ } ,
23+ } )
24+
25+ expect ( challenge . vm . credentialRequestOptions ) . to . deep . equal ( credentialRequestOptions )
26+ } )
27+ } )
You can’t perform that action at this time.
0 commit comments