mirror of https://github.com/nextcloud/server.git
Vueify the login page
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>pull/15647/head
parent
ccd8da66f2
commit
64c4bb5bce
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -1,14 +0,0 @@
|
||||
import $ from 'jquery';
|
||||
import jstz from 'jstimezonedetect';
|
||||
|
||||
$(document).ready(function () {
|
||||
$('#timezone_offset').val((-new Date().getTimezoneOffset() / 60));
|
||||
$('#timezone').val(jstz.determine().name());
|
||||
|
||||
// only enable the submit button once we are sure that the timezone is set
|
||||
const $loginForm = $('form[name="login"]');
|
||||
if ($loginForm.length) {
|
||||
$loginForm.find('input#submit').prop('disabled', false);
|
||||
}
|
||||
}
|
||||
);
|
@ -0,0 +1,202 @@
|
||||
<!--
|
||||
- @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at>
|
||||
-
|
||||
- @author 2019 Christoph Wurst <christoph@winzerhof-wurst.at>
|
||||
-
|
||||
- @license GNU AGPL version 3 or any later version
|
||||
-
|
||||
- This program is free software: you can redistribute it and/or modify
|
||||
- it under the terms of the GNU Affero General Public License as
|
||||
- published by the Free Software Foundation, either version 3 of the
|
||||
- License, or (at your option) any later version.
|
||||
-
|
||||
- This program is distributed in the hope that it will be useful,
|
||||
- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
- GNU Affero General Public License for more details.
|
||||
-
|
||||
- You should have received a copy of the GNU Affero General Public License
|
||||
- along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
-->
|
||||
|
||||
<template>
|
||||
<form method="post"
|
||||
name="login"
|
||||
@submit="submit">
|
||||
<fieldset>
|
||||
<div v-if="apacheAuthFailed"
|
||||
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">
|
||||
{{ message }}<br>
|
||||
</div>
|
||||
<div v-if="internalException"
|
||||
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>
|
||||
<!-- the following div ensures that the spinner is always inside the #message div -->
|
||||
<div style="clear: both;"></div>
|
||||
</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>
|
||||
<label for="user" class="infield">{{ t('core', 'Username or email') }}</label>
|
||||
</p>
|
||||
|
||||
<p class="groupbottom"
|
||||
:class="{shake: invalidPassword}">
|
||||
<input type="password"
|
||||
name="password"
|
||||
id="password"
|
||||
ref="password"
|
||||
:autocomplete="autoCompleteAllowed ? 'on' : 'off'"
|
||||
:placeholder="t('core', 'Password')"
|
||||
:aria-label="t('core', 'Password')"
|
||||
required>
|
||||
<label for="password"
|
||||
class="infield">{{ t('Password') }}</label>
|
||||
</p>
|
||||
|
||||
<div id="submit-wrapper">
|
||||
<input type="submit"
|
||||
id="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>
|
||||
</div>
|
||||
|
||||
<p v-if="invalidPassword"
|
||||
class="warning wrongPasswordMsg">
|
||||
{{ t('core', 'Wrong username or password.') }}
|
||||
</p>
|
||||
<p v-else-if="userDisabled"
|
||||
class="warning userDisabledMsg">
|
||||
{{ t('lib', 'User disabled') }}
|
||||
</p>
|
||||
|
||||
<p v-if="throttleDelay && throttleDelay > 5000"
|
||||
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">
|
||||
<input type="hidden"
|
||||
name="timezone"
|
||||
:value="timezone" />
|
||||
<input type="hidden"
|
||||
name="timezone_offset"
|
||||
:value="timezoneOffset"/>
|
||||
<input type="hidden"
|
||||
name="requesttoken"
|
||||
:value="OC.requestToken">
|
||||
</fieldset>
|
||||
</form>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
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,
|
||||
},
|
||||
},
|
||||
data () {
|
||||
return {
|
||||
loading: false,
|
||||
timezone: jstz.determine().name(),
|
||||
timezoneOffset: (-new Date().getTimezoneOffset() / 60),
|
||||
user: this.username,
|
||||
password: '',
|
||||
}
|
||||
},
|
||||
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
|
||||
},
|
||||
},
|
||||
mounted () {
|
||||
if (this.username === '') {
|
||||
this.$refs.user.focus()
|
||||
} else {
|
||||
this.$refs.password.focus()
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
updateUsername () {
|
||||
this.$emit('update:username', this.user)
|
||||
},
|
||||
submit () {
|
||||
this.loading = true
|
||||
this.$emit('submit')
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
@ -0,0 +1,150 @@
|
||||
<!--
|
||||
- @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at>
|
||||
-
|
||||
- @author 2019 Christoph Wurst <christoph@winzerhof-wurst.at>
|
||||
-
|
||||
- @license GNU AGPL version 3 or any later version
|
||||
-
|
||||
- This program is free software: you can redistribute it and/or modify
|
||||
- it under the terms of the GNU Affero General Public License as
|
||||
- published by the Free Software Foundation, either version 3 of the
|
||||
- License, or (at your option) any later version.
|
||||
-
|
||||
- This program is distributed in the hope that it will be useful,
|
||||
- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
- GNU Affero General Public License for more details.
|
||||
-
|
||||
- You should have received a copy of the GNU Affero General Public License
|
||||
- along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
-->
|
||||
|
||||
<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>
|
||||
<!--<?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')"/>
|
||||
<div class="submit-icon"
|
||||
:class="{
|
||||
'icon-confirm-white': !loading,
|
||||
'icon-loading-small': loading && invertedColors,
|
||||
'icon-loading-small-dark': loading && !invertedColors,
|
||||
}"></div>
|
||||
</div>
|
||||
<p v-if="message === 'send-success'"
|
||||
class="update">
|
||||
{{ t('core', 'We have sent a password reset e-mail to the e-mail address known to us for this account. If you do not receive it within a reasonable amount of time, check your spam/junk folders.') }}
|
||||
<br>
|
||||
{{ t('core', 'If it is not there ask your local administrator.') }}
|
||||
</p>
|
||||
<p v-else-if="message === 'send-error'"
|
||||
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">
|
||||
{{ t('core', 'Password can not be changed. Please contact your administrator.') }}
|
||||
</p>
|
||||
<p v-else-if="message"
|
||||
class="update"
|
||||
:class="{warning: error}">
|
||||
|
||||
</p>
|
||||
|
||||
<a href="#"
|
||||
@click.prevent="$emit('abort')">
|
||||
{{ t('core', 'Back to login') }}
|
||||
</a>
|
||||
</form>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import Axios from 'nextcloud-axios'
|
||||
|
||||
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,
|
||||
}
|
||||
},
|
||||
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)
|
||||
},
|
||||
submit () {
|
||||
this.loading = true
|
||||
this.error = false
|
||||
this.message = ''
|
||||
const url = generateUrl('/lostpassword/email');
|
||||
|
||||
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}`)
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.update {
|
||||
width: auto;
|
||||
}
|
||||
</style>
|
@ -1,48 +1,63 @@
|
||||
/**
|
||||
* Copyright (c) 2015
|
||||
* Vincent Petry <pvince81@owncloud.com>
|
||||
* Jan-Christoph Borchardt, http://jancborchardt.net
|
||||
* This file is licensed under the Affero General Public License version 3 or later.
|
||||
* See the COPYING-README file.
|
||||
/*
|
||||
* @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at>
|
||||
*
|
||||
* @author 2019 Christoph Wurst <christoph@winzerhof-wurst.at>
|
||||
*
|
||||
* @license GNU AGPL version 3 or any later version
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import $ from 'jquery'
|
||||
import Vue from 'vue';
|
||||
import queryString from 'query-string';
|
||||
|
||||
import './lostpassword'
|
||||
import './Util/visitortimezone'
|
||||
import OC from './OC/index'; // TODO: Not needed but L10n breaks if removed
|
||||
import LoginView from './views/Login.vue';
|
||||
import Nextcloud from './mixins/Nextcloud';
|
||||
|
||||
function onLogin () {
|
||||
// Only if password reset form is not active
|
||||
if ($('form[name=login][action]').length === 0) {
|
||||
$('#submit-wrapper .submit-icon')
|
||||
.removeClass('icon-confirm-white')
|
||||
.addClass(OCA.Theming && OCA.Theming.inverted
|
||||
? 'icon-loading-small'
|
||||
: 'icon-loading-small-dark');
|
||||
$('#submit')
|
||||
.attr('value', t('core', 'Logging in …'));
|
||||
$('.login-additional').fadeOut();
|
||||
return true;
|
||||
const query = queryString.parse(location.search);
|
||||
if (query.clear === '1') {
|
||||
try {
|
||||
window.localStorage.clear();
|
||||
window.sessionStorage.clear();
|
||||
console.debug('Browser storage cleared');
|
||||
} catch (e) {
|
||||
console.error('Could not clear browser storage', e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function rememberLogin () {
|
||||
if ($(this).is(":checked")) {
|
||||
if ($("#user").val() && $("#password").val()) {
|
||||
$('#submit').trigger('click');
|
||||
}
|
||||
Vue.mixin(Nextcloud);
|
||||
|
||||
const fromStateOr = (key, orValue) => {
|
||||
try {
|
||||
return OCP.InitialState.loadState('core', key)
|
||||
} catch (e) {
|
||||
return orValue
|
||||
}
|
||||
}
|
||||
|
||||
$(document).ready(function () {
|
||||
$('form[name=login]').submit(onLogin);
|
||||
|
||||
$('#remember_login').click(rememberLogin);
|
||||
|
||||
const clearParamRegex = new RegExp('clear=1');
|
||||
if (clearParamRegex.test(window.location.href)) {
|
||||
window.localStorage.clear();
|
||||
window.sessionStorage.clear();
|
||||
const View = Vue.extend(LoginView);
|
||||
new View({
|
||||
propsData: {
|
||||
errors: fromStateOr('loginErrors', []),
|
||||
messages: fromStateOr('loginMessages', []),
|
||||
redirectUrl: fromStateOr('loginRedirectUrl', undefined),
|
||||
username: fromStateOr('loginUsername', ''),
|
||||
throttleDelay: fromStateOr('loginThrottleDelay', 0),
|
||||
invertedColors: OCA.Theming && OCA.Theming.inverted,
|
||||
canResetPassword: fromStateOr('loginCanResetPassword', false),
|
||||
resetPasswordLink: fromStateOr('loginResetPasswordLink', ''),
|
||||
autoCompleteAllowed: fromStateOr('loginAutocomplete', true),
|
||||
}
|
||||
});
|
||||
}).$mount('#login');
|
||||
|
@ -1,195 +0,0 @@
|
||||
import $ from 'jquery'
|
||||
|
||||
import OC from './OC/index'
|
||||
|
||||
const sendErrorMsg = t('core', 'Couldn\'t send reset email. Please contact your administrator.');
|
||||
const sendSuccessMsg = t('core', 'We have send a password reset e-mail to the e-mail address known to us for this account. If you do not receive it within a reasonable amount of time, check your spam/junk folders.<br>If it is not there ask your local administrator.');
|
||||
const encryptedMsg = t('core', "Your files are encrypted. There will be no way to get your data back after your password is reset.<br />If you are not sure what to do, please contact your administrator before you continue. <br />Do you really want to continue?")
|
||||
+ ('<br /><input type="checkbox" id="encrypted-continue" class="checkbox checkbox--white" value="Yes" />')
|
||||
+ '<label for="encrypted-continue">'
|
||||
+ t('core', 'I know what I\'m doing')
|
||||
+ '</label><br />';
|
||||
const resetErrorMsg = t('core', 'Password can not be changed. Please contact your administrator.');
|
||||
|
||||
function init () {
|
||||
$('#lost-password[href=""]').click(resetLink);
|
||||
$('#lost-password-back').click(backToLogin);
|
||||
$('form[name=login]').submit(onSendLink);
|
||||
$('#reset-password #submit').click(resetPassword);
|
||||
resetButtons();
|
||||
}
|
||||
|
||||
function resetButtons () {
|
||||
$('#reset-password-wrapper .submit-icon')
|
||||
.addClass('icon-confirm-white')
|
||||
.removeClass('icon-loading-small-dark');
|
||||
$('#reset-password-submit')
|
||||
.attr('value', t('core', 'Reset password'))
|
||||
.prop('disabled', false);
|
||||
$('#user').prop('disabled', false);
|
||||
$('.login-additional').fadeIn();
|
||||
}
|
||||
|
||||
function backToLogin (event) {
|
||||
event.preventDefault();
|
||||
|
||||
$('#reset-password-wrapper').slideUp().fadeOut();
|
||||
$('#lost-password').slideDown().fadeIn();
|
||||
$('#lost-password-back').hide();
|
||||
$('.remember-login-container').slideDown().fadeIn();
|
||||
$('#submit-wrapper').slideDown().fadeIn();
|
||||
$('.groupbottom').slideDown().fadeIn();
|
||||
$('#user').parent().addClass('grouptop');
|
||||
$('#password').attr('required', true);
|
||||
$('form[name=login]').removeAttr('action');
|
||||
$('#user').focus();
|
||||
}
|
||||
|
||||
function resetLink (event) {
|
||||
event.preventDefault();
|
||||
|
||||
$('#lost-password').hide();
|
||||
$('.wrongPasswordMsg').hide();
|
||||
$('#lost-password-back').slideDown().fadeIn();
|
||||
$('.remember-login-container').slideUp().fadeOut();
|
||||
$('#submit-wrapper').slideUp().fadeOut();
|
||||
$('.groupbottom').slideUp().fadeOut(function () {
|
||||
$('#user').parent().removeClass('grouptop');
|
||||
});
|
||||
$('#reset-password-wrapper').slideDown().fadeIn();
|
||||
$('#password').attr('required', false);
|
||||
$('form[name=login]').attr('action', 'lostpassword/email');
|
||||
$('#user').focus();
|
||||
|
||||
// Generate a browser warning for required fields if field empty
|
||||
if ($('#user').val().length === 0) {
|
||||
$('#submit').trigger('click');
|
||||
} else {
|
||||
if (OC.config.lost_password_link === 'disabled') {
|
||||
return;
|
||||
} else if (OC.config.lost_password_link) {
|
||||
window.location = OC.config.lost_password_link;
|
||||
} else {
|
||||
onSendLink();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function onSendLink (event) {
|
||||
// Only if password reset form is active
|
||||
if ($('form[name=login][action]').length === 1) {
|
||||
if (event) {
|
||||
event.preventDefault();
|
||||
}
|
||||
$('#reset-password-wrapper .submit-icon')
|
||||
.removeClass('icon-confirm-white')
|
||||
.addClass('icon-loading-small-dark');
|
||||
$('#reset-password-submit')
|
||||
.attr('value', t('core', 'Sending email …'))
|
||||
.prop('disabled', true);
|
||||
$('#user').prop('disabled', true);
|
||||
$('.login-additional').fadeOut();
|
||||
$.post(
|
||||
OC.generateUrl('/lostpassword/email'),
|
||||
{
|
||||
user: $('#user').val()
|
||||
},
|
||||
sendLinkDone
|
||||
).fail(function () {
|
||||
sendLinkError(sendErrorMsg);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function sendLinkDone (result) {
|
||||
var sendErrorMsg;
|
||||
|
||||
if (result && result.status === 'success') {
|
||||
sendLinkSuccess();
|
||||
} else {
|
||||
if (result && result.msg) {
|
||||
sendErrorMsg = result.msg;
|
||||
} else {
|
||||
sendErrorMsg = sendErrorMsg;
|
||||
}
|
||||
sendLinkError(sendErrorMsg);
|
||||
}
|
||||
}
|
||||
|
||||
function sendLinkSuccess (msg) {
|
||||
const node = getSendStatusNode();
|
||||
// update is the better success message styling
|
||||
node.addClass('update').css({width: 'auto'});
|
||||
node.html(sendSuccessMsg);
|
||||
resetButtons();
|
||||
}
|
||||
|
||||
function sendLinkError (msg) {
|
||||
const node = getSendStatusNode();
|
||||
node.addClass('warning');
|
||||
node.html(msg);
|
||||
resetButtons();
|
||||
}
|
||||
|
||||
function getSendStatusNode () {
|
||||
if (!$('#lost-password').length) {
|
||||
$('<p id="lost-password"></p>').insertBefore($('#remember_login'));
|
||||
} else {
|
||||
$('#lost-password').replaceWith($('<p id="lost-password"></p>'));
|
||||
}
|
||||
return $('#lost-password');
|
||||
}
|
||||
|
||||
function resetPassword (event) {
|
||||
event.preventDefault();
|
||||
if ($('#password').val()) {
|
||||
$.post(
|
||||
$('#password').parents('form').attr('action'),
|
||||
{
|
||||
password: $('#password').val(),
|
||||
proceed: $('#encrypted-continue').is(':checked') ? 'true' : 'false'
|
||||
},
|
||||
resetDone
|
||||
);
|
||||
}
|
||||
if ($('#encrypted-continue').is(':checked')) {
|
||||
$('#reset-password #submit').hide();
|
||||
$('#reset-password #float-spinner').removeClass('hidden');
|
||||
}
|
||||
}
|
||||
|
||||
function resetDone (result) {
|
||||
if (result && result.status === 'success') {
|
||||
redirect('/login?user=' + result.user);
|
||||
} else {
|
||||
if (result && result.msg) {
|
||||
resetError(result.msg);
|
||||
} else if (result && result.encryption) {
|
||||
resetError(encryptedMsg);
|
||||
} else {
|
||||
resetError(resetErrorMsg);
|
||||
}
|
||||
resetError(resetErrorMsg);
|
||||
}
|
||||
}
|
||||
|
||||
function redirect (url) {
|
||||
window.location = OC.generateUrl(url);
|
||||
}
|
||||
|
||||
function resetError (msg) {
|
||||
var node = getResetStatusNode();
|
||||
node.addClass('warning');
|
||||
node.html(msg);
|
||||
}
|
||||
|
||||
function getResetStatusNode () {
|
||||
if (!$('#lost-password').length) {
|
||||
$('<p id="lost-password"></p>').insertBefore($('#reset-password fieldset'));
|
||||
} else {
|
||||
$('#lost-password').replaceWith($('<p id="lost-password"></p>'));
|
||||
}
|
||||
return $('#lost-password');
|
||||
}
|
||||
|
||||
$(document).ready(init);
|
@ -0,0 +1,35 @@
|
||||
/*
|
||||
* @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at>
|
||||
*
|
||||
* @author 2019 Christoph Wurst <christoph@winzerhof-wurst.at>
|
||||
*
|
||||
* @license GNU AGPL version 3 or any later version
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import L10n from '../OC/l10n'
|
||||
import OC from '../OC/index'
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
OC,
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
t: L10n.translate.bind(L10n),
|
||||
n: L10n.translatePlural.bind(L10n),
|
||||
},
|
||||
}
|
@ -0,0 +1,125 @@
|
||||
<!--
|
||||
- @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at>
|
||||
-
|
||||
- @author 2019 Christoph Wurst <christoph@winzerhof-wurst.at>
|
||||
-
|
||||
- @license GNU AGPL version 3 or any later version
|
||||
-
|
||||
- This program is free software: you can redistribute it and/or modify
|
||||
- it under the terms of the GNU Affero General Public License as
|
||||
- published by the Free Software Foundation, either version 3 of the
|
||||
- License, or (at your option) any later version.
|
||||
-
|
||||
- This program is distributed in the hope that it will be useful,
|
||||
- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
- GNU Affero General Public License for more details.
|
||||
-
|
||||
- You should have received a copy of the GNU Affero General Public License
|
||||
- along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
-->
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<transition name="fade" mode="out-in">
|
||||
<div v-if="!resetPassword"
|
||||
key="login">
|
||||
<LoginForm
|
||||
:username.sync="user"
|
||||
:redirect-url="redirectUrl"
|
||||
:messages="messages"
|
||||
:errors="errors"
|
||||
:throttle-delay="throttleDelay"
|
||||
:inverted-colors="invertedColors"
|
||||
:auto-complete-allowed="autoCompleteAllowed"
|
||||
@submit="loading = true"/>
|
||||
<a v-if="canResetPassword && resetPasswordLink !== ''"
|
||||
id="lost-password"
|
||||
:href="resetPasswordLink">
|
||||
{{ t('core', 'Forgot password?') }}
|
||||
</a>
|
||||
<a v-else-if="canResetPassword && !resetPassword"
|
||||
id="lost-password"
|
||||
:href="resetPasswordLink"
|
||||
@click.prevent="resetPassword = true">
|
||||
{{ t('core', 'Forgot password?') }}
|
||||
</a>
|
||||
</div>
|
||||
<div v-else-if="!loading && canResetPassword"
|
||||
key="reset"
|
||||
class="login-additional">
|
||||
<div class="lost-password-container">
|
||||
<ResetPassword v-if="resetPassword"
|
||||
:username.sync="user"
|
||||
:reset-password-link="resetPasswordLink"
|
||||
:inverted-colors="invertedColors"
|
||||
@abort="resetPassword = false"/>
|
||||
</div>
|
||||
</div>
|
||||
</transition>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import LoginForm from '../components/login/LoginForm.vue'
|
||||
import ResetPassword from '../components/login/ResetPassword.vue'
|
||||
|
||||
export default {
|
||||
name: 'Login',
|
||||
props: {
|
||||
username: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
redirectUrl: {
|
||||
type: String,
|
||||
},
|
||||
errors: {
|
||||
type: Array,
|
||||
default: () => [],
|
||||
},
|
||||
messages: {
|
||||
type: Array,
|
||||
default: () => [],
|
||||
},
|
||||
throttleDelay: {
|
||||
type: Number,
|
||||
},
|
||||
canResetPassword: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
resetPasswordLink: {
|
||||
type: String,
|
||||
},
|
||||
invertedColors: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
autoCompleteAllowed: {
|
||||
type: Boolean,
|
||||
default: true,
|
||||
},
|
||||
},
|
||||
components: {
|
||||
LoginForm,
|
||||
ResetPassword,
|
||||
},
|
||||
data () {
|
||||
return {
|
||||
loading: false,
|
||||
user: this.username,
|
||||
resetPassword: false,
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.fade-enter-active, .fade-leave-active {
|
||||
transition: opacity .3s;
|
||||
}
|
||||
.fade-enter, .fade-leave-to /* .fade-leave-active below version 2.1.8 */ {
|
||||
opacity: 0;
|
||||
}
|
||||
</style>
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue