Skip to content

Commit

Permalink
refactor: restructure code to satisfy linting rules
Browse files Browse the repository at this point in the history
Signed-off-by: ernolf <raphael.gradenwitz@googlemail.com>
  • Loading branch information
ernolf committed Aug 26, 2024
1 parent 1f71384 commit af65887
Show file tree
Hide file tree
Showing 12 changed files with 32 additions and 49 deletions.
7 changes: 4 additions & 3 deletions src/components/LoginSetup.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
- @author 2019 Christoph Wurst <christoph@winzerhof-wurst.at>
- @author 2024 [ernolf] Raphael Gradenwitz <raphael.gradenwitz@googlemail.com>
-
- @license GNU AGPL version 3 or any later version
- @license AGPL-3.0-or-later
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU Affero General Public License as
Expand All @@ -24,7 +24,7 @@
<div id="twofactor-totp-login-setup">
<div v-if="loading" class="loading" />
<SetupConfirmation v-if="secret"
:isCentered="true"
:center="true"
:loading="loadingConfirmation"
:secret="secret"
:qr-url="qrUrl"
Expand All @@ -36,9 +36,10 @@
</template>

<script>
import Vue from 'vue'
import Vuex from 'vuex'
import store from '../store.js' // Store importieren
import store from '../store.js' // import store
import Logger from '../logger.js'
import SetupConfirmation from './SetupConfirmation.vue'
Expand Down
3 changes: 2 additions & 1 deletion src/components/PersonalTotpSettings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
- @author 2018 Christoph Wurst <christoph@winzerhof-wurst.at>
- @author 2024 [ernolf] Raphael Gradenwitz <raphael.gradenwitz@googlemail.com>
-
- @license GNU AGPL version 3 or any later version
- @license AGPL-3.0-or-later
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU Affero General Public License as
Expand Down Expand Up @@ -46,6 +46,7 @@
</button>

<SetupConfirmation v-if="secret"
:center="false"
:secret="secret"
:qr-url="qrUrl"
:loading="loadingConfirmation"
Expand Down
36 changes: 18 additions & 18 deletions src/components/SetupConfirmation.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
- @author 2019 Christoph Wurst <christoph@winzerhof-wurst.at>
- @author 2024 [ernolf] Raphael Gradenwitz <raphael.gradenwitz@googlemail.com>
-
- @license GNU AGPL version 3 or any later version
- @license AGPL-3.0-or-later
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU Affero General Public License as
Expand All @@ -21,20 +21,20 @@
-->

<template>
<div :class="['setup-confirmation', { centered: isCentered }]">
<div :class="['setup-confirmation', { centered: center }]">
<p class="setup-confirmation__secret">
{{ t('twofactor_totp', 'Your new TOTP secret is:') }} {{ localSecret }}
</p>

<!-- Advanced Settings Button -->
<div :class="['advanced-settings-container', { centered: isCentered }]">
<div :class="['advanced-settings-container', { centered: center }]">
<button class="advanced-settings-btn" @click="toggleAdvancedSettings">
{{ showAdvanced ? t('twofactor_totp', 'Hide advanced settings') : t('twofactor_totp', 'Advanced settings') }}
</button>
</div>

<!-- Advanced Settings Section -->
<div v-if="showAdvanced" :class="['advanced-settings', { centered: isCentered }]">
<div v-if="showAdvanced" :class="['advanced-settings', { centered: center }]">
<p class="warning-message">
{{ t('twofactor_totp', 'Warning: Not all TOTP devices or smartphone apps support the full range of these advanced settings.') }}
</p>
Expand All @@ -43,8 +43,8 @@
</p>

<!-- Custom Secret Input -->
<div :class="['form-group', { centered: isCentered }]">
<label :class="{ centered: isCentered }"
<div :class="['form-group', { centered: center }]">
<label :class="{ centered: center }"
for="custom-secret"
@mouseleave="onMouseLeave">
{{ t('twofactor_totp', 'Secret') }}
Expand All @@ -63,8 +63,8 @@
<!-- Settings Row (Algorithm, Digits, Period) -->
<div class="form-row">
<!-- Algorithm Select -->
<div :class="['form-group', { centered: isCentered }]">
<label :class="{ centered: isCentered }"
<div :class="['form-group', { centered: center }]">
<label :class="{ centered: center }"
for="algorithm"
@mouseleave="onMouseLeave">
{{ t('twofactor_totp', 'Algorithm') }}
Expand All @@ -86,8 +86,8 @@
</div>

<!-- Digits Select -->
<div :class="['form-group', { centered: isCentered }]">
<label :class="{ centered: isCentered }"
<div :class="['form-group', { centered: center }]">
<label :class="{ centered: center }"
for="digits"
:title="t('twofactor_totp', 'OTP token length')"
@mouseleave="onMouseLeave">
Expand All @@ -105,8 +105,8 @@
</div>

<!-- Period Select -->
<div :class="['form-group', { centered: isCentered }]">
<label :class="{ centered: isCentered }"
<div :class="['form-group', { centered: center }]">
<label :class="{ centered: center }"
for="period"
:title="t('twofactor_totp', 'OTP validity in seconds')"
@mouseleave="onMouseLeave">
Expand All @@ -133,7 +133,7 @@
<p>{{ t('twofactor_totp', 'For quick setup, scan this QR code with your TOTP app:') }}</p>
<QR :value="qrUrl" :options="{ width: 150 }" />
<p>{{ t('twofactor_totp', 'After you configured your app, enter a test code below to ensure everything works correctly:') }}</p>
<div id="['totp-confirmation-container', { centered: isCentered }]">
<div id="['totp-confirmation-container', { centered: center }]">
<input id="totp-confirmation"
ref="confirmationInput"
v-model="confirmationCode"
Expand Down Expand Up @@ -164,7 +164,7 @@ export default {
QR,
},
props: {
isCentered: {
center: {
type: Boolean,
default: false,
},
Expand Down Expand Up @@ -324,7 +324,7 @@ export default {
const base32Regex = /^[A-Z2-7]*$/
const minLength = 26
const maxLength = 128
let warningMessages = []
const warningMessages = []
if (this.customSecret.length < minLength) {
warningMessages.push(this.t('twofactor_totp', 'The secret must have at least 26 characters.'))
}
Expand All @@ -336,9 +336,9 @@ export default {
}
// Set the warning message based on the validation
if (warningMessages.length > 0) {
this.customSecretWarning = warningMessages.join(' ');
this.customSecretWarning = warningMessages.join(' ')
} else {
this.customSecretWarning = false;
this.customSecretWarning = false
}
// Check if the settings have changed
this.checkIfSettingsChanged()
Expand All @@ -364,7 +364,7 @@ export default {

<style lang="scss" scoped>
.setup-confirmation {
/* Centered only if isCentered is true */
/* Centered only if center is true */
&.centered {
display: flex;
flex-direction: column;
Expand Down
2 changes: 1 addition & 1 deletion src/logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*
* @author 2019 Christoph Wurst <christoph@winzerhof-wurst.at>
*
* @license GNU AGPL version 3 or any later version
* @license AGPL-3.0-or-later
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
Expand Down
2 changes: 1 addition & 1 deletion src/main-login-setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*
* @author 2019 Christoph Wurst <christoph@winzerhof-wurst.at>
*
* @license GNU AGPL version 3 or any later version
* @license AGPL-3.0-or-later
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
Expand Down
2 changes: 1 addition & 1 deletion src/main-settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*
* @author 2018 Christoph Wurst <christoph@winzerhof-wurst.at>
*
* @license GNU AGPL version 3 or any later version
* @license AGPL-3.0-or-later
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
Expand Down
2 changes: 1 addition & 1 deletion src/services/StateService.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* @author 2019 Christoph Wurst <christoph@winzerhof-wurst.at>
* @author 2024 [ernolf] Raphael Gradenwitz <raphael.gradenwitz@googlemail.com>
*
* @license GNU AGPL version 3 or any later version
* @license AGPL-3.0-or-later
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
Expand Down
2 changes: 1 addition & 1 deletion src/state.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*
* @author 2018 Christoph Wurst <christoph@winzerhof-wurst.at>
*
* @license GNU AGPL version 3 or any later version
* @license AGPL-3.0-or-later
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
Expand Down
19 changes: 0 additions & 19 deletions src/store.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,3 @@
/**
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
* @copyright Copyright (c) Christoph Wurst <christoph@winzerhof-wurst.at>
* @author 2024 [ernolf] Raphael Gradenwitz <raphael.gradenwitz@googlemail.com>
*
* This code is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* 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, version 3,
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/

import Vue from 'vue'
import Vuex from 'vuex'

Expand Down
2 changes: 1 addition & 1 deletion src/tests/components/PersonalTotpSettings.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*
* @author 2018 Christoph Wurst <christoph@winzerhof-wurst.at>
*
* @license GNU AGPL version 3 or any later version
* @license AGPL-3.0-or-later
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
Expand Down
2 changes: 1 addition & 1 deletion src/tests/components/SetupConfirmation.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*
* @author 2024 [ernolf] Raphael Gradenwitz <raphael.gradenwitz@googlemail.com>
*
* @license GNU AGPL version 3 or any later version
* @license AGPL-3.0-or-later
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
Expand Down
2 changes: 1 addition & 1 deletion src/tests/jest.setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*
* @author 2018 Christoph Wurst <christoph@winzerhof-wurst.at>
*
* @license GNU AGPL version 3 or any later version
* @license AGPL-3.0-or-later
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
Expand Down

0 comments on commit af65887

Please sign in to comment.