Skip to content

Commit

Permalink
Merge pull request #38330 from nextcloud/fix/alt-login-box-design
Browse files Browse the repository at this point in the history
Adjust style of passwordless login
  • Loading branch information
szaimen authored May 17, 2023
2 parents 3fc43bc + 5be82f2 commit fa3bbb2
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 30 deletions.
57 changes: 33 additions & 24 deletions core/src/components/login/PasswordLessLoginForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,38 +4,31 @@
method="post"
name="login"
@submit.prevent="submit">
<h2>{{ t('core', 'Log in with a device') }}</h2>
<fieldset>
<p class="grouptop groupbottom">
<label for="user" class="infield">{{ t('core', 'Username or email') }}</label>
<input id="user"
ref="user"
v-model="user"
type="text"
name="user"
:autocomplete="autoCompleteAllowed ? 'on' : 'off'"
:placeholder="t('core', 'Username or email')"
:aria-label="t('core', 'Username or email')"
required
@change="$emit('update:username', user)">
</p>

<div v-if="!validCredentials" class="body-login-container update form__message-box">
{{ t('core', 'Your account is not setup for passwordless login.') }}
</div>
<NcTextField required
:value="user"
:autocomplete="autoCompleteAllowed ? 'on' : 'off'"
:error="!validCredentials"
:label-visible="true"
:label="t('core', 'Username or email')"
:placeholder="t('core', 'Username or email')"
:helper-text="!validCredentials ? t('core', 'Your account is not setup for passwordless login.') : ''"
@update:value="changeUsername" />

<LoginButton v-if="validCredentials"
:loading="loading"
@click="authenticate" />
</fieldset>
</form>
<div v-else-if="!hasPublicKeyCredential" class="body-login-container update">
<div v-else-if="!hasPublicKeyCredential" class="update">
<InformationIcon size="70" />
<h2>{{ t('core', 'Browser not supported') }}</h2>
<p class="infogroup">
{{ t('core', 'Passwordless authentication is not supported in your browser.') }}
</p>
</div>
<div v-else-if="!isHttps && !isLocalhost" class="body-login-container update">
<div v-else-if="!isHttps && !isLocalhost" class="update">
<LockOpenIcon size="70" />
<h2>{{ t('core', 'Your connection is not secure') }}</h2>
<p class="infogroup">
Expand All @@ -52,6 +45,7 @@ import {
import LoginButton from './LoginButton.vue'
import InformationIcon from 'vue-material-design-icons/Information.vue'
import LockOpenIcon from 'vue-material-design-icons/LockOpen.vue'
import NcTextField from '@nextcloud/vue/dist/Components/NcTextField.js'
class NoValidCredentials extends Error {
Expand All @@ -63,6 +57,7 @@ export default {
LoginButton,
InformationIcon,
LockOpenIcon,
NcTextField,
},
props: {
username: {
Expand Down Expand Up @@ -99,6 +94,11 @@ export default {
},
methods: {
authenticate() {
// check required fields
if (!this.$refs.loginForm.checkValidity()) {
return
}
console.debug('passwordless login initiated')
this.getAuthenticationData(this.user)
Expand All @@ -116,6 +116,10 @@ export default {
console.debug(error)
})
},
changeUsername(username) {
this.user = username
this.$emit('update:username', this.user)
},
getAuthenticationData(uid) {
const base64urlDecode = function(input) {
// Replace non-url compatible chars with base64 standard chars
Expand Down Expand Up @@ -221,12 +225,17 @@ export default {
</script>

<style lang="scss" scoped>
.body-login-container.update {
margin: 15px 0;
fieldset {
display: flex;
flex-direction: column;
gap: 0.5rem;
&.form__message-box {
width: 240px;
margin: 5px;
:deep(label) {
text-align: initial;
}
}
.update {
margin: 0 auto;
}
</style>
15 changes: 12 additions & 3 deletions core/src/views/Login.vue
Original file line number Diff line number Diff line change
Expand Up @@ -65,17 +65,20 @@
</div>
<div v-else-if="!loading && passwordlessLogin"
key="reset"
class="login-additional">
class="login-additional login-passwordless">
<PasswordLessLoginForm :username.sync="user"
:redirect-url="redirectUrl"
:auto-complete-allowed="autoCompleteAllowed"
:is-https="isHttps"
:is-localhost="isLocalhost"
:has-public-key-credential="hasPublicKeyCredential"
@submit="loading = true" />
<a href="#" class="login-box__link" @click.prevent="passwordlessLogin = false">
<NcButton type="tertiary"
:aria-label="t('core', 'Back to login form')"
:wide="true"
@click="passwordlessLogin = false">
{{ t('core', 'Back') }}
</a>
</NcButton>
</div>
<div v-else-if="!loading && canResetPassword"
key="reset"
Expand Down Expand Up @@ -249,4 +252,10 @@ footer {
box-sizing: border-box;
}
}

.login-passwordless {
.button-vue {
margin-top: 0.5rem;
}
}
</style>
4 changes: 2 additions & 2 deletions dist/core-login.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/core-login.js.map

Large diffs are not rendered by default.

0 comments on commit fa3bbb2

Please sign in to comment.