44 method =" post"
55 name =" login"
66 @submit.prevent =" submit" >
7+ <h2 >{{ t('core', 'Log in with a device') }}</h2 >
78 <fieldset >
8- <p class =" grouptop groupbottom" >
9- <label for =" user" class =" infield" >{{ t('core', 'Username or email') }}</label >
10- <input id =" user"
11- ref =" user"
12- v-model =" user"
13- type =" text"
14- name =" user"
15- :autocomplete =" autoCompleteAllowed ? 'on' : 'off'"
16- :placeholder =" t('core', 'Username or email')"
17- :aria-label =" t('core', 'Username or email')"
18- required
19- @change =" $emit('update:username', user)" >
20- </p >
21-
22- <div v-if =" !validCredentials" class =" body-login-container update form__message-box" >
23- {{ t('core', 'Your account is not setup for passwordless login.') }}
24- </div >
9+ <NcTextField required
10+ :value =" user"
11+ :autocomplete =" autoCompleteAllowed ? 'on' : 'off'"
12+ :error =" !validCredentials"
13+ :label-visible =" true"
14+ :label =" t('core', 'Username or email')"
15+ :placeholder =" t('core', 'Username or email')"
16+ :helper-text =" !validCredentials ? t('core', 'Your account is not setup for passwordless login.') : ''"
17+ @update:value =" changeUsername" />
2518
2619 <LoginButton v-if =" validCredentials"
2720 :loading =" loading"
2821 @click =" authenticate" />
2922 </fieldset >
3023 </form >
31- <div v-else-if =" !hasPublicKeyCredential" class =" body-login-container update" >
24+ <div v-else-if =" !hasPublicKeyCredential" class =" update" >
3225 <InformationIcon size =" 70" />
3326 <h2 >{{ t('core', 'Browser not supported') }}</h2 >
3427 <p class =" infogroup" >
3528 {{ t('core', 'Passwordless authentication is not supported in your browser.') }}
3629 </p >
3730 </div >
38- <div v-else-if =" !isHttps && !isLocalhost" class =" body-login-container update" >
31+ <div v-else-if =" !isHttps && !isLocalhost" class =" update" >
3932 <LockOpenIcon size =" 70" />
4033 <h2 >{{ t('core', 'Your connection is not secure') }}</h2 >
4134 <p class =" infogroup" >
@@ -52,6 +45,7 @@ import {
5245import LoginButton from ' ./LoginButton.vue'
5346import InformationIcon from ' vue-material-design-icons/Information.vue'
5447import LockOpenIcon from ' vue-material-design-icons/LockOpen.vue'
48+ import NcTextField from ' @nextcloud/vue/dist/Components/NcTextField.js'
5549
5650class NoValidCredentials extends Error {
5751
@@ -63,6 +57,7 @@ export default {
6357 LoginButton,
6458 InformationIcon,
6559 LockOpenIcon,
60+ NcTextField,
6661 },
6762 props: {
6863 username: {
@@ -99,6 +94,11 @@ export default {
9994 },
10095 methods: {
10196 authenticate () {
97+ // check required fields
98+ if (! this .$refs .loginForm .checkValidity ()) {
99+ return
100+ }
101+
102102 console .debug (' passwordless login initiated' )
103103
104104 this .getAuthenticationData (this .user )
@@ -116,6 +116,10 @@ export default {
116116 console .debug (error)
117117 })
118118 },
119+ changeUsername (username ) {
120+ this .user = username
121+ this .$emit (' update:username' , this .user )
122+ },
119123 getAuthenticationData (uid ) {
120124 const base64urlDecode = function (input ) {
121125 // Replace non-url compatible chars with base64 standard chars
@@ -221,12 +225,17 @@ export default {
221225 </script >
222226
223227<style lang="scss" scoped>
224- .body-login-container.update {
225- margin : 15px 0 ;
228+ fieldset {
229+ display : flex ;
230+ flex-direction : column ;
231+ gap : 0.5rem ;
226232
227- & .form__message-box {
228- width : 240px ;
229- margin : 5px ;
233+ :deep (label ) {
234+ text-align : initial ;
230235 }
231236 }
237+
238+ .update {
239+ margin : 0 auto ;
240+ }
232241 </style >
0 commit comments