diff options
author | John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com> | 2019-09-25 18:19:42 +0200 |
---|---|---|
committer | John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com> | 2019-10-01 17:16:09 +0200 |
commit | b9bc2417e7a8dc81feb0abe20359bedaf864f790 (patch) | |
tree | 61b47fbf37c1d168da8625224debde9e6a985348 /core/src/components/login | |
parent | 7fb651235128dcbca8a6683b5cdafdf835f46300 (diff) | |
download | nextcloud-server-b9bc2417e7a8dc81feb0abe20359bedaf864f790.tar.gz nextcloud-server-b9bc2417e7a8dc81feb0abe20359bedaf864f790.zip |
Comply to eslint
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
Diffstat (limited to 'core/src/components/login')
-rw-r--r-- | core/src/components/login/LoginForm.vue | 262 | ||||
-rw-r--r-- | core/src/components/login/ResetPassword.vue | 162 | ||||
-rw-r--r-- | core/src/components/login/UpdatePassword.vue | 150 |
3 files changed, 289 insertions, 285 deletions
diff --git a/core/src/components/login/LoginForm.vue b/core/src/components/login/LoginForm.vue index 3ba13b4f025..e9f44cccb8f 100644 --- a/core/src/components/login/LoginForm.vue +++ b/core/src/components/login/LoginForm.vue @@ -21,195 +21,195 @@ <template> <form method="post" - name="login" - :action="OC.generateUrl('login')" - @submit="submit"> + name="login" + :action="OC.generateUrl('login')" + @submit="submit"> <fieldset> <div v-if="apacheAuthFailed" - class="warning"> + class="warning"> {{ t('core', 'Server side authentication failed!') }}<br> <small>{{ t('core', 'Please contact your administrator.') }} </small> </div> - <div v-for="message in messages" - class="warning"> + <div v-for="(message, index) in messages" + :key="index" + class="warning"> {{ message }}<br> </div> <div v-if="internalException" - class="warning"> + class="warning"> {{ t('core', 'An internal error occurred.') }}<br> <small>{{ t('core', 'Please try again or contact your administrator.') }} </small> </div> <div id="message" - class="hidden"> - <img class="float-spinner" alt="" - :src="OC.imagePath('core', 'loading-dark.gif')"> - <span id="messageText"></span> + class="hidden"> + <img class="float-spinner" + alt="" + :src="OC.imagePath('core', 'loading-dark.gif')"> + <span id="messageText" /> <!-- the following div ensures that the spinner is always inside the #message div --> - <div style="clear: both;"></div> + <div style="clear: both;" /> </div> <p class="grouptop" - :class="{shake: invalidPassword}"> - <input type="text" - name="user" - id="user" - ref="user" - :autocomplete="autoCompleteAllowed ? 'on' : 'off'" - :placeholder="t('core', 'Username or email')" - :aria-label="t('core', 'Username or email')" - v-model="user" - @change="updateUsername" - required> + :class="{shake: invalidPassword}"> + <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="updateUsername"> <label for="user" class="infield">{{ t('core', 'Username or email') }}</label> </p> <p class="groupbottom" - :class="{shake: invalidPassword}"> - <input :type="passwordInputType" - class="password-with-toggle" - name="password" - id="password" - ref="password" - :autocomplete="autoCompleteAllowed ? 'on' : 'off'" - :placeholder="t('core', 'Password')" - :aria-label="t('core', 'Password')" - required> + :class="{shake: invalidPassword}"> + <input id="password" + ref="password" + :type="passwordInputType" + class="password-with-toggle" + name="password" + :autocomplete="autoCompleteAllowed ? 'on' : 'off'" + :placeholder="t('core', 'Password')" + :aria-label="t('core', 'Password')" + required> <label for="password" - class="infield">{{ t('Password') }}</label> - <a href="#" @click.stop.prevent="togglePassword" class="toggle-password"> - <img :src="OC.imagePath('core', 'actions/toggle.svg')"/> + class="infield">{{ t('Password') }}</label> + <a href="#" class="toggle-password" @click.stop.prevent="togglePassword"> + <img :src="OC.imagePath('core', 'actions/toggle.svg')"> </a> </p> <div id="submit-wrapper"> - <input type="submit" - class="login primary" - name="submit" - id="submit-form" - title="" - :value="!loading ? t('core', 'Log in') : t('core', 'Logging in …')" /> + <input id="submit-form" + type="submit" + class="login primary" + title="" + :value="!loading ? t('core', 'Log in') : t('core', 'Logging in …')"> <div class="submit-icon" - :class="{ - 'icon-confirm-white': !loading, - 'icon-loading-small': loading && invertedColors, - 'icon-loading-small-dark': loading && !invertedColors, - }"></div> + :class="{ + 'icon-confirm-white': !loading, + 'icon-loading-small': loading && invertedColors, + 'icon-loading-small-dark': loading && !invertedColors, + }" /> </div> <p v-if="invalidPassword" - class="warning wrongPasswordMsg"> + class="warning wrongPasswordMsg"> {{ t('core', 'Wrong username or password.') }} </p> <p v-else-if="userDisabled" - class="warning userDisabledMsg"> + class="warning userDisabledMsg"> {{ t('lib', 'User disabled') }} </p> <p v-if="throttleDelay && throttleDelay > 5000" - class="warning throttledMsg"> + class="warning throttledMsg"> {{ t('core', 'We have detected multiple invalid login attempts from your IP. Therefore your next login is throttled up to 30 seconds.') }} </p> <input v-if="redirectUrl" - type="hidden" - name="redirect_url" - :value="redirectUrl"> + type="hidden" + name="redirect_url" + :value="redirectUrl"> <input type="hidden" - name="timezone" - :value="timezone" /> + name="timezone" + :value="timezone"> <input type="hidden" - name="timezone_offset" - :value="timezoneOffset"/> + name="timezone_offset" + :value="timezoneOffset"> <input type="hidden" - name="requesttoken" - :value="OC.requestToken"> + name="requesttoken" + :value="OC.requestToken"> </fieldset> </form> </template> <script> - import jstz from 'jstimezonedetect' +import jstz from 'jstimezonedetect' - export default { - name: 'LoginForm', - props: { - username: { - type: String, - default: '', - }, - redirectUrl: { - type: String, - }, - errors: { - type: Array, - default: () => [], - }, - messages: { - type: Array, - default: () => [], - }, - throttleDelay: { - type: Number, - }, - invertedColors: { - type: Boolean, - default: false, - }, - autoCompleteAllowed: { - type: Boolean, - default: true, - }, +export default { + name: 'LoginForm', + props: { + username: { + type: String, + default: '' }, - data () { - return { - loading: false, - timezone: jstz.determine().name(), - timezoneOffset: (-new Date().getTimezoneOffset() / 60), - user: this.username, - password: '', - passwordInputType: 'password', - } + redirectUrl: { + type: String + }, + errors: { + type: Array, + default: () => [] + }, + messages: { + type: Array, + default: () => [] + }, + throttleDelay: { + type: Number }, - computed: { - apacheAuthFailed () { - return this.errors.indexOf('apacheAuthFailed') !== -1 - }, - internalException () { - return this.errors.indexOf('internalexception') !== -1 - }, - invalidPassword () { - return this.errors.indexOf('invalidpassword') !== -1 - }, - userDisabled () { - return this.errors.indexOf('userdisabled') !== -1 - }, + invertedColors: { + type: Boolean, + default: false + }, + autoCompleteAllowed: { + type: Boolean, + default: true + } + }, + data() { + return { + loading: false, + timezone: jstz.determine().name(), + timezoneOffset: (-new Date().getTimezoneOffset() / 60), + user: this.username, + password: '', + passwordInputType: 'password' + } + }, + computed: { + apacheAuthFailed() { + return this.errors.indexOf('apacheAuthFailed') !== -1 }, - mounted () { - if (this.username === '') { - this.$refs.user.focus() + internalException() { + return this.errors.indexOf('internalexception') !== -1 + }, + invalidPassword() { + return this.errors.indexOf('invalidpassword') !== -1 + }, + userDisabled() { + return this.errors.indexOf('userdisabled') !== -1 + } + }, + mounted() { + if (this.username === '') { + this.$refs.user.focus() + } else { + this.$refs.password.focus() + } + }, + methods: { + togglePassword() { + if (this.passwordInputType === 'password') { + this.passwordInputType = 'text' } else { - this.$refs.password.focus() + this.passwordInputType = 'password' } }, - methods: { - togglePassword () { - if(this.passwordInputType === 'password'){ - this.passwordInputType = 'text' - } - else{ - this.passwordInputType = 'password' - } - }, - updateUsername () { - this.$emit('update:username', this.user) - }, - submit () { - this.loading = true - this.$emit('submit') - } + updateUsername() { + this.$emit('update:username', this.user) + }, + submit() { + this.loading = true + this.$emit('submit') } } +} </script> <style scoped> diff --git a/core/src/components/login/ResetPassword.vue b/core/src/components/login/ResetPassword.vue index ac152342d4f..0fd50e43ea9 100644 --- a/core/src/components/login/ResetPassword.vue +++ b/core/src/components/login/ResetPassword.vue @@ -22,125 +22,123 @@ <template> <form @submit.prevent="submit"> <p> - <input type="text" - name="user" - id="user" - :placeholder="t('core', 'Username or email')" - :aria-label="t('core', 'Username or email')" - v-model="user" - @change="updateUsername" - required> + <input id="user" + v-model="user" + type="text" + name="user" + :placeholder="t('core', 'Username or email')" + :aria-label="t('core', 'Username or email')" + required + @change="updateUsername"> <!--<?php p($_['user_autofocus'] ? 'autofocus' : ''); ?> autocomplete="<?php p($_['login_form_autocomplete']); ?>" autocapitalize="none" autocorrect="off"--> <label for="user" class="infield">{{ t('core', 'Username or email') }}</label> </p> <div id="reset-password-wrapper"> - <input type="submit" - id="reset-password-submit" - class="login primary" - title="" - :value="t('core', 'Reset password')"/> + <input id="reset-password-submit" + type="submit" + class="login primary" + title="" + :value="t('core', 'Reset password')"> <div class="submit-icon" - :class="{ - 'icon-confirm-white': !loading, - 'icon-loading-small': loading && invertedColors, - 'icon-loading-small-dark': loading && !invertedColors, - }"></div> + :class="{ + 'icon-confirm-white': !loading, + 'icon-loading-small': loading && invertedColors, + 'icon-loading-small-dark': loading && !invertedColors, + }" /> </div> <p v-if="message === 'send-success'" - class="update"> + class="update"> {{ t('core', 'A password reset message has been sent to the e-mail address of this account. If you do not receive it, check your spam/junk folders or ask your local administrator for help.') }} <br> {{ t('core', 'If it is not there ask your local administrator.') }} </p> <p v-else-if="message === 'send-error'" - class="update warning"> + class="update warning"> {{ t('core', 'Couldn\'t send reset email. Please contact your administrator.') }} </p> <p v-else-if="message === 'reset-error'" - class="update warning"> + class="update warning"> {{ t('core', 'Password can not be changed. Please contact your administrator.') }} </p> <p v-else-if="message" - class="update" - :class="{warning: error}"> - - </p> + class="update" + :class="{warning: error}" /> <a href="#" - @click.prevent="$emit('abort')"> + @click.prevent="$emit('abort')"> {{ t('core', 'Back to login') }} </a> </form> </template> <script> - import Axios from 'nextcloud-axios' +import axios from 'nextcloud-axios' - import {generateUrl} from '../../OC/routing' +import { generateUrl } from '../../OC/routing' - export default { - name: 'ResetPassword', - props: { - username: { - type: String, - required: true, - }, - resetPasswordLink: { - type: String, - required: true, - }, - invertedColors: { - type: Boolean, - default: false, - } +export default { + name: 'ResetPassword', + props: { + username: { + type: String, + required: true }, - data() { - return { - error: false, - loading: false, - message: undefined, - user: this.username, - } + resetPasswordLink: { + type: String, + required: true }, - watch: { - username (value) { - this.user = value - } + invertedColors: { + type: Boolean, + default: false + } + }, + data() { + return { + error: false, + loading: false, + message: undefined, + user: this.username + } + }, + watch: { + username(value) { + this.user = value + } + }, + methods: { + updateUsername() { + this.$emit('update:username', this.user) }, - methods: { - updateUsername () { - this.$emit('update:username', this.user) - }, - submit () { - this.loading = true - this.error = false - this.message = '' - const url = generateUrl('/lostpassword/email'); + submit() { + this.loading = true + this.error = false + this.message = '' + const url = generateUrl('/lostpassword/email') - const data = { - user: this.user, - } + const data = { + user: this.user + } - return Axios.post(url, data) - .then(resp => resp.data) - .then(data => { - if (data.status !== 'success') { - throw new Error(`got status ${data.status}`) - } + return axios.post(url, data) + .then(resp => resp.data) + .then(data => { + if (data.status !== 'success') { + throw new Error(`got status ${data.status}`) + } - this.message = 'send-success' - }) - .catch(e => { - console.error('could not send reset e-mail request', e) + this.message = 'send-success' + }) + .catch(e => { + console.error('could not send reset e-mail request', e) - this.error = true - this.message = 'send-error' - }) - .then(() => this.loading = false) - } - }, + this.error = true + this.message = 'send-error' + }) + .then(() => { this.loading = false }) + } } +} </script> <style scoped> diff --git a/core/src/components/login/UpdatePassword.vue b/core/src/components/login/UpdatePassword.vue index 3b5ac32133d..c0976bf0d6f 100644 --- a/core/src/components/login/UpdatePassword.vue +++ b/core/src/components/login/UpdatePassword.vue @@ -25,32 +25,38 @@ <fieldset> <p> <label for="password" class="infield">{{ t('core', 'New password') }}</label> - <input type="password" name="password" - id="password" v-model="password" required - :placeholder="t('core', 'New password')" /> + <input id="password" + v-model="password" + type="password" + name="password" + required + :placeholder="t('core', 'New password')"> </p> <div v-if="encrypted" class="update"> <p> {{ t('core', 'Your files are encrypted. There will be no way to get your data back after your password is reset. If you are not sure what to do, please contact your administrator before you continue. Do you really want to continue?') }} </p> - <input type="checkbox" class="checkbox" - id="encrypted-continue" v-model="proceed" /> + <input id="encrypted-continue" + v-model="proceed" + type="checkbox" + class="checkbox"> <label for="encrypted-continue"> {{ t('core', 'I know what I\'m doing') }} </label> </div> <div id="submit-wrapper"> - <input type="submit" - id="submit" - class="login primary" - title="" - :value="!loading ? t('core', 'Reset password') : t('core', 'Resetting password')" /> - <div class="submit-icon" :class="{ - 'icon-loading-small': loading && invertedColors, - 'icon-loading-small-dark': loading && !invertedColors - }"></div> + <input id="submit" + type="submit" + class="login primary" + title="" + :value="!loading ? t('core', 'Reset password') : t('core', 'Resetting password')"> + <div class="submit-icon" + :class="{ + 'icon-loading-small': loading && invertedColors, + 'icon-loading-small-dark': loading && !invertedColors + }" /> </div> <p v-if="error && message" :class="{warning: error}"> @@ -61,71 +67,71 @@ </template> <script> - import Axios from 'nextcloud-axios' +import Axios from 'nextcloud-axios' - export default { - name: 'UpdatePassword', - props: { - username: { - type: String, - required: true, - }, - resetPasswordTarget: { - type: String, - required: true, - }, - invertedColors: { - type: Boolean, - default: false, - } +export default { + name: 'UpdatePassword', + props: { + username: { + type: String, + required: true }, - data() { - return { - error: false, - loading: false, - message: undefined, - user: this.username, - password: '', - encrypted: false, - proceed: false - } + resetPasswordTarget: { + type: String, + required: true }, - watch: { - username (value) { - this.user = value - } - }, - methods: { - async submit () { - this.loading = true - this.error = false - this.message = '' + invertedColors: { + type: Boolean, + default: false + } + }, + data() { + return { + error: false, + loading: false, + message: undefined, + user: this.username, + password: '', + encrypted: false, + proceed: false + } + }, + watch: { + username(value) { + this.user = value + } + }, + methods: { + async submit() { + this.loading = true + this.error = false + this.message = '' - try { - const { data } = await Axios.post(this.resetPasswordTarget, { - password: this.password, - proceed: this.proceed - }) - if (data && data.status === 'success') { - this.message = 'send-success' - this.$emit('update:username', this.user) - this.$emit('done') - } else if (data && data.encryption) { - this.encrypted = true - } else if (data && data.msg) { - throw new Error(data.msg) - } else { - throw new Error() - } - } catch (e) { - this.error = true - this.message = e.message ? e.message : t('core', 'Password can not be changed. Please contact your administrator.') - } finally { - this.loading = false + try { + const { data } = await Axios.post(this.resetPasswordTarget, { + password: this.password, + proceed: this.proceed + }) + if (data && data.status === 'success') { + this.message = 'send-success' + this.$emit('update:username', this.user) + this.$emit('done') + } else if (data && data.encryption) { + this.encrypted = true + } else if (data && data.msg) { + throw new Error(data.msg) + } else { + throw new Error() } + } catch (e) { + this.error = true + this.message = e.message ? e.message : t('core', 'Password can not be changed. Please contact your administrator.') + } finally { + this.loading = false } - }, + } } +} </script> <style scoped> |