mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
Merge branch 'master' into test-send-email
This commit is contained in:
commit
1c86b704d3
2
.github/workflows/test.yml
vendored
2
.github/workflows/test.yml
vendored
@ -470,7 +470,7 @@ jobs:
|
||||
report_name: Coverage Admin Interface
|
||||
type: lcov
|
||||
result_path: ./coverage/lcov.info
|
||||
min_coverage: 76
|
||||
min_coverage: 77
|
||||
token: ${{ github.token }}
|
||||
|
||||
##############################################################################
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
GRAPHQL_URI=http://localhost:4000/graphql
|
||||
WALLET_AUTH_URL=http://localhost/vue/authenticate?token=$1
|
||||
WALLET_URL=http://localhost/vue/login
|
||||
DEBUG_DISABLE_AUTH=false
|
||||
@ -19,6 +19,7 @@ const mocks = {
|
||||
}
|
||||
|
||||
const propsData = {
|
||||
checked: false,
|
||||
email: 'bob@baumeister.de',
|
||||
dateLastSend: '',
|
||||
}
|
||||
|
||||
@ -1,19 +1,20 @@
|
||||
<template>
|
||||
<div class="component-confirm-register-mail">
|
||||
<div class="shadow p-3 mb-5 bg-white rounded">
|
||||
<div class="h5">
|
||||
{{ $t('unregister_mail.text', { date: dateLastSend, mail: email }) }}
|
||||
</div>
|
||||
<div v-if="checked">{{ $t('unregister_mail.text_true', { date: dateLastSend }) }}</div>
|
||||
<div v-else>
|
||||
{{ $t('unregister_mail.text_false', { date: dateLastSend, mail: email }) }}
|
||||
|
||||
<!-- Using components -->
|
||||
<b-input-group :prepend="$t('unregister_mail.info')" class="mt-3">
|
||||
<b-form-input readonly :value="email"></b-form-input>
|
||||
<b-input-group-append>
|
||||
<b-button variant="outline-success" class="test-button" @click="sendRegisterMail">
|
||||
{{ $t('unregister_mail.button') }}
|
||||
</b-button>
|
||||
</b-input-group-append>
|
||||
</b-input-group>
|
||||
<!-- Using components -->
|
||||
<b-input-group :prepend="$t('unregister_mail.info')" class="mt-3">
|
||||
<b-form-input readonly :value="email"></b-form-input>
|
||||
<b-input-group-append>
|
||||
<b-button variant="outline-success" class="test-button" @click="sendRegisterMail">
|
||||
{{ $t('unregister_mail.button') }}
|
||||
</b-button>
|
||||
</b-input-group-append>
|
||||
</b-input-group>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@ -23,6 +24,9 @@ import { sendActivationEmail } from '../graphql/sendActivationEmail'
|
||||
export default {
|
||||
name: 'ConfirmRegisterMail',
|
||||
props: {
|
||||
checked: {
|
||||
type: Boolean,
|
||||
},
|
||||
email: {
|
||||
type: String,
|
||||
},
|
||||
|
||||
@ -8,7 +8,7 @@ const apolloQueryMock = jest.fn().mockResolvedValue({
|
||||
transactionList: {
|
||||
transactions: [
|
||||
{
|
||||
type: 'created',
|
||||
type: 'creation',
|
||||
balance: 100,
|
||||
decayStart: 0,
|
||||
decayEnd: 0,
|
||||
@ -27,7 +27,7 @@ const apolloQueryMock = jest.fn().mockResolvedValue({
|
||||
},
|
||||
},
|
||||
{
|
||||
type: 'created',
|
||||
type: 'creation',
|
||||
balance: 200,
|
||||
decayStart: 0,
|
||||
decayEnd: 0,
|
||||
@ -58,9 +58,7 @@ const mocks = {
|
||||
query: apolloQueryMock,
|
||||
},
|
||||
$toasted: {
|
||||
global: {
|
||||
error: toastedErrorMock,
|
||||
},
|
||||
error: toastedErrorMock,
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
@ -30,10 +30,10 @@ export default {
|
||||
},
|
||||
})
|
||||
.then((result) => {
|
||||
this.items = result.data.transactionList.transactions
|
||||
this.items = result.data.transactionList.transactions.filter((t) => t.type === 'creation')
|
||||
})
|
||||
.catch((error) => {
|
||||
this.$toasted.global.error(error.message)
|
||||
this.$toasted.error(error.message)
|
||||
})
|
||||
},
|
||||
},
|
||||
|
||||
@ -53,13 +53,17 @@ describe('NavBar', () => {
|
||||
})
|
||||
|
||||
describe('logout', () => {
|
||||
// const assignLocationSpy = jest.fn()
|
||||
const windowLocationMock = jest.fn()
|
||||
beforeEach(async () => {
|
||||
delete window.location
|
||||
window.location = {
|
||||
assign: windowLocationMock,
|
||||
}
|
||||
await wrapper.findAll('a').at(6).trigger('click')
|
||||
})
|
||||
|
||||
it('redirects to /logout', () => {
|
||||
expect(routerPushMock).toBeCalledWith('/logout')
|
||||
expect(windowLocationMock).toBeCalledWith('http://localhost/vue/login')
|
||||
})
|
||||
|
||||
it('dispatches logout to store', () => {
|
||||
|
||||
@ -33,8 +33,9 @@ export default {
|
||||
name: 'navbar',
|
||||
methods: {
|
||||
logout() {
|
||||
window.location.assign(CONFIG.WALLET_URL)
|
||||
// window.location = CONFIG.WALLET_URL
|
||||
this.$store.dispatch('logout')
|
||||
this.$router.push('/logout')
|
||||
},
|
||||
wallet() {
|
||||
window.location = CONFIG.WALLET_AUTH_URL.replace('$1', this.$store.state.token)
|
||||
|
||||
@ -3,31 +3,287 @@ import UserTable from './UserTable.vue'
|
||||
|
||||
const localVue = global.localVue
|
||||
|
||||
const apolloQueryMock = jest.fn()
|
||||
apolloQueryMock.mockResolvedValue()
|
||||
|
||||
describe('UserTable', () => {
|
||||
let wrapper
|
||||
|
||||
const propsData = {
|
||||
type: 'Type',
|
||||
itemsUser: [],
|
||||
fieldsTable: [],
|
||||
creation: [],
|
||||
const defaultItemsUser = [
|
||||
{
|
||||
email: 'bibi@bloxberg.de',
|
||||
firstName: 'Bibi',
|
||||
lastName: 'Bloxberg',
|
||||
creation: [1000, 1000, 1000],
|
||||
},
|
||||
{
|
||||
email: 'bibi@bloxberg.de',
|
||||
firstName: 'Bibi',
|
||||
lastName: 'Bloxberg',
|
||||
creation: [1000, 1000, 1000],
|
||||
},
|
||||
{
|
||||
email: 'bibi@bloxberg.de',
|
||||
firstName: 'Bibi',
|
||||
lastName: 'Bloxberg',
|
||||
creation: [1000, 1000, 1000],
|
||||
},
|
||||
]
|
||||
|
||||
const confirmationItemsUser = [
|
||||
{
|
||||
email: 'bibi@bloxberg.de',
|
||||
firstName: 'Bibi',
|
||||
lastName: 'Bloxberg',
|
||||
amount: 10,
|
||||
memo: 'Test 1',
|
||||
date: '11-09-2001',
|
||||
moderator: 1,
|
||||
},
|
||||
{
|
||||
email: 'bibi@bloxberg.de',
|
||||
firstName: 'Bibi',
|
||||
lastName: 'Bloxberg',
|
||||
amount: 10,
|
||||
memo: 'Test 2',
|
||||
date: '21-09-2001',
|
||||
moderator: 1,
|
||||
},
|
||||
{
|
||||
email: 'bibi@bloxberg.de',
|
||||
firstName: 'Bibi',
|
||||
lastName: 'Bloxberg',
|
||||
amount: 10,
|
||||
memo: 'Test 3',
|
||||
date: '30-09-2001',
|
||||
moderator: 1,
|
||||
},
|
||||
]
|
||||
|
||||
const propsDataPageUserSearch = {
|
||||
type: 'PageUserSearch',
|
||||
itemsUser: defaultItemsUser,
|
||||
fieldsTable: [
|
||||
'email',
|
||||
'firstName',
|
||||
'lastName',
|
||||
'creation',
|
||||
'show_details',
|
||||
'confirm_mail',
|
||||
'transactions_list',
|
||||
],
|
||||
}
|
||||
|
||||
const propsDataUserListSearch = {
|
||||
type: 'UserListSearch',
|
||||
itemsUser: defaultItemsUser,
|
||||
fieldsTable: ['bookmark', 'email', 'firstName', 'lastName', 'creation'],
|
||||
creation: [1000, 1000, 1000],
|
||||
}
|
||||
|
||||
const propsDataUserListMassCreation = {
|
||||
type: 'UserListMassCreation',
|
||||
itemsUser: defaultItemsUser,
|
||||
fieldsTable: ['email', 'firstName', 'lastName', 'creation', 'bookmark'],
|
||||
creation: [1000, 1000, 1000],
|
||||
}
|
||||
|
||||
const propsDataPageCreationConfirm = {
|
||||
type: 'PageCreationConfirm',
|
||||
itemsUser: confirmationItemsUser,
|
||||
fieldsTable: [
|
||||
'bookmark',
|
||||
'email',
|
||||
'firstName',
|
||||
'lastName',
|
||||
'amount',
|
||||
'memo',
|
||||
'date',
|
||||
'moderator',
|
||||
'edit_creation',
|
||||
'confirm',
|
||||
],
|
||||
}
|
||||
|
||||
const mocks = {
|
||||
$t: jest.fn((t) => t),
|
||||
$moment: jest.fn(() => {
|
||||
return {
|
||||
format: jest.fn((m) => m),
|
||||
subtract: jest.fn(() => {
|
||||
return {
|
||||
format: jest.fn((m) => m),
|
||||
}
|
||||
}),
|
||||
}
|
||||
}),
|
||||
$apollo: {
|
||||
query: apolloQueryMock,
|
||||
},
|
||||
$store: {
|
||||
commit: jest.fn(),
|
||||
},
|
||||
}
|
||||
|
||||
const Wrapper = () => {
|
||||
const Wrapper = (propsData) => {
|
||||
return mount(UserTable, { localVue, propsData, mocks })
|
||||
}
|
||||
|
||||
describe('mount', () => {
|
||||
beforeEach(() => {
|
||||
wrapper = Wrapper()
|
||||
describe('type PageUserSearch', () => {
|
||||
beforeEach(() => {
|
||||
wrapper = Wrapper(propsDataPageUserSearch)
|
||||
})
|
||||
|
||||
it('has a DIV element with the class.component-user-table', () => {
|
||||
expect(wrapper.find('.component-user-table').exists()).toBeTruthy()
|
||||
})
|
||||
|
||||
it('has a DIV element with the id overlay that is not displayed', () => {
|
||||
expect(wrapper.find('#overlay').exists()).toBeTruthy()
|
||||
expect(wrapper.find('#overlay').attributes('style')).toBe('display: none;')
|
||||
})
|
||||
|
||||
describe('table', () => {
|
||||
it('has a table', () => {
|
||||
expect(wrapper.find('table').exists()).toBeTruthy()
|
||||
})
|
||||
|
||||
describe('header definition', () => {
|
||||
it('has 4 column', () => {
|
||||
expect(wrapper.findAll('th').length).toBe(7)
|
||||
})
|
||||
|
||||
it('has Email as first column', () => {
|
||||
expect(wrapper.find('th[aria-colindex="1"] div').text()).toBe('Email')
|
||||
})
|
||||
|
||||
it('has First Name as second column', () => {
|
||||
expect(wrapper.find('th[aria-colindex="2"] div').text()).toBe('First Name')
|
||||
})
|
||||
|
||||
it('has Last Name as third column', () => {
|
||||
expect(wrapper.find('th[aria-colindex="3"] div').text()).toBe('Last Name')
|
||||
})
|
||||
|
||||
it('has Creation as fourth column', () => {
|
||||
expect(wrapper.find('th[aria-colindex="4"] div').text()).toBe('Creation')
|
||||
})
|
||||
|
||||
it('has Creation as fifth column', () => {
|
||||
expect(wrapper.find('th[aria-colindex="5"] div').text()).toBe('Show Details')
|
||||
})
|
||||
|
||||
it('has Creation as sixth column', () => {
|
||||
expect(wrapper.find('th[aria-colindex="6"] div').text()).toBe('Confirm Mail')
|
||||
})
|
||||
|
||||
it('has Creation as seventh column', () => {
|
||||
expect(wrapper.find('th[aria-colindex="7"] div').text()).toBe('Transactions List')
|
||||
})
|
||||
})
|
||||
|
||||
describe('content', () => {
|
||||
it('has 3 rows', () => {
|
||||
expect(wrapper.findAll('tbody tr').length).toBe(3)
|
||||
})
|
||||
|
||||
it('has 7 columns', () => {
|
||||
expect(wrapper.findAll('tr:nth-child(1) > td').length).toBe(7)
|
||||
})
|
||||
|
||||
it('click button on fifth column', () => {
|
||||
wrapper.find('tbody tr td[aria-colindex="5"] button').trigger('click')
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
// it('expect(wrapper.html()).', () => {
|
||||
// // eslint-disable-next-line no-console
|
||||
// console.log(wrapper.html())
|
||||
// })
|
||||
})
|
||||
|
||||
it('has a DIV element with the class.component-user-table', () => {
|
||||
expect(wrapper.find('.component-user-table').exists()).toBeTruthy()
|
||||
describe('type UserListSearch', () => {
|
||||
beforeEach(() => {
|
||||
wrapper = Wrapper(propsDataUserListSearch)
|
||||
})
|
||||
|
||||
it('has a DIV element with the class.component-user-table', () => {
|
||||
expect(wrapper.find('.component-user-table').exists()).toBeTruthy()
|
||||
})
|
||||
|
||||
// it('expect(wrapper.html()).', () => {
|
||||
// // eslint-disable-next-line no-console
|
||||
// console.log(wrapper.html())
|
||||
// })
|
||||
})
|
||||
|
||||
describe('type UserListMassCreation', () => {
|
||||
beforeEach(() => {
|
||||
wrapper = Wrapper(propsDataUserListMassCreation)
|
||||
})
|
||||
|
||||
it('has a DIV element with the class.component-user-table', () => {
|
||||
expect(wrapper.find('.component-user-table').exists()).toBeTruthy()
|
||||
})
|
||||
|
||||
// it('expect(wrapper.html()).', () => {
|
||||
// // eslint-disable-next-line no-console
|
||||
// console.log(wrapper.html())
|
||||
// })
|
||||
})
|
||||
|
||||
describe('type PageCreationConfirm', () => {
|
||||
beforeEach(() => {
|
||||
wrapper = Wrapper(propsDataPageCreationConfirm)
|
||||
})
|
||||
|
||||
it('has a DIV element with the class.component-user-table', () => {
|
||||
expect(wrapper.find('.component-user-table').exists()).toBeTruthy()
|
||||
})
|
||||
|
||||
// it('expect(wrapper.html()).', () => {
|
||||
// // eslint-disable-next-line no-console
|
||||
// console.log(wrapper.html())
|
||||
// })
|
||||
})
|
||||
/**
|
||||
<user-table
|
||||
v-if="itemsList.length > 0"
|
||||
type="UserListSearch"
|
||||
:itemsUser="itemsList"
|
||||
:fieldsTable="Searchfields"
|
||||
:criteria="criteria"
|
||||
:creation="creation"
|
||||
@update-item="updateItem"
|
||||
/>
|
||||
|
||||
<user-table
|
||||
v-show="itemsMassCreation.length > 0"
|
||||
class="shadow p-3 mb-5 bg-white rounded"
|
||||
type="UserListMassCreation"
|
||||
:itemsUser="itemsMassCreation"
|
||||
:fieldsTable="fields"
|
||||
:criteria="null"
|
||||
:creation="creation"
|
||||
@update-item="updateItem"
|
||||
/>
|
||||
|
||||
<user-table
|
||||
class="mt-4"
|
||||
type="PageCreationConfirm"
|
||||
:itemsUser="confirmResult"
|
||||
:fieldsTable="fields"
|
||||
@remove-confirm-result="removeConfirmResult"
|
||||
/>
|
||||
|
||||
<user-table
|
||||
type="PageUserSearch"
|
||||
:itemsUser="searchResult"
|
||||
:fieldsTable="fields"
|
||||
:criteria="criteria"
|
||||
/>
|
||||
*/
|
||||
})
|
||||
})
|
||||
|
||||
@ -74,6 +74,7 @@
|
||||
|
||||
<template #row-details="row">
|
||||
<row-details
|
||||
v-if="type !== 'UserListSearch' && type !== 'UserListMassCreation'"
|
||||
:row="row"
|
||||
:type="type"
|
||||
:slotName="slotName"
|
||||
@ -107,6 +108,7 @@
|
||||
</template>
|
||||
<template #show-register-mail>
|
||||
<confirm-register-mail-formular
|
||||
:checked="row.item.emailChecked"
|
||||
:email="row.item.email"
|
||||
:dateLastSend="$moment().subtract(1, 'month').format('dddd, DD.MMMM.YYYY HH:mm'),"
|
||||
/>
|
||||
@ -232,6 +234,9 @@ export default {
|
||||
row.toggleDetails()
|
||||
this.slotIndex = index
|
||||
this.openRow = row
|
||||
if (this.type === 'PageCreationConfirm') {
|
||||
this.creationUserData = row.item
|
||||
}
|
||||
}
|
||||
} else {
|
||||
row.toggleDetails()
|
||||
|
||||
@ -20,6 +20,7 @@ const environment = {
|
||||
const endpoints = {
|
||||
GRAPHQL_URI: process.env.GRAPHQL_URI || 'http://localhost:4000/graphql',
|
||||
WALLET_AUTH_URL: process.env.WALLET_AUTH_URL || 'http://localhost/vue/authenticate?token=$1',
|
||||
WALLET_URL: process.env.WALLET_URL || 'http://localhost/vue/login',
|
||||
}
|
||||
|
||||
const debug = {
|
||||
|
||||
@ -7,6 +7,7 @@ export const verifyLogin = gql`
|
||||
lastName
|
||||
isAdmin
|
||||
id
|
||||
language
|
||||
}
|
||||
}
|
||||
`
|
||||
|
||||
@ -59,7 +59,8 @@
|
||||
"error": "Fehler beim Senden des Bestätigungs-Links an den Benutzer: {message}",
|
||||
"info": "Email bestätigen, wiederholt senden an:",
|
||||
"success": "Erfolgreiches Senden des Bestätigungs-Links an die E-Mail des Nutzers! ({email})",
|
||||
"text": " Die letzte Email wurde am <b>{date} Uhr</b> an das Mitglied ({mail}) gesendet."
|
||||
"text_false": " Die letzte Email wurde am {date} Uhr an das Mitglied ({mail}) gesendet.",
|
||||
"text_true": " Die Email wurde am {date} Uhr bestätigt."
|
||||
},
|
||||
"user_search": "Nutzer-Suche"
|
||||
}
|
||||
|
||||
@ -59,7 +59,8 @@
|
||||
"error": "Error sending the confirmation link to the user: {message}",
|
||||
"info": "Confirm email, send repeatedly to:",
|
||||
"success": "Successfully send the confirmation link to the user's email! ({email})",
|
||||
"text": " The last email was sent to the member ({mail}) on <b>{date} clock</b>."
|
||||
"text_false": "The last email was sent to the member ({mail}) on {date} clock.",
|
||||
"text_true": "The email was confirmed on {date} clock."
|
||||
},
|
||||
"user_search": "User search"
|
||||
}
|
||||
|
||||
@ -42,7 +42,7 @@ Vue.use(Toasted, {
|
||||
},
|
||||
})
|
||||
|
||||
addNavigationGuards(router, store, apolloProvider.defaultClient)
|
||||
addNavigationGuards(router, store, apolloProvider.defaultClient, i18n)
|
||||
|
||||
new Vue({
|
||||
moment,
|
||||
|
||||
@ -35,6 +35,16 @@ const mocks = {
|
||||
$toasted: {
|
||||
error: toastErrorMock,
|
||||
},
|
||||
$moment: jest.fn(() => {
|
||||
return {
|
||||
format: jest.fn((m) => m),
|
||||
subtract: jest.fn(() => {
|
||||
return {
|
||||
format: jest.fn((m) => m),
|
||||
}
|
||||
}),
|
||||
}
|
||||
}),
|
||||
}
|
||||
|
||||
describe('Creation', () => {
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<div class="creation">
|
||||
<b-row>
|
||||
<b-col cols="12" lg="5">
|
||||
<b-col cols="12" lg="6">
|
||||
<label>Usersuche</label>
|
||||
<b-input
|
||||
type="text"
|
||||
@ -19,7 +19,7 @@
|
||||
@update-item="updateItem"
|
||||
/>
|
||||
</b-col>
|
||||
<b-col cols="12" lg="7" class="shadow p-3 mb-5 rounded bg-info">
|
||||
<b-col cols="12" lg="6" class="shadow p-3 mb-5 rounded bg-info">
|
||||
<user-table
|
||||
v-show="itemsMassCreation.length > 0"
|
||||
class="shadow p-3 mb-5 bg-white rounded"
|
||||
@ -62,14 +62,38 @@ export default {
|
||||
{ key: 'bookmark', label: 'bookmark' },
|
||||
{ key: 'firstName', label: this.$t('firstname') },
|
||||
{ key: 'lastName', label: this.$t('lastname') },
|
||||
{ key: 'creation', label: this.$t('open_creations') },
|
||||
{
|
||||
key: 'creation',
|
||||
// label: this.$t('open_creation') + 'Jan | Feb | März',
|
||||
label:
|
||||
this.$moment().subtract(2, 'month').format('MMM') +
|
||||
' | ' +
|
||||
this.$moment().subtract(1, 'month').format('MMM') +
|
||||
' | ' +
|
||||
this.$moment().format('MMM'),
|
||||
formatter: (value, key, item) => {
|
||||
return String(value[0]) + ` | ` + String(value[1]) + ` | ` + String(value[2])
|
||||
},
|
||||
},
|
||||
{ key: 'email', label: this.$t('e_mail') },
|
||||
],
|
||||
fields: [
|
||||
{ key: 'email', label: this.$t('e_mail') },
|
||||
{ key: 'firstName', label: this.$t('firstname') },
|
||||
{ key: 'lastName', label: this.$t('lastname') },
|
||||
{ key: 'creation', label: this.$t('open_creations') },
|
||||
{
|
||||
key: 'creation',
|
||||
// label: this.$t('open_creation') + 'Jan | Feb | März',
|
||||
label:
|
||||
this.$moment().subtract(2, 'month').format('MMM') +
|
||||
' | ' +
|
||||
this.$moment().subtract(1, 'month').format('MMM') +
|
||||
' | ' +
|
||||
this.$moment().format('MMM'),
|
||||
formatter: (value, key, item) => {
|
||||
return String(value[0]) + ` | ` + String(value[1]) + ` | ` + String(value[2])
|
||||
},
|
||||
},
|
||||
{ key: 'bookmark', label: this.$t('remove') },
|
||||
],
|
||||
itemsList: [],
|
||||
|
||||
@ -61,7 +61,7 @@ describe('UserSearch', () => {
|
||||
})
|
||||
|
||||
it('filters the users by unconfirmed emails', () => {
|
||||
expect(wrapper.vm.searchResult).toHaveLength(0)
|
||||
expect(wrapper.vm.searchResult).toHaveLength(1)
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
@ -42,27 +42,13 @@ export default {
|
||||
{ key: 'lastName', label: this.$t('lastname') },
|
||||
{
|
||||
key: 'creation',
|
||||
label: this.$t('open_creation'),
|
||||
label: [
|
||||
this.$moment().subtract(2, 'month').format('MMM'),
|
||||
this.$moment().subtract(1, 'month').format('MMM'),
|
||||
this.$moment().format('MMM'),
|
||||
].join(' | '),
|
||||
formatter: (value, key, item) => {
|
||||
return (
|
||||
`
|
||||
<div>` +
|
||||
this.$moment().subtract(2, 'month').format('MMMM') +
|
||||
` - ` +
|
||||
String(value[0]) +
|
||||
` GDD</div>
|
||||
<div>` +
|
||||
this.$moment().subtract(1, 'month').format('MMMM') +
|
||||
` - ` +
|
||||
String(value[1]) +
|
||||
` GDD</div>
|
||||
<div>` +
|
||||
this.$moment().format('MMMM') +
|
||||
` - ` +
|
||||
String(value[2]) +
|
||||
` GDD</div>
|
||||
`
|
||||
)
|
||||
return value.join(' | ')
|
||||
},
|
||||
},
|
||||
{ key: 'show_details', label: this.$t('details') },
|
||||
@ -87,7 +73,7 @@ export default {
|
||||
methods: {
|
||||
unconfirmedRegisterMails() {
|
||||
this.searchResult = this.searchResult.filter((user) => {
|
||||
return user.emailChecked
|
||||
return !user.emailChecked
|
||||
})
|
||||
},
|
||||
getUsers() {
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import { verifyLogin } from '../graphql/verifyLogin'
|
||||
import CONFIG from '../config'
|
||||
|
||||
const addNavigationGuards = (router, store, apollo) => {
|
||||
const addNavigationGuards = (router, store, apollo, i18n) => {
|
||||
// store token on `authenticate`
|
||||
router.beforeEach(async (to, from, next) => {
|
||||
if (to.path === '/authenticate' && to.query && to.query.token) {
|
||||
@ -14,6 +14,7 @@ const addNavigationGuards = (router, store, apollo) => {
|
||||
.then((result) => {
|
||||
const moderator = result.data.verifyLogin
|
||||
if (moderator.isAdmin) {
|
||||
i18n.locale = moderator.language
|
||||
store.commit('moderator', moderator)
|
||||
next({ path: '/' })
|
||||
} else {
|
||||
|
||||
@ -6,9 +6,11 @@ const apolloQueryMock = jest.fn().mockResolvedValue({
|
||||
data: {
|
||||
verifyLogin: {
|
||||
isAdmin: true,
|
||||
language: 'de',
|
||||
},
|
||||
},
|
||||
})
|
||||
const i18nLocaleMock = jest.fn()
|
||||
|
||||
const store = {
|
||||
commit: storeCommitMock,
|
||||
@ -21,7 +23,11 @@ const apollo = {
|
||||
query: apolloQueryMock,
|
||||
}
|
||||
|
||||
addNavigationGuards(router, store, apollo)
|
||||
const i18n = {
|
||||
locale: i18nLocaleMock,
|
||||
}
|
||||
|
||||
addNavigationGuards(router, store, apollo, i18n)
|
||||
|
||||
describe('navigation guards', () => {
|
||||
beforeEach(() => {
|
||||
@ -33,19 +39,23 @@ describe('navigation guards', () => {
|
||||
const next = jest.fn()
|
||||
|
||||
describe('with valid token and as admin', () => {
|
||||
beforeEach(() => {
|
||||
navGuard({ path: '/authenticate', query: { token: 'valid-token' } }, {}, next)
|
||||
beforeEach(async () => {
|
||||
await navGuard({ path: '/authenticate', query: { token: 'valid-token' } }, {}, next)
|
||||
})
|
||||
|
||||
it('commits the token to the store', async () => {
|
||||
it('commits the token to the store', () => {
|
||||
expect(storeCommitMock).toBeCalledWith('token', 'valid-token')
|
||||
})
|
||||
|
||||
it('commits the moderator to the store', () => {
|
||||
expect(storeCommitMock).toBeCalledWith('moderator', { isAdmin: true })
|
||||
it.skip('sets the locale', () => {
|
||||
expect(i18nLocaleMock).toBeCalledWith('de')
|
||||
})
|
||||
|
||||
it('redirects to /', async () => {
|
||||
it('commits the moderator to the store', () => {
|
||||
expect(storeCommitMock).toBeCalledWith('moderator', { isAdmin: true, language: 'de' })
|
||||
})
|
||||
|
||||
it('redirects to /', () => {
|
||||
expect(next).toBeCalledWith({ path: '/' })
|
||||
})
|
||||
})
|
||||
|
||||
@ -1,3 +1,6 @@
|
||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
|
||||
|
||||
import { Resolver, Query, Arg, Args, Authorized, Mutation, Ctx } from 'type-graphql'
|
||||
import { getCustomRepository, Raw } from 'typeorm'
|
||||
import { UserAdmin } from '../model/UserAdmin'
|
||||
@ -62,9 +65,9 @@ export class AdminResolver {
|
||||
loginPendingTaskAdmin.memo = memo
|
||||
loginPendingTaskAdmin.moderator = moderator
|
||||
|
||||
loginPendingTasksAdminRepository.save(loginPendingTaskAdmin)
|
||||
await loginPendingTasksAdminRepository.save(loginPendingTaskAdmin)
|
||||
}
|
||||
return await getUserCreations(user.id)
|
||||
return getUserCreations(user.id)
|
||||
}
|
||||
|
||||
@Authorized([RIGHTS.CREATE_PENDING_CREATION])
|
||||
|
||||
@ -503,7 +503,7 @@ export class TransactionResolver {
|
||||
email: userEntity.email,
|
||||
})
|
||||
if (!resultGDTSum.success) throw new Error(resultGDTSum.data)
|
||||
transactions.gdtSum = resultGDTSum.data.sum || 0
|
||||
transactions.gdtSum = Number(resultGDTSum.data.sum / 100) || 0
|
||||
|
||||
// get balance
|
||||
const balanceRepository = getCustomRepository(BalanceRepository)
|
||||
|
||||
@ -710,7 +710,7 @@ export class UserResolver {
|
||||
if (password && passwordNew) {
|
||||
// TODO: This had some error cases defined - like missing private key. This is no longer checked.
|
||||
const oldPasswordHash = SecretKeyCryptographyCreateKey(loginUser.email, password)
|
||||
if (loginUser.password !== oldPasswordHash[0].readBigUInt64LE()) {
|
||||
if (BigInt(loginUser.password.toString()) !== oldPasswordHash[0].readBigUInt64LE()) {
|
||||
throw new Error(`Old password is invalid`)
|
||||
}
|
||||
|
||||
@ -720,7 +720,7 @@ export class UserResolver {
|
||||
const encryptedPrivkey = SecretKeyCryptographyEncrypt(privKey, newPasswordHash[1])
|
||||
|
||||
// Save new password hash and newly encrypted private key
|
||||
loginUser.password = newPasswordHash[0].readBigInt64LE()
|
||||
loginUser.password = newPasswordHash[0].readBigUInt64LE()
|
||||
loginUser.privKey = encryptedPrivkey
|
||||
}
|
||||
|
||||
|
||||
@ -8,7 +8,11 @@ const plugins = [
|
||||
willSendResponse(requestContext: any) {
|
||||
const { setHeaders = [] } = requestContext.context
|
||||
setHeaders.forEach(({ key, value }: { [key: string]: string }) => {
|
||||
requestContext.response.http.headers.append(key, value)
|
||||
if (requestContext.response.http.headers.get(key)) {
|
||||
requestContext.response.http.headers.set(key, value)
|
||||
} else {
|
||||
requestContext.response.http.headers.append(key, value)
|
||||
}
|
||||
})
|
||||
return requestContext
|
||||
},
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
import { EntityRepository, Repository } from 'typeorm'
|
||||
import { Order } from '../../graphql/enum/Order'
|
||||
import { UserTransaction } from '@entity/UserTransaction'
|
||||
import { TransactionTypeId } from '../../graphql/enum/TransactionTypeId'
|
||||
|
||||
@EntityRepository(UserTransaction)
|
||||
export class UserTransactionRepository extends Repository<UserTransaction> {
|
||||
@ -14,7 +15,9 @@ export class UserTransactionRepository extends Repository<UserTransaction> {
|
||||
if (onlyCreation) {
|
||||
return this.createQueryBuilder('userTransaction')
|
||||
.where('userTransaction.userId = :userId', { userId })
|
||||
.andWhere('userTransaction.type = "creation"')
|
||||
.andWhere('userTransaction.transactionTypeId = :transactionTypeId', {
|
||||
transactionTypeId: TransactionTypeId.CREATION,
|
||||
})
|
||||
.orderBy('userTransaction.balanceDate', order)
|
||||
.limit(limit)
|
||||
.offset(offset)
|
||||
|
||||
@ -19,7 +19,7 @@ define(LoginUser, (faker: typeof Faker, context?: LoginUserContext) => {
|
||||
user.privKey = context.privKey ? context.privKey : randomBytes(80)
|
||||
user.emailHash = context.emailHash ? context.emailHash : randomBytes(32)
|
||||
user.createdAt = context.createdAt ? context.createdAt : faker.date.recent()
|
||||
user.emailChecked = context.emailChecked ? context.emailChecked : true
|
||||
user.emailChecked = context.emailChecked === undefined ? false : context.emailChecked
|
||||
user.passphraseShown = context.passphraseShown ? context.passphraseShown : false
|
||||
user.language = context.language ? context.language : 'en'
|
||||
user.disabled = context.disabled ? context.disabled : false
|
||||
|
||||
@ -6,6 +6,7 @@ import { CreatePeterLustigSeed } from './seeds/users/peter-lustig.admin.seed'
|
||||
import { CreateBibiBloxbergSeed } from './seeds/users/bibi-bloxberg.seed'
|
||||
import { CreateRaeuberHotzenplotzSeed } from './seeds/users/raeuber-hotzenplotz.seed'
|
||||
import { CreateBobBaumeisterSeed } from './seeds/users/bob-baumeister.seed'
|
||||
import { CreateGarrickOllivanderSeed } from './seeds/users/garrick-ollivander.seed'
|
||||
import { DecayStartBlockSeed } from './seeds/decay-start-block.seed'
|
||||
import { resetDB, pool, migration } from './helpers'
|
||||
|
||||
@ -44,6 +45,7 @@ const run = async (command: string) => {
|
||||
await runSeeder(CreateBibiBloxbergSeed)
|
||||
await runSeeder(CreateRaeuberHotzenplotzSeed)
|
||||
await runSeeder(CreateBobBaumeisterSeed)
|
||||
await runSeeder(CreateGarrickOllivanderSeed)
|
||||
break
|
||||
default:
|
||||
throw new Error(`Unsupported command ${command}`)
|
||||
|
||||
@ -23,7 +23,7 @@ export interface LoginUserContext {
|
||||
language?: string
|
||||
disabled?: boolean
|
||||
groupId?: number
|
||||
publisherId?: number | null
|
||||
publisherId?: number
|
||||
}
|
||||
|
||||
export interface LoginUserBackupContext {
|
||||
|
||||
@ -15,7 +15,7 @@ export interface UserInterface {
|
||||
language?: string
|
||||
disabled?: boolean
|
||||
groupId?: number
|
||||
publisherId?: number | null
|
||||
publisherId?: number
|
||||
// from login user backup
|
||||
passphrase?: string
|
||||
mnemonicType?: number
|
||||
|
||||
@ -17,7 +17,6 @@ export const bibiBloxberg = {
|
||||
language: 'de',
|
||||
disabled: false,
|
||||
groupId: 1,
|
||||
publisherId: null,
|
||||
passphrase:
|
||||
'knife normal level all hurdle crucial color avoid warrior stadium road bachelor affair topple hawk pottery right afford immune two ceiling budget glance hour ',
|
||||
mnemonicType: 2,
|
||||
|
||||
@ -17,7 +17,6 @@ export const bobBaumeister = {
|
||||
language: 'de',
|
||||
disabled: false,
|
||||
groupId: 1,
|
||||
publisherId: null,
|
||||
passphrase:
|
||||
'detail master source effort unable waste tilt flush domain orchard art truck hint barrel response gate impose peanut secret merry three uncle wink resource ',
|
||||
mnemonicType: 2,
|
||||
|
||||
9
database/src/seeds/users/garrick-ollivander.seed.ts
Normal file
9
database/src/seeds/users/garrick-ollivander.seed.ts
Normal file
@ -0,0 +1,9 @@
|
||||
import { Factory, Seeder } from 'typeorm-seeding'
|
||||
import { garrickOllivander } from './garrick-ollivander'
|
||||
import { userSeeder } from '../helpers/user-helpers'
|
||||
|
||||
export class CreateGarrickOllivanderSeed implements Seeder {
|
||||
public async run(factory: Factory): Promise<void> {
|
||||
await userSeeder(factory, garrickOllivander)
|
||||
}
|
||||
}
|
||||
21
database/src/seeds/users/garrick-ollivander.ts
Normal file
21
database/src/seeds/users/garrick-ollivander.ts
Normal file
@ -0,0 +1,21 @@
|
||||
export const garrickOllivander = {
|
||||
email: 'garrick@ollivander.com',
|
||||
firstName: 'Garrick',
|
||||
lastName: 'Ollivander',
|
||||
username: 'garrick',
|
||||
description: `Curious ... curious ...
|
||||
Renowned wandmaker Mr Ollivander owns the wand shop Ollivanders: Makers of Fine Wands Since 382 BC in Diagon Alley. His shop is widely considered the best place to purchase a wand.`,
|
||||
password: BigInt('0'),
|
||||
emailHash: Buffer.from('91e358000e908146342789979d62a7255b2b88a71dad0c6a10e32af44be57886', 'hex'),
|
||||
createdAt: new Date('2022-01-10T10:23:17'),
|
||||
emailChecked: false,
|
||||
passphraseShown: false,
|
||||
language: 'en',
|
||||
disabled: false,
|
||||
groupId: 1,
|
||||
passphrase:
|
||||
'human glide theory clump wish history other duty door fringe neck industry ostrich equal plate diesel tornado neck people antenna door category moon hen ',
|
||||
mnemonicType: 2,
|
||||
isAdmin: false,
|
||||
addBalance: false,
|
||||
}
|
||||
@ -17,7 +17,6 @@ export const peterLustig = {
|
||||
language: 'de',
|
||||
disabled: false,
|
||||
groupId: 1,
|
||||
publisherId: null,
|
||||
passphrase:
|
||||
'okay property choice naive calm present weird increase stuff royal vibrant frame attend wood one else tribe pull hedgehog woman kitchen hawk snack smart ',
|
||||
mnemonicType: 2,
|
||||
|
||||
@ -17,7 +17,6 @@ export const raeuberHotzenplotz = {
|
||||
language: 'de',
|
||||
disabled: false,
|
||||
groupId: 1,
|
||||
publisherId: null,
|
||||
passphrase:
|
||||
'gospel trip tenant mouse spider skill auto curious man video chief response same little over expire drum display fancy clinic keen throw urge basket ',
|
||||
mnemonicType: 2,
|
||||
|
||||
Binary file not shown.
@ -28,7 +28,7 @@ Vue.toasted.register(
|
||||
|
||||
loadAllRules(i18n)
|
||||
|
||||
addNavigationGuards(router, store, apolloProvider.defaultClient)
|
||||
addNavigationGuards(router, store, apolloProvider.defaultClient, i18n)
|
||||
|
||||
if (!store) {
|
||||
setTimeout(
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { verifyLogin } from '../graphql/queries'
|
||||
|
||||
const addNavigationGuards = (router, store, apollo) => {
|
||||
const addNavigationGuards = (router, store, apollo, i18n) => {
|
||||
// handle publisherId
|
||||
router.beforeEach((to, from, next) => {
|
||||
const publisherId = to.query.pid
|
||||
@ -21,6 +21,7 @@ const addNavigationGuards = (router, store, apollo) => {
|
||||
fetchPolicy: 'network-only',
|
||||
})
|
||||
.then((result) => {
|
||||
i18n.locale = result.data.verifyLogin.language
|
||||
store.dispatch('login', result.data.verifyLogin)
|
||||
next({ path: '/overview' })
|
||||
})
|
||||
|
||||
@ -23,7 +23,11 @@ const apollo = {
|
||||
query: apolloQueryMock,
|
||||
}
|
||||
|
||||
addNavigationGuards(router, store, apollo)
|
||||
const i18n = {
|
||||
locale: jest.fn(),
|
||||
}
|
||||
|
||||
addNavigationGuards(router, store, apollo, i18n)
|
||||
|
||||
describe('navigation guards', () => {
|
||||
beforeEach(() => {
|
||||
|
||||
@ -28,6 +28,9 @@ const createMockObject = (comingFrom) => {
|
||||
optin: '123',
|
||||
comingFrom,
|
||||
},
|
||||
path: {
|
||||
includes: (t) => t,
|
||||
},
|
||||
},
|
||||
$toasted: {
|
||||
global: {
|
||||
|
||||
@ -5,10 +5,10 @@
|
||||
<div class="header-body text-center mb-7">
|
||||
<b-row class="justify-content-center">
|
||||
<b-col xl="5" lg="6" md="8" class="px-2">
|
||||
<h1>{{ $t('settings.password.reset') }}</h1>
|
||||
<h1>{{ $t(displaySetup.authenticated) }}</h1>
|
||||
<div class="pb-4">
|
||||
<span>
|
||||
{{ $t('settings.password.reset-password.text') }}
|
||||
{{ $t(displaySetup.notAuthenticated) }}
|
||||
</span>
|
||||
</div>
|
||||
</b-col>
|
||||
@ -49,14 +49,14 @@ import { setPassword } from '../../graphql/mutations'
|
||||
|
||||
const textFields = {
|
||||
reset: {
|
||||
authenticated: 'settings.password.reset-password.text',
|
||||
notAuthenticated: 'settings.password.not-authenticated',
|
||||
button: 'settings.password.reset',
|
||||
authenticated: 'settings.password.change-password',
|
||||
notAuthenticated: 'settings.password.reset-password.text',
|
||||
button: 'settings.password.change-password',
|
||||
linkTo: '/login',
|
||||
},
|
||||
checkEmail: {
|
||||
authenticated: 'settings.password.set-password.text',
|
||||
notAuthenticated: 'settings.password.not-authenticated',
|
||||
authenticated: 'settings.password.set',
|
||||
notAuthenticated: 'settings.password.set-password.text',
|
||||
button: 'settings.password.set',
|
||||
linkTo: '/login',
|
||||
},
|
||||
@ -95,19 +95,17 @@ export default {
|
||||
this.$router.push('/thx/reset')
|
||||
})
|
||||
.catch((error) => {
|
||||
if (error.message.includes('Code is older than 10 minutes')) {
|
||||
this.$toasted.global.error(error.message)
|
||||
this.$toasted.global.error(error.message)
|
||||
if (error.message.includes('Code is older than 10 minutes'))
|
||||
this.$router.push('/password/reset')
|
||||
} else {
|
||||
this.$toasted.global.error(error.message)
|
||||
}
|
||||
})
|
||||
},
|
||||
setDisplaySetup() {
|
||||
if (!this.$route.params.comingFrom) {
|
||||
if (this.$route.path.includes('checkEmail')) {
|
||||
this.displaySetup = textFields.checkEmail
|
||||
}
|
||||
if (this.$route.path.includes('reset')) {
|
||||
this.displaySetup = textFields.reset
|
||||
} else {
|
||||
this.displaySetup = textFields[this.$route.params.comingFrom]
|
||||
}
|
||||
},
|
||||
},
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user