Skip to content

Commit

Permalink
add make format and run it
Browse files Browse the repository at this point in the history
  • Loading branch information
hobbitronics committed Sep 27, 2024
1 parent 1f3015e commit 189ef94
Show file tree
Hide file tree
Showing 30 changed files with 249 additions and 237 deletions.
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ dist: deps
logs:
docker-compose logs
docker-compose exec idp cat /var/log/apache2/error.log

phpmyadmin:
docker-compose up -d brokerPhpmyadmin profilePhpmyadmin

Expand All @@ -26,3 +26,6 @@ clean:
docker-compose run --rm node npm run clean
docker-compose kill
docker-compose rm -f

format:
npm run format
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
"serve": "vite --port=8000",
"serve:prod": "vite preview --port=8000",
"build": "vite build",
"clean": "rimraf dist"
"clean": "rimraf dist",
"format": "prettier --write ./src/**/*.{js,vue}"
},
"dependencies": {
"@simplewebauthn/browser": "^4.1.0",
Expand Down
15 changes: 7 additions & 8 deletions src/2sv/Change.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@
</p>

<ButtonBar>
<v-btn to="/profile" outlined>
<v-btn to="/profile" outlined>
{{ $vuetify.lang.t('$vuetify.global.button.no') }}
</v-btn>

<v-spacer></v-spacer>
<v-btn @click.once="yes(requested.id)" color="primary" outlined>

<v-btn @click.once="yes(requested.id)" color="primary" outlined>
{{ $vuetify.lang.t('$vuetify.global.button.yes') }}
</v-btn>
</ButtonBar>
Expand All @@ -32,17 +32,16 @@ import { find, remove, removeWebauthn, mfa, retrieve } from '@/global/mfa'
export default {
data: () => ({
requested: {},
isLastOne: mfa.numVerified === 1
isLastOne: mfa.numVerified === 1,
}),
computed: {
label: vm => vm.requested?.label || '2SV',
label: (vm) => vm.requested?.label || '2SV',
},
methods: {
async yes(id) {
if (mfa.keys.id === id) {
await removeWebauthn(id, mfa.keys.data[0].id)
}
else {
} else {
await remove(id)
}
Expand All @@ -54,4 +53,4 @@ export default {
this.requested = find(this.$route.params.id)
},
}
</script>
</script>
6 changes: 3 additions & 3 deletions src/2sv/Removed.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
</p>

<ButtonBar>
<v-btn to="/profile" color="warning" outlined>
<v-btn to="/profile" color="warning" outlined>
{{ $vuetify.lang.t('$vuetify.2sv.removed.button.later') }}
</v-btn>

<v-spacer></v-spacer>
<v-btn to="/2sv/intro" color="primary" outlined>

<v-btn to="/2sv/intro" color="primary" outlined>
{{ $vuetify.lang.t('$vuetify.global.button.yes') }}
</v-btn>
</ButtonBar>
Expand Down
4 changes: 2 additions & 2 deletions src/global/BasePage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<header class="display-1 d-flex align-center justify-center text-center">
<slot name="header" />
</header>

<main class="body-1 py-4">
<slot />
</main>
Expand All @@ -16,7 +16,7 @@
export default {
mounted() {
document.title = this.$vuetify.lang.t('$vuetify.app.title', this.$slots.header[0].text.trim())
}
},
}
</script>

Expand Down
10 changes: 2 additions & 8 deletions src/global/BaseTextField.vue
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
<template>
<v-text-field
ref="tf"
:value="value"
v-bind="$attrs"
outlined
v-on="$listeners" />
<v-text-field ref="tf" :value="value" v-bind="$attrs" outlined v-on="$listeners" />
</template>

<script>
Expand All @@ -19,7 +14,6 @@ export default {
if (this.$refs.tf.autofocus) {
this.$nextTick(this.$refs.tf.focus)
}
}
},
}
</script>

10 changes: 5 additions & 5 deletions src/global/Loading.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,27 @@
<script>
export default {
data: () => ({
loading: 0
loading: 0,
}),
beforeCreate() {
this.$API.interceptors.request.use(config => {
this.$API.interceptors.request.use((config) => {
this.loading++
return config
})
this.$API.interceptors.response.use(
response => {
(response) => {
this.loading--
return response
},
error => {
(error) => {
this.loading--
throw error
}
)
}
},
}
</script>
2 changes: 1 addition & 1 deletion src/global/PageNotFound.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
{{ $vuetify.lang.t('$vuetify.pageNotFound.header') }}
</template>

<img src="@/assets/riddler-geeky-world.jpg">
<img src="@/assets/riddler-geeky-world.jpg" />
</BasePage>
</template>
8 changes: 2 additions & 6 deletions src/global/filters.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
import Vue from 'vue'
import { format, parseISO } from 'date-fns'

Vue.filter('format', (date, fmt = 'iiii, LLLL do yyyy') =>
date ? format(parseISO(date), fmt) : '–'
)
Vue.filter('formatLong', (date, fmt = 'iiii, LLLL do yyyy, h:mm:ss a') =>
date ? format(date, fmt) : '–'
)
Vue.filter('format', (date, fmt = 'iiii, LLLL do yyyy') => (date ? format(parseISO(date), fmt) : '–'))
Vue.filter('formatLong', (date, fmt = 'iiii, LLLL do yyyy, h:mm:ss a') => (date ? format(date, fmt) : '–'))
38 changes: 25 additions & 13 deletions src/global/mfa.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export const mfa = {
u2f: {},
keys: {},
backup: {},
numVerified: 0
numVerified: 0,
}
export default mfa

Expand All @@ -16,14 +16,14 @@ export const newKeyName = {
},
set: function (value) {
this._value = value
}
},
}

export const add = async (type) => await Vue.prototype.$API.post('mfa', { type })

export const verify = async (id, verification = '') => {
const verifiedMfa = await Vue.prototype.$API.put(`mfa/${id}/verify`, {
value: verification
value: verification,
})

mfa[verifiedMfa.type] = Object.assign({}, verifiedMfa)
Expand All @@ -32,10 +32,22 @@ export const verify = async (id, verification = '') => {
export const retrieve = async () => {
const all = await Vue.prototype.$API.get('mfa')

mfa.totp = Object.assign({}, [...all]?.find(m => m.type === 'totp'))
mfa.u2f = Object.assign({}, [...all]?.find(m => m.type === 'u2f'))
mfa.keys = Object.assign({}, [...all]?.find(m => m.type === 'webauthn'))
mfa.backup = Object.assign({}, [...all]?.find(m => m.type === 'backupcode'))
mfa.totp = Object.assign(
{},
[...all]?.find((m) => m.type === 'totp')
)
mfa.u2f = Object.assign(
{},
[...all]?.find((m) => m.type === 'u2f')
)
mfa.keys = Object.assign(
{},
[...all]?.find((m) => m.type === 'webauthn')
)
mfa.backup = Object.assign(
{},
[...all]?.find((m) => m.type === 'backupcode')
)

mfa.numVerified = numOfVerifiedMfas(mfa) // currently, the api only returns verified mfas
}
Expand All @@ -53,21 +65,21 @@ function numOfVerifiedMfas(mfa) {
export const remove = async (id) => {
await Vue.prototype.$API.delete(`mfa/${id}`)

const type = Object.keys(mfa).find(key => mfa[key].id === id)
const type = Object.keys(mfa).find((key) => mfa[key].id === id)
mfa[type] = {}
}

export const change = async (id, updates) => {
return await Vue.prototype.$API.put(`mfa/${id}`, updates)
}

export const find = id => {
const type = Object.keys(mfa).find(key => mfa[key].id == id)
export const find = (id) => {
const type = Object.keys(mfa).find((key) => mfa[key].id == id)

return mfa[type]
}

export const verifyWebauthn = async (id, verification = '', label = '') => {
export const verifyWebauthn = async (id, verification = '', label = '') => {
const verifiedMfa = await Vue.prototype.$API.put(`mfa/${id}/verify/registration`, {
value: verification,
label: label,
Expand All @@ -77,8 +89,8 @@ export const verifyWebauthn = async (id, verification = '', label = '') => {

export const removeWebauthn = async (mfaId, webauthnId) => {
const response = await Vue.prototype.$API.delete(`mfa/${mfaId}/webauthn/${webauthnId}`)
const index = mfa.keys.data.findIndex(m => m.id === mfaId)
if(index > -1) {
const index = mfa.keys.data.findIndex((m) => m.id === mfaId)
if (index > -1) {
mfa.keys.data.splice(index, 1)
}
}
Expand Down
10 changes: 5 additions & 5 deletions src/global/recoveryMethods.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default recoveryMethods

export const add = async (email) => {
const newMethod = await Vue.prototype.$API.post('method', {
value: email
value: email,
})

recoveryMethods.alternates.push(newMethod)
Expand All @@ -19,8 +19,8 @@ export const retrieve = async () => {

const all = await Vue.prototype.$API.get('method')

recoveryMethods.system.push([...all]?.filter(m => m.type != 'email'))
recoveryMethods.alternates.push([...all]?.filter(m => m.type == 'email'))
recoveryMethods.system.push([...all]?.filter((m) => m.type != 'email'))
recoveryMethods.alternates.push([...all]?.filter((m) => m.type == 'email'))
}

function clear() {
Expand All @@ -31,12 +31,12 @@ function clear() {
export const remove = async (id) => {
await Vue.prototype.$API.delete(`method/${id}`)

const i = recoveryMethods.alternates.findIndex(m => m.id == id)
const i = recoveryMethods.alternates.findIndex((m) => m.id == id)
recoveryMethods.alternates.splice(i, 1)
}

export const verify = async (id, verificationCode = '') => {
await Vue.prototype.$API.put(`method/${id}/verify`, {
code: verificationCode
code: verificationCode,
})
}
4 changes: 2 additions & 2 deletions src/global/token.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function get(key) {
// TODO: currently no IE support for URLSearchParams (https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams#Browser_compatibility)
// check this out for further info: https://developers.google.com/web/updates/2016/01/urlsearchparams
// polyfill if needed (https://github.com/jerrybendy/url-search-params-polyfill) or the WebReflection one...
const defragged = new URL(location.href.replace('#',''))
const defragged = new URL(location.href.replace('#', ''))
const params = new URLSearchParams(defragged.search)

return sessionStorage.getItem(key) || params.get(key)
Expand All @@ -42,4 +42,4 @@ function reset() {

function apiToken() {
return get('key') + get('access_token')
}
}
36 changes: 21 additions & 15 deletions src/help/HelpButton.vue
Original file line number Diff line number Diff line change
@@ -1,27 +1,31 @@
<template>
<v-dialog v-if="$root.idpConfig.support" v-model="isOpen" width="initial"> <!-- making it initial so card grows with content -->
<v-dialog v-if="$root.idpConfig.support" v-model="isOpen" width="initial">
<!-- making it initial so card grows with content -->
<template v-slot:activator="{ on }">
<v-btn v-on="on" text dark :icon="mobile" class="mx-1">{{ !mobile ? $vuetify.lang.t('$vuetify.help.button.help') : '' }}<v-icon v-if="mobile">mdi-help</v-icon></v-btn>

<v-btn v-on="on" text dark :icon="mobile" class="mx-1"
>{{ !mobile ? $vuetify.lang.t('$vuetify.help.button.help') : '' }}<v-icon v-if="mobile">mdi-help</v-icon></v-btn
>
</template>
<v-card>
<v-card-title class="headline primary white--text">{{ $vuetify.lang.t('$vuetify.help.title') }}</v-card-title>

<v-card-text>
<p v-if="$root.idpConfig.support.phone">
{{ $vuetify.lang.t('$vuetify.help.phone') }}<span class="subtitle-1"> {{ $root.idpConfig.support.phone }}</span>
{{ $vuetify.lang.t('$vuetify.help.phone')
}}<span class="subtitle-1"> {{ $root.idpConfig.support.phone }}</span>
</p>
<p v-if="$root.idpConfig.support.email">
{{ $vuetify.lang.t('$vuetify.help.email') }}<span class="subtitle-1"> {{ $root.idpConfig.support.email }}</span>
{{ $vuetify.lang.t('$vuetify.help.email')
}}<span class="subtitle-1"> {{ $root.idpConfig.support.email }}</span>
</p>
<p v-if="$root.idpConfig.support.url">
{{ $vuetify.lang.t('$vuetify.help.site') }}
{{ $vuetify.lang.t('$vuetify.help.site') }}
<a :href="$root.idpConfig.support.url" target="_blank" class="subtitle-1">
{{ $root.idpConfig.support.url }}
</a>
</p>
<p v-if="$root.idpConfig.support.feedbackUrl">
{{ $vuetify.lang.t('$vuetify.help.feedback') }}
{{ $vuetify.lang.t('$vuetify.help.feedback') }}
<a :href="$root.idpConfig.support.feedbackUrl" target="_blank" class="subtitle-1">
{{ $root.idpConfig.support.feedbackUrl }}
</a>
Expand All @@ -34,7 +38,7 @@
<v-spacer></v-spacer>
<v-btn color="primary" text @click="isOpen = false">{{ $vuetify.lang.t('$vuetify.help.button.ok') }}</v-btn>
</v-card-actions>
</v-card>
</v-card>
</v-dialog>
</template>

Expand All @@ -44,12 +48,14 @@ export default {
isOpen: false,
}),
computed: {
mobile () {
switch (this.$vuetify.breakpoint.name) {
case 'xs': return true
default: return false
}
},
mobile() {
switch (this.$vuetify.breakpoint.name) {
case 'xs':
return true
default:
return false
}
},
},
}
</script>
Loading

0 comments on commit 189ef94

Please sign in to comment.