mirror of
https://github.com/Bubka/2FAuth.git
synced 2025-06-26 15:01:54 +02:00
Use Groups store in Options view to remove a request
This commit is contained in:
parent
8845027800
commit
d8861ba475
@ -8,7 +8,7 @@ export default async function auth({ to, next, stores }) {
|
|||||||
if (! user.isAuthenticated) {
|
if (! user.isAuthenticated) {
|
||||||
const currentUser = await authService.getCurrentUser()
|
const currentUser = await authService.getCurrentUser()
|
||||||
if (currentUser) {
|
if (currentUser) {
|
||||||
user.loginAs({
|
await user.loginAs({
|
||||||
name: currentUser.name,
|
name: currentUser.name,
|
||||||
email: currentUser.email,
|
email: currentUser.email,
|
||||||
preferences: currentUser.preferences,
|
preferences: currentUser.preferences,
|
||||||
|
10
resources/js_vue3/stores/user.js
vendored
10
resources/js_vue3/stores/user.js
vendored
@ -29,22 +29,22 @@ export const useUserStore = defineStore({
|
|||||||
*
|
*
|
||||||
* @param {object} user
|
* @param {object} user
|
||||||
*/
|
*/
|
||||||
loginAs(user) {
|
async loginAs(user) {
|
||||||
this.$patch(user)
|
this.$patch(user)
|
||||||
this.initDataStores()
|
await this.initDataStores()
|
||||||
this.applyUserPrefs()
|
this.applyUserPrefs()
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializes the user's data stores
|
* Initializes the user's data stores
|
||||||
*/
|
*/
|
||||||
initDataStores() {
|
async initDataStores() {
|
||||||
const accounts = useTwofaccounts()
|
const accounts = useTwofaccounts()
|
||||||
const groups = useGroups()
|
const groups = useGroups()
|
||||||
|
|
||||||
if (this.isAuthenticated) {
|
if (this.isAuthenticated) {
|
||||||
accounts.fetch()
|
await accounts.fetch()
|
||||||
groups.fetch()
|
await groups.fetch()
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
accounts.$reset()
|
accounts.$reset()
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
import userService from '@/services/userService'
|
import userService from '@/services/userService'
|
||||||
import appSettingService from '@/services/appSettingService'
|
import appSettingService from '@/services/appSettingService'
|
||||||
import { useUserStore } from '@/stores/user'
|
import { useUserStore } from '@/stores/user'
|
||||||
|
import { useGroups } from '@/stores/groups'
|
||||||
import { useAppSettingsStore } from '@/stores/appSettings'
|
import { useAppSettingsStore } from '@/stores/appSettings'
|
||||||
import { useNotifyStore } from '@/stores/notify'
|
import { useNotifyStore } from '@/stores/notify'
|
||||||
import { UseColorMode } from '@vueuse/components'
|
import { UseColorMode } from '@vueuse/components'
|
||||||
@ -11,6 +12,7 @@
|
|||||||
|
|
||||||
const $2fauth = inject('2fauth')
|
const $2fauth = inject('2fauth')
|
||||||
const user = useUserStore()
|
const user = useUserStore()
|
||||||
|
const groups = useGroups()
|
||||||
const notify = useNotifyStore()
|
const notify = useNotifyStore()
|
||||||
const appSettings = useAppSettingsStore()
|
const appSettings = useAppSettingsStore()
|
||||||
const returnTo = useStorage($2fauth.prefix + 'returnTo', 'accounts')
|
const returnTo = useStorage($2fauth.prefix + 'returnTo', 'accounts')
|
||||||
@ -40,10 +42,10 @@
|
|||||||
{ text: 'settings.forms.1_hour', value: 60 },
|
{ text: 'settings.forms.1_hour', value: 60 },
|
||||||
{ text: 'settings.forms.1_day', value: 1440 },
|
{ text: 'settings.forms.1_day', value: 1440 },
|
||||||
]
|
]
|
||||||
const groups = [
|
const groupsList = ref([
|
||||||
{ text: 'groups.no_group', value: 0 },
|
{ text: 'groups.no_group', value: 0 },
|
||||||
{ text: 'groups.active_group', value: -1 },
|
{ text: 'groups.active_group', value: -1 },
|
||||||
]
|
])
|
||||||
const captureModes = [
|
const captureModes = [
|
||||||
{ text: 'settings.forms.livescan', value: 'livescan' },
|
{ text: 'settings.forms.livescan', value: 'livescan' },
|
||||||
{ text: 'settings.forms.upload', value: 'upload' },
|
{ text: 'settings.forms.upload', value: 'upload' },
|
||||||
@ -93,15 +95,13 @@
|
|||||||
})
|
})
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
groupService.getAll().then(response => {
|
groups.items.forEach((group) => {
|
||||||
response.data.forEach((data) => {
|
if( group.id > 0 ) {
|
||||||
if( data.id >0 ) {
|
groupsList.value.push({
|
||||||
groups.push({
|
text: group.name,
|
||||||
text: data.name,
|
value: group.id
|
||||||
value: data.id
|
})
|
||||||
})
|
}
|
||||||
}
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -146,7 +146,7 @@
|
|||||||
|
|
||||||
<h4 class="title is-4 pt-4 has-text-grey-light">{{ $t('groups.groups') }}</h4>
|
<h4 class="title is-4 pt-4 has-text-grey-light">{{ $t('groups.groups') }}</h4>
|
||||||
<!-- default group -->
|
<!-- default group -->
|
||||||
<FormSelect v-model="user.preferences.defaultGroup" :options="groups" fieldName="defaultGroup" label="settings.forms.default_group.label" help="settings.forms.default_group.help" />
|
<FormSelect v-model="user.preferences.defaultGroup" :options="groupsList" fieldName="defaultGroup" label="settings.forms.default_group.label" help="settings.forms.default_group.help" />
|
||||||
<!-- retain active group -->
|
<!-- retain active group -->
|
||||||
<FormCheckbox v-model="user.preferences.rememberActiveGroup" fieldName="rememberActiveGroup" label="settings.forms.remember_active_group.label" help="settings.forms.remember_active_group.help" />
|
<FormCheckbox v-model="user.preferences.rememberActiveGroup" fieldName="rememberActiveGroup" label="settings.forms.remember_active_group.label" help="settings.forms.remember_active_group.help" />
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user