2019-05-21 09:58:35 +03:00
|
|
|
/*
|
|
|
|
* @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/>.
|
2019-01-30 19:06:01 +03:00
|
|
|
*/
|
|
|
|
|
2019-10-03 18:08:39 +03:00
|
|
|
import { loadState } from '@nextcloud/initial-state'
|
2019-09-25 19:19:42 +03:00
|
|
|
import queryString from 'query-string'
|
2019-10-03 18:08:39 +03:00
|
|
|
import Vue from 'vue'
|
2019-01-30 19:06:01 +03:00
|
|
|
|
2019-09-25 19:19:42 +03:00
|
|
|
// eslint-disable-next-line no-unused-vars
|
|
|
|
import OC from './OC/index' // TODO: Not needed but L10n breaks if removed
|
|
|
|
import LoginView from './views/Login.vue'
|
|
|
|
import Nextcloud from './mixins/Nextcloud'
|
2019-01-30 19:06:01 +03:00
|
|
|
|
2019-09-25 19:19:42 +03:00
|
|
|
const query = queryString.parse(location.search)
|
2019-05-21 09:58:35 +03:00
|
|
|
if (query.clear === '1') {
|
|
|
|
try {
|
2019-09-25 19:19:42 +03:00
|
|
|
window.localStorage.clear()
|
|
|
|
window.sessionStorage.clear()
|
|
|
|
console.debug('Browser storage cleared')
|
2019-05-21 09:58:35 +03:00
|
|
|
} catch (e) {
|
2019-09-25 19:19:42 +03:00
|
|
|
console.error('Could not clear browser storage', e)
|
2019-01-30 19:06:01 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-09-25 19:19:42 +03:00
|
|
|
Vue.mixin(Nextcloud)
|
2019-05-21 09:58:35 +03:00
|
|
|
|
|
|
|
const fromStateOr = (key, orValue) => {
|
|
|
|
try {
|
2019-10-03 18:08:39 +03:00
|
|
|
return loadState('core', key)
|
2019-05-21 09:58:35 +03:00
|
|
|
} catch (e) {
|
|
|
|
return orValue
|
2019-01-30 19:06:01 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-09-25 19:19:42 +03:00
|
|
|
const View = Vue.extend(LoginView)
|
2019-05-21 09:58:35 +03:00
|
|
|
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),
|
2019-07-25 18:04:33 +03:00
|
|
|
resetPasswordTarget: fromStateOr('resetPasswordTarget', ''),
|
2019-10-15 17:27:41 +03:00
|
|
|
resetPasswordUser: fromStateOr('resetPasswordUser', ''),
|
2019-11-13 15:05:10 +03:00
|
|
|
directLogin: query.direct === '1',
|
2020-02-09 22:06:08 +03:00
|
|
|
hasPasswordless: fromStateOr('webauthn-available', false),
|
|
|
|
isHttps: window.location.protocol === 'https:',
|
|
|
|
hasPublicKeyCredential: typeof (window.PublicKeyCredential) !== 'undefined',
|
2019-11-13 15:05:10 +03:00
|
|
|
},
|
2019-09-25 19:19:42 +03:00
|
|
|
}).$mount('#login')
|