Skip to content

Commit fa3bbb2

Browse files
authored
Merge pull request #38330 from nextcloud/fix/alt-login-box-design
Adjust style of passwordless login
2 parents 3fc43bc + 5be82f2 commit fa3bbb2

File tree

4 files changed

+48
-30
lines changed

4 files changed

+48
-30
lines changed

core/src/components/login/PasswordLessLoginForm.vue

Lines changed: 33 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4,38 +4,31 @@
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 {
5245
import LoginButton from './LoginButton.vue'
5346
import InformationIcon from 'vue-material-design-icons/Information.vue'
5447
import LockOpenIcon from 'vue-material-design-icons/LockOpen.vue'
48+
import NcTextField from '@nextcloud/vue/dist/Components/NcTextField.js'
5549
5650
class 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>

core/src/views/Login.vue

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,17 +65,20 @@
6565
</div>
6666
<div v-else-if="!loading && passwordlessLogin"
6767
key="reset"
68-
class="login-additional">
68+
class="login-additional login-passwordless">
6969
<PasswordLessLoginForm :username.sync="user"
7070
:redirect-url="redirectUrl"
7171
:auto-complete-allowed="autoCompleteAllowed"
7272
:is-https="isHttps"
7373
:is-localhost="isLocalhost"
7474
:has-public-key-credential="hasPublicKeyCredential"
7575
@submit="loading = true" />
76-
<a href="#" class="login-box__link" @click.prevent="passwordlessLogin = false">
76+
<NcButton type="tertiary"
77+
:aria-label="t('core', 'Back to login form')"
78+
:wide="true"
79+
@click="passwordlessLogin = false">
7780
{{ t('core', 'Back') }}
78-
</a>
81+
</NcButton>
7982
</div>
8083
<div v-else-if="!loading && canResetPassword"
8184
key="reset"
@@ -249,4 +252,10 @@ footer {
249252
box-sizing: border-box;
250253
}
251254
}
255+
256+
.login-passwordless {
257+
.button-vue {
258+
margin-top: 0.5rem;
259+
}
260+
}
252261
</style>

dist/core-login.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/core-login.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)