mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
Merge branch 'master' of github.com:gradido/gradido into disable-change-month-for-contribution-updates
This commit is contained in:
commit
98e64ed867
@ -3,11 +3,15 @@ import NavBar from './NavBar.vue'
|
||||
|
||||
const localVue = global.localVue
|
||||
|
||||
const apolloMutateMock = jest.fn()
|
||||
const storeDispatchMock = jest.fn()
|
||||
const routerPushMock = jest.fn()
|
||||
|
||||
const mocks = {
|
||||
$t: jest.fn((t) => t),
|
||||
$apollo: {
|
||||
mutate: apolloMutateMock,
|
||||
},
|
||||
$store: {
|
||||
state: {
|
||||
openCreations: 1,
|
||||
@ -69,5 +73,9 @@ describe('NavBar', () => {
|
||||
it('dispatches logout to store', () => {
|
||||
expect(storeDispatchMock).toBeCalledWith('logout')
|
||||
})
|
||||
|
||||
it('has called logout mutation', () => {
|
||||
expect(apolloMutateMock).toBeCalled()
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@ -28,14 +28,18 @@
|
||||
</template>
|
||||
<script>
|
||||
import CONFIG from '../config'
|
||||
import { logout } from '../graphql/logout'
|
||||
|
||||
export default {
|
||||
name: 'navbar',
|
||||
methods: {
|
||||
logout() {
|
||||
async logout() {
|
||||
window.location.assign(CONFIG.WALLET_URL)
|
||||
// window.location = CONFIG.WALLET_URL
|
||||
this.$store.dispatch('logout')
|
||||
await this.$apollo.mutate({
|
||||
mutation: logout,
|
||||
})
|
||||
},
|
||||
wallet() {
|
||||
window.location = CONFIG.WALLET_AUTH_URL.replace('{token}', this.$store.state.token)
|
||||
|
||||
7
admin/src/graphql/logout.js
Normal file
7
admin/src/graphql/logout.js
Normal file
@ -0,0 +1,7 @@
|
||||
import gql from 'graphql-tag'
|
||||
|
||||
export const logout = gql`
|
||||
mutation {
|
||||
logout
|
||||
}
|
||||
`
|
||||
@ -13,6 +13,7 @@ import { peterLustig } from '@/seeds/users/peter-lustig'
|
||||
import { stephenHawking } from '@/seeds/users/stephen-hawking'
|
||||
import { garrickOllivander } from '@/seeds/users/garrick-ollivander'
|
||||
import {
|
||||
login,
|
||||
setUserRole,
|
||||
deleteUser,
|
||||
unDeleteUser,
|
||||
@ -27,7 +28,6 @@ import {
|
||||
} from '@/seeds/graphql/mutations'
|
||||
import {
|
||||
listUnconfirmedContributions,
|
||||
login,
|
||||
searchUsers,
|
||||
listTransactionLinksAdmin,
|
||||
listContributionLinks,
|
||||
@ -96,8 +96,8 @@ describe('AdminResolver', () => {
|
||||
describe('without admin rights', () => {
|
||||
beforeAll(async () => {
|
||||
user = await userFactory(testEnv, bibiBloxberg)
|
||||
await query({
|
||||
query: login,
|
||||
await mutate({
|
||||
mutation: login,
|
||||
variables: { email: 'bibi@bloxberg.de', password: 'Aa12345_' },
|
||||
})
|
||||
})
|
||||
@ -121,8 +121,8 @@ describe('AdminResolver', () => {
|
||||
describe('with admin rights', () => {
|
||||
beforeAll(async () => {
|
||||
admin = await userFactory(testEnv, peterLustig)
|
||||
await query({
|
||||
query: login,
|
||||
await mutate({
|
||||
mutation: login,
|
||||
variables: { email: 'peter@lustig.de', password: 'Aa12345_' },
|
||||
})
|
||||
})
|
||||
@ -249,8 +249,8 @@ describe('AdminResolver', () => {
|
||||
describe('without admin rights', () => {
|
||||
beforeAll(async () => {
|
||||
user = await userFactory(testEnv, bibiBloxberg)
|
||||
await query({
|
||||
query: login,
|
||||
await mutate({
|
||||
mutation: login,
|
||||
variables: { email: 'bibi@bloxberg.de', password: 'Aa12345_' },
|
||||
})
|
||||
})
|
||||
@ -274,8 +274,8 @@ describe('AdminResolver', () => {
|
||||
describe('with admin rights', () => {
|
||||
beforeAll(async () => {
|
||||
admin = await userFactory(testEnv, peterLustig)
|
||||
await query({
|
||||
query: login,
|
||||
await mutate({
|
||||
mutation: login,
|
||||
variables: { email: 'peter@lustig.de', password: 'Aa12345_' },
|
||||
})
|
||||
})
|
||||
@ -357,8 +357,8 @@ describe('AdminResolver', () => {
|
||||
describe('without admin rights', () => {
|
||||
beforeAll(async () => {
|
||||
user = await userFactory(testEnv, bibiBloxberg)
|
||||
await query({
|
||||
query: login,
|
||||
await mutate({
|
||||
mutation: login,
|
||||
variables: { email: 'bibi@bloxberg.de', password: 'Aa12345_' },
|
||||
})
|
||||
})
|
||||
@ -382,8 +382,8 @@ describe('AdminResolver', () => {
|
||||
describe('with admin rights', () => {
|
||||
beforeAll(async () => {
|
||||
admin = await userFactory(testEnv, peterLustig)
|
||||
await query({
|
||||
query: login,
|
||||
await mutate({
|
||||
mutation: login,
|
||||
variables: { email: 'peter@lustig.de', password: 'Aa12345_' },
|
||||
})
|
||||
})
|
||||
@ -469,8 +469,8 @@ describe('AdminResolver', () => {
|
||||
describe('without admin rights', () => {
|
||||
beforeAll(async () => {
|
||||
user = await userFactory(testEnv, bibiBloxberg)
|
||||
await query({
|
||||
query: login,
|
||||
await mutate({
|
||||
mutation: login,
|
||||
variables: { email: 'bibi@bloxberg.de', password: 'Aa12345_' },
|
||||
})
|
||||
})
|
||||
@ -514,8 +514,8 @@ describe('AdminResolver', () => {
|
||||
|
||||
beforeAll(async () => {
|
||||
admin = await userFactory(testEnv, peterLustig)
|
||||
await query({
|
||||
query: login,
|
||||
await mutate({
|
||||
mutation: login,
|
||||
variables: { email: 'peter@lustig.de', password: 'Aa12345_' },
|
||||
})
|
||||
|
||||
@ -766,8 +766,8 @@ describe('AdminResolver', () => {
|
||||
describe('without admin rights', () => {
|
||||
beforeAll(async () => {
|
||||
user = await userFactory(testEnv, bibiBloxberg)
|
||||
await query({
|
||||
query: login,
|
||||
await mutate({
|
||||
mutation: login,
|
||||
variables: { email: 'bibi@bloxberg.de', password: 'Aa12345_' },
|
||||
})
|
||||
})
|
||||
@ -875,8 +875,8 @@ describe('AdminResolver', () => {
|
||||
describe('with admin rights', () => {
|
||||
beforeAll(async () => {
|
||||
admin = await userFactory(testEnv, peterLustig)
|
||||
await query({
|
||||
query: login,
|
||||
await mutate({
|
||||
mutation: login,
|
||||
variables: { email: 'peter@lustig.de', password: 'Aa12345_' },
|
||||
})
|
||||
})
|
||||
@ -1559,8 +1559,8 @@ describe('AdminResolver', () => {
|
||||
describe('without admin rights', () => {
|
||||
beforeAll(async () => {
|
||||
user = await userFactory(testEnv, bibiBloxberg)
|
||||
await query({
|
||||
query: login,
|
||||
await mutate({
|
||||
mutation: login,
|
||||
variables: { email: 'bibi@bloxberg.de', password: 'Aa12345_' },
|
||||
})
|
||||
})
|
||||
@ -1605,8 +1605,8 @@ describe('AdminResolver', () => {
|
||||
}
|
||||
|
||||
// admin: only now log in
|
||||
await query({
|
||||
query: login,
|
||||
await mutate({
|
||||
mutation: login,
|
||||
variables: { email: 'peter@lustig.de', password: 'Aa12345_' },
|
||||
})
|
||||
})
|
||||
@ -1865,8 +1865,8 @@ describe('AdminResolver', () => {
|
||||
describe('without admin rights', () => {
|
||||
beforeAll(async () => {
|
||||
user = await userFactory(testEnv, bibiBloxberg)
|
||||
await query({
|
||||
query: login,
|
||||
await mutate({
|
||||
mutation: login,
|
||||
variables: { email: 'bibi@bloxberg.de', password: 'Aa12345_' },
|
||||
})
|
||||
})
|
||||
@ -1939,8 +1939,8 @@ describe('AdminResolver', () => {
|
||||
describe('with admin rights', () => {
|
||||
beforeAll(async () => {
|
||||
user = await userFactory(testEnv, peterLustig)
|
||||
await query({
|
||||
query: login,
|
||||
await mutate({
|
||||
mutation: login,
|
||||
variables: { email: 'peter@lustig.de', password: 'Aa12345_' },
|
||||
})
|
||||
})
|
||||
|
||||
@ -7,8 +7,9 @@ import {
|
||||
adminCreateContributionMessage,
|
||||
createContribution,
|
||||
createContributionMessage,
|
||||
login,
|
||||
} from '@/seeds/graphql/mutations'
|
||||
import { listContributionMessages, login } from '@/seeds/graphql/queries'
|
||||
import { listContributionMessages } from '@/seeds/graphql/queries'
|
||||
import { userFactory } from '@/seeds/factory/user'
|
||||
import { bibiBloxberg } from '@/seeds/users/bibi-bloxberg'
|
||||
import { peterLustig } from '@/seeds/users/peter-lustig'
|
||||
@ -21,14 +22,13 @@ jest.mock('@/mailer/sendAddedContributionMessageEmail', () => {
|
||||
}
|
||||
})
|
||||
|
||||
let mutate: any, query: any, con: any
|
||||
let mutate: any, con: any
|
||||
let testEnv: any
|
||||
let result: any
|
||||
|
||||
beforeAll(async () => {
|
||||
testEnv = await testEnvironment()
|
||||
mutate = testEnv.mutate
|
||||
query = testEnv.query
|
||||
con = testEnv.con
|
||||
await cleanDB()
|
||||
})
|
||||
@ -59,8 +59,8 @@ describe('ContributionMessageResolver', () => {
|
||||
beforeAll(async () => {
|
||||
await userFactory(testEnv, bibiBloxberg)
|
||||
await userFactory(testEnv, peterLustig)
|
||||
await query({
|
||||
query: login,
|
||||
await mutate({
|
||||
mutation: login,
|
||||
variables: { email: 'bibi@bloxberg.de', password: 'Aa12345_' },
|
||||
})
|
||||
result = await mutate({
|
||||
@ -71,8 +71,8 @@ describe('ContributionMessageResolver', () => {
|
||||
creationDate: new Date().toString(),
|
||||
},
|
||||
})
|
||||
await query({
|
||||
query: login,
|
||||
await mutate({
|
||||
mutation: login,
|
||||
variables: { email: 'peter@lustig.de', password: 'Aa12345_' },
|
||||
})
|
||||
})
|
||||
@ -103,8 +103,8 @@ describe('ContributionMessageResolver', () => {
|
||||
})
|
||||
|
||||
it('throws error when contribution.userId equals user.id', async () => {
|
||||
await query({
|
||||
query: login,
|
||||
await mutate({
|
||||
mutation: login,
|
||||
variables: { email: 'peter@lustig.de', password: 'Aa12345_' },
|
||||
})
|
||||
const result2 = await mutate({
|
||||
@ -195,8 +195,8 @@ describe('ContributionMessageResolver', () => {
|
||||
|
||||
describe('authenticated', () => {
|
||||
beforeAll(async () => {
|
||||
await query({
|
||||
query: login,
|
||||
await mutate({
|
||||
mutation: login,
|
||||
variables: { email: 'bibi@bloxberg.de', password: 'Aa12345_' },
|
||||
})
|
||||
})
|
||||
@ -227,8 +227,8 @@ describe('ContributionMessageResolver', () => {
|
||||
})
|
||||
|
||||
it('throws error when other user tries to send createContributionMessage', async () => {
|
||||
await query({
|
||||
query: login,
|
||||
await mutate({
|
||||
mutation: login,
|
||||
variables: { email: 'peter@lustig.de', password: 'Aa12345_' },
|
||||
})
|
||||
await expect(
|
||||
@ -253,8 +253,8 @@ describe('ContributionMessageResolver', () => {
|
||||
|
||||
describe('valid input', () => {
|
||||
beforeAll(async () => {
|
||||
await query({
|
||||
query: login,
|
||||
await mutate({
|
||||
mutation: login,
|
||||
variables: { email: 'bibi@bloxberg.de', password: 'Aa12345_' },
|
||||
})
|
||||
})
|
||||
@ -304,8 +304,8 @@ describe('ContributionMessageResolver', () => {
|
||||
|
||||
describe('authenticated', () => {
|
||||
beforeAll(async () => {
|
||||
await query({
|
||||
query: login,
|
||||
await mutate({
|
||||
mutation: login,
|
||||
variables: { email: 'bibi@bloxberg.de', password: 'Aa12345_' },
|
||||
})
|
||||
})
|
||||
|
||||
@ -8,8 +8,9 @@ import {
|
||||
createContribution,
|
||||
deleteContribution,
|
||||
updateContribution,
|
||||
login,
|
||||
} from '@/seeds/graphql/mutations'
|
||||
import { listAllContributions, listContributions, login } from '@/seeds/graphql/queries'
|
||||
import { listAllContributions, listContributions } from '@/seeds/graphql/queries'
|
||||
import { cleanDB, resetToken, testEnvironment } from '@test/helpers'
|
||||
import { GraphQLError } from 'graphql'
|
||||
import { userFactory } from '@/seeds/factory/user'
|
||||
@ -54,8 +55,8 @@ describe('ContributionResolver', () => {
|
||||
describe('authenticated with valid user', () => {
|
||||
beforeAll(async () => {
|
||||
await userFactory(testEnv, bibiBloxberg)
|
||||
await query({
|
||||
query: login,
|
||||
await mutate({
|
||||
mutation: login,
|
||||
variables: { email: 'bibi@bloxberg.de', password: 'Aa12345_' },
|
||||
})
|
||||
})
|
||||
@ -197,8 +198,8 @@ describe('ContributionResolver', () => {
|
||||
const bibisCreation = creations.find((creation) => creation.email === 'bibi@bloxberg.de')
|
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
await creationFactory(testEnv, bibisCreation!)
|
||||
await query({
|
||||
query: login,
|
||||
await mutate({
|
||||
mutation: login,
|
||||
variables: { email: 'bibi@bloxberg.de', password: 'Aa12345_' },
|
||||
})
|
||||
await mutate({
|
||||
@ -310,8 +311,8 @@ describe('ContributionResolver', () => {
|
||||
beforeAll(async () => {
|
||||
await userFactory(testEnv, peterLustig)
|
||||
await userFactory(testEnv, bibiBloxberg)
|
||||
await query({
|
||||
query: login,
|
||||
await mutate({
|
||||
mutation: login,
|
||||
variables: { email: 'bibi@bloxberg.de', password: 'Aa12345_' },
|
||||
})
|
||||
result = await mutate({
|
||||
@ -393,8 +394,8 @@ describe('ContributionResolver', () => {
|
||||
|
||||
describe('wrong user tries to update the contribution', () => {
|
||||
beforeAll(async () => {
|
||||
await query({
|
||||
query: login,
|
||||
await mutate({
|
||||
mutation: login,
|
||||
variables: { email: 'peter@lustig.de', password: 'Aa12345_' },
|
||||
})
|
||||
})
|
||||
@ -445,8 +446,8 @@ describe('ContributionResolver', () => {
|
||||
|
||||
describe('update too much so that the limit is exceeded', () => {
|
||||
beforeAll(async () => {
|
||||
await query({
|
||||
query: login,
|
||||
await mutate({
|
||||
mutation: login,
|
||||
variables: { email: 'bibi@bloxberg.de', password: 'Aa12345_' },
|
||||
})
|
||||
})
|
||||
@ -551,8 +552,8 @@ describe('ContributionResolver', () => {
|
||||
const bibisCreation = creations.find((creation) => creation.email === 'bibi@bloxberg.de')
|
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
await creationFactory(testEnv, bibisCreation!)
|
||||
await query({
|
||||
query: login,
|
||||
await mutate({
|
||||
mutation: login,
|
||||
variables: { email: 'bibi@bloxberg.de', password: 'Aa12345_' },
|
||||
})
|
||||
await mutate({
|
||||
@ -628,8 +629,8 @@ describe('ContributionResolver', () => {
|
||||
beforeAll(async () => {
|
||||
await userFactory(testEnv, bibiBloxberg)
|
||||
await userFactory(testEnv, peterLustig)
|
||||
await query({
|
||||
query: login,
|
||||
await mutate({
|
||||
mutation: login,
|
||||
variables: { email: 'bibi@bloxberg.de', password: 'Aa12345_' },
|
||||
})
|
||||
result = await mutate({
|
||||
@ -666,8 +667,8 @@ describe('ContributionResolver', () => {
|
||||
|
||||
describe('other user sends a deleteContribtuion', () => {
|
||||
it('returns an error', async () => {
|
||||
await query({
|
||||
query: login,
|
||||
await mutate({
|
||||
mutation: login,
|
||||
variables: { email: 'peter@lustig.de', password: 'Aa12345_' },
|
||||
})
|
||||
await expect(
|
||||
@ -700,8 +701,8 @@ describe('ContributionResolver', () => {
|
||||
|
||||
describe('User deletes already confirmed contribution', () => {
|
||||
it('throws an error', async () => {
|
||||
await query({
|
||||
query: login,
|
||||
await mutate({
|
||||
mutation: login,
|
||||
variables: { email: 'peter@lustig.de', password: 'Aa12345_' },
|
||||
})
|
||||
await mutate({
|
||||
@ -710,8 +711,8 @@ describe('ContributionResolver', () => {
|
||||
id: result.data.createContribution.id,
|
||||
},
|
||||
})
|
||||
await query({
|
||||
query: login,
|
||||
await mutate({
|
||||
mutation: login,
|
||||
variables: { email: 'bibi@bloxberg.de', password: 'Aa12345_' },
|
||||
})
|
||||
await expect(
|
||||
|
||||
@ -5,6 +5,8 @@ import { testEnvironment, headerPushMock, resetToken, cleanDB } from '@test/help
|
||||
import { userFactory } from '@/seeds/factory/user'
|
||||
import { bibiBloxberg } from '@/seeds/users/bibi-bloxberg'
|
||||
import {
|
||||
login,
|
||||
logout,
|
||||
createUser,
|
||||
setPassword,
|
||||
forgotPassword,
|
||||
@ -12,7 +14,7 @@ import {
|
||||
createContribution,
|
||||
confirmContribution,
|
||||
} from '@/seeds/graphql/mutations'
|
||||
import { login, logout, verifyLogin, queryOptIn, searchAdminUsers } from '@/seeds/graphql/queries'
|
||||
import { verifyLogin, queryOptIn, searchAdminUsers } from '@/seeds/graphql/queries'
|
||||
import { GraphQLError } from 'graphql'
|
||||
import { User } from '@entity/User'
|
||||
import CONFIG from '@/config'
|
||||
@ -582,7 +584,7 @@ describe('UserResolver', () => {
|
||||
describe('no users in database', () => {
|
||||
beforeAll(async () => {
|
||||
jest.clearAllMocks()
|
||||
result = await query({ query: login, variables })
|
||||
result = await mutate({ mutation: login, variables })
|
||||
})
|
||||
|
||||
it('throws an error', () => {
|
||||
@ -603,7 +605,7 @@ describe('UserResolver', () => {
|
||||
describe('user is in database and correct login data', () => {
|
||||
beforeAll(async () => {
|
||||
await userFactory(testEnv, bibiBloxberg)
|
||||
result = await query({ query: login, variables })
|
||||
result = await mutate({ mutation: login, variables })
|
||||
})
|
||||
|
||||
afterAll(async () => {
|
||||
@ -640,7 +642,7 @@ describe('UserResolver', () => {
|
||||
describe('user is in database and wrong password', () => {
|
||||
beforeAll(async () => {
|
||||
await userFactory(testEnv, bibiBloxberg)
|
||||
result = await query({ query: login, variables: { ...variables, password: 'wrong' } })
|
||||
result = await mutate({ mutation: login, variables: { ...variables, password: 'wrong' } })
|
||||
})
|
||||
|
||||
afterAll(async () => {
|
||||
@ -665,7 +667,7 @@ describe('UserResolver', () => {
|
||||
describe('unauthenticated', () => {
|
||||
it('throws an error', async () => {
|
||||
resetToken()
|
||||
await expect(query({ query: logout })).resolves.toEqual(
|
||||
await expect(mutate({ mutation: logout })).resolves.toEqual(
|
||||
expect.objectContaining({
|
||||
errors: [new GraphQLError('401 Unauthorized')],
|
||||
}),
|
||||
@ -681,7 +683,7 @@ describe('UserResolver', () => {
|
||||
|
||||
beforeAll(async () => {
|
||||
await userFactory(testEnv, bibiBloxberg)
|
||||
await query({ query: login, variables })
|
||||
await mutate({ mutation: login, variables })
|
||||
})
|
||||
|
||||
afterAll(async () => {
|
||||
@ -689,7 +691,7 @@ describe('UserResolver', () => {
|
||||
})
|
||||
|
||||
it('returns true', async () => {
|
||||
await expect(query({ query: logout })).resolves.toEqual(
|
||||
await expect(mutate({ mutation: logout })).resolves.toEqual(
|
||||
expect.objectContaining({
|
||||
data: { logout: 'true' },
|
||||
errors: undefined,
|
||||
@ -738,7 +740,7 @@ describe('UserResolver', () => {
|
||||
}
|
||||
|
||||
beforeAll(async () => {
|
||||
await query({ query: login, variables })
|
||||
await mutate({ mutation: login, variables })
|
||||
user = await User.find()
|
||||
})
|
||||
|
||||
@ -929,8 +931,8 @@ describe('UserResolver', () => {
|
||||
describe('authenticated', () => {
|
||||
beforeAll(async () => {
|
||||
await userFactory(testEnv, bibiBloxberg)
|
||||
await query({
|
||||
query: login,
|
||||
await mutate({
|
||||
mutation: login,
|
||||
variables: {
|
||||
email: 'bibi@bloxberg.de',
|
||||
password: 'Aa12345_',
|
||||
@ -1061,8 +1063,8 @@ describe('UserResolver', () => {
|
||||
|
||||
it('can login with new password', async () => {
|
||||
await expect(
|
||||
query({
|
||||
query: login,
|
||||
mutate({
|
||||
mutation: login,
|
||||
variables: {
|
||||
email: 'bibi@bloxberg.de',
|
||||
password: 'Bb12345_',
|
||||
@ -1081,8 +1083,8 @@ describe('UserResolver', () => {
|
||||
|
||||
it('cannot login with old password', async () => {
|
||||
await expect(
|
||||
query({
|
||||
query: login,
|
||||
mutate({
|
||||
mutation: login,
|
||||
variables: {
|
||||
email: 'bibi@bloxberg.de',
|
||||
password: 'Aa12345_',
|
||||
@ -1119,8 +1121,8 @@ describe('UserResolver', () => {
|
||||
beforeAll(async () => {
|
||||
await userFactory(testEnv, bibiBloxberg)
|
||||
await userFactory(testEnv, peterLustig)
|
||||
await query({
|
||||
query: login,
|
||||
await mutate({
|
||||
mutation: login,
|
||||
variables: {
|
||||
email: 'bibi@bloxberg.de',
|
||||
password: 'Aa12345_',
|
||||
|
||||
@ -316,7 +316,7 @@ export class UserResolver {
|
||||
}
|
||||
|
||||
@Authorized([RIGHTS.LOGIN])
|
||||
@Query(() => User)
|
||||
@Mutation(() => User)
|
||||
@UseMiddleware(klicktippNewsletterStateMiddleware)
|
||||
async login(
|
||||
@Args() { email, password, publisherId }: UnsecureLoginArgs,
|
||||
@ -377,7 +377,7 @@ export class UserResolver {
|
||||
}
|
||||
|
||||
@Authorized([RIGHTS.LOGOUT])
|
||||
@Query(() => String)
|
||||
@Mutation(() => String)
|
||||
async logout(): Promise<boolean> {
|
||||
// TODO: We dont need this anymore, but might need this in the future in oder to invalidate a valid JWT-Token.
|
||||
// Furthermore this hook can be useful for tracking user behaviour (did he logout or not? Warn him if he didn't on next login)
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
import { ApolloServerTestClient } from 'apollo-server-testing'
|
||||
import { createContributionLink } from '@/seeds/graphql/mutations'
|
||||
import { login } from '@/seeds/graphql/queries'
|
||||
import { login, createContributionLink } from '@/seeds/graphql/mutations'
|
||||
import { ContributionLink } from '@model/ContributionLink'
|
||||
import { ContributionLinkInterface } from '@/seeds/contributionLink/ContributionLinkInterface'
|
||||
|
||||
@ -8,12 +7,12 @@ export const contributionLinkFactory = async (
|
||||
client: ApolloServerTestClient,
|
||||
contributionLink: ContributionLinkInterface,
|
||||
): Promise<ContributionLink> => {
|
||||
const { mutate, query } = client
|
||||
const { mutate } = client
|
||||
|
||||
// login as admin
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
const user = await query({
|
||||
query: login,
|
||||
const user = await mutate({
|
||||
mutation: login,
|
||||
variables: { email: 'peter@lustig.de', password: 'Aa12345_' },
|
||||
})
|
||||
|
||||
|
||||
@ -2,8 +2,7 @@
|
||||
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
|
||||
|
||||
import { backendLogger as logger } from '@/server/logger'
|
||||
import { adminCreateContribution, confirmContribution } from '@/seeds/graphql/mutations'
|
||||
import { login } from '@/seeds/graphql/queries'
|
||||
import { login, adminCreateContribution, confirmContribution } from '@/seeds/graphql/mutations'
|
||||
import { CreationInterface } from '@/seeds/creation/CreationInterface'
|
||||
import { ApolloServerTestClient } from 'apollo-server-testing'
|
||||
import { Transaction } from '@entity/Transaction'
|
||||
@ -19,9 +18,9 @@ export const creationFactory = async (
|
||||
client: ApolloServerTestClient,
|
||||
creation: CreationInterface,
|
||||
): Promise<Contribution | void> => {
|
||||
const { mutate, query } = client
|
||||
const { mutate } = client
|
||||
logger.trace('creationFactory...')
|
||||
await query({ query: login, variables: { email: 'peter@lustig.de', password: 'Aa12345_' } })
|
||||
await mutate({ mutation: login, variables: { email: 'peter@lustig.de', password: 'Aa12345_' } })
|
||||
logger.trace('creationFactory... after login')
|
||||
// TODO it would be nice to have this mutation return the id
|
||||
await mutate({ mutation: adminCreateContribution, variables: { ...creation } })
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
import { ApolloServerTestClient } from 'apollo-server-testing'
|
||||
import { createTransactionLink } from '@/seeds/graphql/mutations'
|
||||
import { login } from '@/seeds/graphql/queries'
|
||||
import { login, createTransactionLink } from '@/seeds/graphql/mutations'
|
||||
import { TransactionLinkInterface } from '@/seeds/transactionLink/TransactionLinkInterface'
|
||||
import { transactionLinkExpireDate } from '@/graphql/resolver/TransactionLinkResolver'
|
||||
import { TransactionLink } from '@entity/TransactionLink'
|
||||
@ -9,10 +8,13 @@ export const transactionLinkFactory = async (
|
||||
client: ApolloServerTestClient,
|
||||
transactionLink: TransactionLinkInterface,
|
||||
): Promise<void> => {
|
||||
const { mutate, query } = client
|
||||
const { mutate } = client
|
||||
|
||||
// login
|
||||
await query({ query: login, variables: { email: transactionLink.email, password: 'Aa12345_' } })
|
||||
await mutate({
|
||||
mutation: login,
|
||||
variables: { email: transactionLink.email, password: 'Aa12345_' },
|
||||
})
|
||||
|
||||
const variables = {
|
||||
amount: transactionLink.amount,
|
||||
|
||||
@ -289,3 +289,27 @@ export const adminCreateContributionMessage = gql`
|
||||
}
|
||||
}
|
||||
`
|
||||
|
||||
export const login = gql`
|
||||
mutation ($email: String!, $password: String!, $publisherId: Int) {
|
||||
login(email: $email, password: $password, publisherId: $publisherId) {
|
||||
id
|
||||
email
|
||||
firstName
|
||||
lastName
|
||||
language
|
||||
klickTipp {
|
||||
newsletterState
|
||||
}
|
||||
hasElopage
|
||||
publisherId
|
||||
isAdmin
|
||||
}
|
||||
}
|
||||
`
|
||||
|
||||
export const logout = gql`
|
||||
mutation {
|
||||
logout
|
||||
}
|
||||
`
|
||||
|
||||
@ -1,23 +1,5 @@
|
||||
import gql from 'graphql-tag'
|
||||
|
||||
export const login = gql`
|
||||
query ($email: String!, $password: String!, $publisherId: Int) {
|
||||
login(email: $email, password: $password, publisherId: $publisherId) {
|
||||
id
|
||||
email
|
||||
firstName
|
||||
lastName
|
||||
language
|
||||
klickTipp {
|
||||
newsletterState
|
||||
}
|
||||
hasElopage
|
||||
publisherId
|
||||
isAdmin
|
||||
}
|
||||
}
|
||||
`
|
||||
|
||||
export const verifyLogin = gql`
|
||||
query {
|
||||
verifyLogin {
|
||||
@ -35,12 +17,6 @@ export const verifyLogin = gql`
|
||||
}
|
||||
`
|
||||
|
||||
export const logout = gql`
|
||||
query {
|
||||
logout
|
||||
}
|
||||
`
|
||||
|
||||
export const queryOptIn = gql`
|
||||
query ($optIn: String!) {
|
||||
queryOptIn(optIn: $optIn)
|
||||
|
||||
@ -136,3 +136,27 @@ export const createContributionMessage = gql`
|
||||
}
|
||||
}
|
||||
`
|
||||
|
||||
export const login = gql`
|
||||
mutation($email: String!, $password: String!, $publisherId: Int) {
|
||||
login(email: $email, password: $password, publisherId: $publisherId) {
|
||||
email
|
||||
firstName
|
||||
lastName
|
||||
language
|
||||
klickTipp {
|
||||
newsletterState
|
||||
}
|
||||
hasElopage
|
||||
publisherId
|
||||
isAdmin
|
||||
creation
|
||||
}
|
||||
}
|
||||
`
|
||||
|
||||
export const logout = gql`
|
||||
mutation {
|
||||
logout
|
||||
}
|
||||
`
|
||||
|
||||
@ -1,23 +1,5 @@
|
||||
import gql from 'graphql-tag'
|
||||
|
||||
export const login = gql`
|
||||
query($email: String!, $password: String!, $publisherId: Int) {
|
||||
login(email: $email, password: $password, publisherId: $publisherId) {
|
||||
email
|
||||
firstName
|
||||
lastName
|
||||
language
|
||||
klickTipp {
|
||||
newsletterState
|
||||
}
|
||||
hasElopage
|
||||
publisherId
|
||||
isAdmin
|
||||
creation
|
||||
}
|
||||
}
|
||||
`
|
||||
|
||||
export const verifyLogin = gql`
|
||||
query {
|
||||
verifyLogin {
|
||||
@ -36,12 +18,6 @@ export const verifyLogin = gql`
|
||||
}
|
||||
`
|
||||
|
||||
export const logout = gql`
|
||||
query {
|
||||
logout
|
||||
}
|
||||
`
|
||||
|
||||
export const transactionsQuery = gql`
|
||||
query($currentPage: Int = 1, $pageSize: Int = 25, $order: Order = DESC) {
|
||||
transactionList(currentPage: $currentPage, pageSize: $pageSize, order: $order) {
|
||||
|
||||
@ -18,6 +18,7 @@ const apolloMock = jest.fn().mockResolvedValue({
|
||||
logout: 'success',
|
||||
},
|
||||
})
|
||||
const apolloQueryMock = jest.fn()
|
||||
|
||||
describe('DashboardLayout', () => {
|
||||
let wrapper
|
||||
@ -40,7 +41,8 @@ describe('DashboardLayout', () => {
|
||||
},
|
||||
},
|
||||
$apollo: {
|
||||
query: apolloMock,
|
||||
mutate: apolloMock,
|
||||
query: apolloQueryMock,
|
||||
},
|
||||
$store: {
|
||||
state: {
|
||||
@ -142,7 +144,7 @@ describe('DashboardLayout', () => {
|
||||
|
||||
describe('update transactions', () => {
|
||||
beforeEach(async () => {
|
||||
apolloMock.mockResolvedValue({
|
||||
apolloQueryMock.mockResolvedValue({
|
||||
data: {
|
||||
transactionList: {
|
||||
balance: {
|
||||
@ -163,7 +165,7 @@ describe('DashboardLayout', () => {
|
||||
})
|
||||
|
||||
it('calls the API', () => {
|
||||
expect(apolloMock).toBeCalledWith(
|
||||
expect(apolloQueryMock).toBeCalledWith(
|
||||
expect.objectContaining({
|
||||
variables: {
|
||||
currentPage: 2,
|
||||
@ -201,7 +203,7 @@ describe('DashboardLayout', () => {
|
||||
|
||||
describe('update transactions returns error', () => {
|
||||
beforeEach(async () => {
|
||||
apolloMock.mockRejectedValue({
|
||||
apolloQueryMock.mockRejectedValue({
|
||||
message: 'Ouch!',
|
||||
})
|
||||
await wrapper
|
||||
|
||||
@ -41,7 +41,8 @@
|
||||
import Navbar from '@/components/Menu/Navbar.vue'
|
||||
import Sidebar from '@/components/Menu/Sidebar.vue'
|
||||
import SessionLogoutTimeout from '@/components/SessionLogoutTimeout.vue'
|
||||
import { logout, transactionsQuery } from '@/graphql/queries'
|
||||
import { transactionsQuery } from '@/graphql/queries'
|
||||
import { logout } from '@/graphql/mutations'
|
||||
import ContentFooter from '@/components/ContentFooter.vue'
|
||||
import { FadeTransition } from 'vue2-transitions'
|
||||
import CONFIG from '@/config'
|
||||
@ -75,8 +76,8 @@ export default {
|
||||
methods: {
|
||||
async logout() {
|
||||
this.$apollo
|
||||
.query({
|
||||
query: logout,
|
||||
.mutate({
|
||||
mutation: logout,
|
||||
})
|
||||
.then(() => {
|
||||
this.$store.dispatch('logout')
|
||||
|
||||
@ -5,7 +5,7 @@ import Login from './Login'
|
||||
|
||||
const localVue = global.localVue
|
||||
|
||||
const apolloQueryMock = jest.fn()
|
||||
const apolloMutateMock = jest.fn()
|
||||
const mockStoreDispach = jest.fn()
|
||||
const mockStoreCommit = jest.fn()
|
||||
const mockRouterPush = jest.fn()
|
||||
@ -41,7 +41,7 @@ describe('Login', () => {
|
||||
params: {},
|
||||
},
|
||||
$apollo: {
|
||||
query: apolloQueryMock,
|
||||
mutate: apolloMutateMock,
|
||||
},
|
||||
}
|
||||
|
||||
@ -113,7 +113,7 @@ describe('Login', () => {
|
||||
await wrapper.find('input[placeholder="Email"]').setValue('user@example.org')
|
||||
await wrapper.find('input[placeholder="form.password"]').setValue('1234')
|
||||
await flushPromises()
|
||||
apolloQueryMock.mockResolvedValue({
|
||||
apolloMutateMock.mockResolvedValue({
|
||||
data: {
|
||||
login: 'token',
|
||||
},
|
||||
@ -123,7 +123,7 @@ describe('Login', () => {
|
||||
})
|
||||
|
||||
it('calls the API with the given data', () => {
|
||||
expect(apolloQueryMock).toBeCalledWith(
|
||||
expect(apolloMutateMock).toBeCalledWith(
|
||||
expect.objectContaining({
|
||||
variables: {
|
||||
email: 'user@example.org',
|
||||
@ -175,7 +175,7 @@ describe('Login', () => {
|
||||
|
||||
describe('login fails', () => {
|
||||
const createError = async (errorMessage) => {
|
||||
apolloQueryMock.mockRejectedValue({
|
||||
apolloMutateMock.mockRejectedValue({
|
||||
message: errorMessage,
|
||||
})
|
||||
wrapper = Wrapper()
|
||||
|
||||
@ -43,7 +43,7 @@
|
||||
import InputPassword from '@/components/Inputs/InputPassword'
|
||||
import InputEmail from '@/components/Inputs/InputEmail'
|
||||
import Message from '@/components/Message/Message'
|
||||
import { login } from '@/graphql/queries'
|
||||
import { login } from '@/graphql/mutations'
|
||||
|
||||
export default {
|
||||
name: 'Login',
|
||||
@ -71,14 +71,13 @@ export default {
|
||||
container: this.$refs.submitButton,
|
||||
})
|
||||
this.$apollo
|
||||
.query({
|
||||
query: login,
|
||||
.mutate({
|
||||
mutation: login,
|
||||
variables: {
|
||||
email: this.form.email,
|
||||
password: this.form.password,
|
||||
publisherId: this.$store.state.publisherId,
|
||||
},
|
||||
fetchPolicy: 'network-only',
|
||||
})
|
||||
.then(async (result) => {
|
||||
const {
|
||||
|
||||
@ -43,6 +43,7 @@ const mocks = {
|
||||
$store: {
|
||||
state: {
|
||||
token: null,
|
||||
tokenTime: null,
|
||||
email: 'bibi@bloxberg.de',
|
||||
},
|
||||
},
|
||||
@ -68,7 +69,7 @@ describe('TransactionLink', () => {
|
||||
}
|
||||
|
||||
describe('mount', () => {
|
||||
beforeEach(() => {
|
||||
beforeAll(() => {
|
||||
jest.clearAllMocks()
|
||||
wrapper = Wrapper()
|
||||
})
|
||||
@ -214,112 +215,159 @@ describe('TransactionLink', () => {
|
||||
})
|
||||
})
|
||||
|
||||
describe('token in store and own link', () => {
|
||||
beforeEach(() => {
|
||||
describe('token in store', () => {
|
||||
beforeAll(() => {
|
||||
mocks.$store.state.token = 'token'
|
||||
apolloQueryMock.mockResolvedValue({
|
||||
data: {
|
||||
queryTransactionLink: {
|
||||
__typename: 'TransactionLink',
|
||||
id: 92,
|
||||
amount: '22',
|
||||
memo: 'Abrakadabra drei, vier, fünf, sechs, hier steht jetzt ein Memotext! Hex hex ',
|
||||
createdAt: '2022-03-17T16:10:28.000Z',
|
||||
validUntil: transactionLinkValidExpireDate(),
|
||||
redeemedAt: null,
|
||||
deletedAt: null,
|
||||
user: { firstName: 'Bibi', publisherId: 0, email: 'bibi@bloxberg.de' },
|
||||
},
|
||||
},
|
||||
})
|
||||
wrapper = Wrapper()
|
||||
})
|
||||
|
||||
it('has a RedeemSelfCreator component', () => {
|
||||
expect(wrapper.findComponent({ name: 'RedeemSelfCreator' }).exists()).toBe(true)
|
||||
})
|
||||
|
||||
it('has a no redeem text', () => {
|
||||
expect(wrapper.findComponent({ name: 'RedeemSelfCreator' }).text()).toContain(
|
||||
'gdd_per_link.no-redeem',
|
||||
)
|
||||
})
|
||||
|
||||
it.skip('has a link to transaction page', () => {
|
||||
expect(wrapper.find('a[target="/transactions"]').exists()).toBe(true)
|
||||
})
|
||||
})
|
||||
|
||||
describe('valid link', () => {
|
||||
beforeEach(() => {
|
||||
mocks.$store.state.token = 'token'
|
||||
apolloQueryMock.mockResolvedValue({
|
||||
data: {
|
||||
queryTransactionLink: {
|
||||
__typename: 'TransactionLink',
|
||||
id: 92,
|
||||
amount: '22',
|
||||
memo: 'Abrakadabra drei, vier, fünf, sechs, hier steht jetzt ein Memotext! Hex hex ',
|
||||
createdAt: '2022-03-17T16:10:28.000Z',
|
||||
validUntil: transactionLinkValidExpireDate(),
|
||||
redeemedAt: null,
|
||||
deletedAt: null,
|
||||
user: { firstName: 'Peter', publisherId: 0, email: 'peter@listig.de' },
|
||||
},
|
||||
},
|
||||
})
|
||||
wrapper = Wrapper()
|
||||
})
|
||||
|
||||
it('has a RedeemValid component', () => {
|
||||
expect(wrapper.findComponent({ name: 'RedeemValid' }).exists()).toBe(true)
|
||||
})
|
||||
|
||||
it('has a button with redeem text', () => {
|
||||
expect(wrapper.findComponent({ name: 'RedeemValid' }).find('button').text()).toBe(
|
||||
'gdd_per_link.redeem',
|
||||
)
|
||||
})
|
||||
|
||||
describe('redeem link with success', () => {
|
||||
beforeEach(async () => {
|
||||
apolloMutateMock.mockResolvedValue()
|
||||
await wrapper.findComponent({ name: 'RedeemValid' }).find('button').trigger('click')
|
||||
describe('sufficient token time in store', () => {
|
||||
beforeAll(() => {
|
||||
mocks.$store.state.tokenTime = Math.floor(Date.now() / 1000) + 20
|
||||
})
|
||||
|
||||
it('calls the API', () => {
|
||||
expect(apolloMutateMock).toBeCalledWith(
|
||||
expect.objectContaining({
|
||||
mutation: redeemTransactionLink,
|
||||
variables: {
|
||||
code: 'some-code',
|
||||
describe('own link', () => {
|
||||
beforeAll(() => {
|
||||
apolloQueryMock.mockResolvedValue({
|
||||
data: {
|
||||
queryTransactionLink: {
|
||||
__typename: 'TransactionLink',
|
||||
id: 92,
|
||||
amount: '22',
|
||||
memo:
|
||||
'Abrakadabra drei, vier, fünf, sechs, hier steht jetzt ein Memotext! Hex hex ',
|
||||
createdAt: '2022-03-17T16:10:28.000Z',
|
||||
validUntil: transactionLinkValidExpireDate(),
|
||||
redeemedAt: null,
|
||||
deletedAt: null,
|
||||
user: { firstName: 'Bibi', publisherId: 0, email: 'bibi@bloxberg.de' },
|
||||
},
|
||||
},
|
||||
}),
|
||||
)
|
||||
})
|
||||
wrapper = Wrapper()
|
||||
})
|
||||
|
||||
it('has a RedeemSelfCreator component', () => {
|
||||
expect(wrapper.findComponent({ name: 'RedeemSelfCreator' }).exists()).toBe(true)
|
||||
})
|
||||
|
||||
it('has a no redeem text', () => {
|
||||
expect(wrapper.findComponent({ name: 'RedeemSelfCreator' }).text()).toContain(
|
||||
'gdd_per_link.no-redeem',
|
||||
)
|
||||
})
|
||||
|
||||
it.skip('has a link to transaction page', () => {
|
||||
expect(wrapper.find('a[target="/transactions"]').exists()).toBe(true)
|
||||
})
|
||||
})
|
||||
|
||||
it('toasts a success message', () => {
|
||||
expect(mocks.$t).toBeCalledWith('gdd_per_link.redeem')
|
||||
expect(toastSuccessSpy).toBeCalledWith('gdd_per_link.redeemed; ')
|
||||
})
|
||||
describe('valid link', () => {
|
||||
beforeAll(() => {
|
||||
apolloQueryMock.mockResolvedValue({
|
||||
data: {
|
||||
queryTransactionLink: {
|
||||
__typename: 'TransactionLink',
|
||||
id: 92,
|
||||
amount: '22',
|
||||
memo:
|
||||
'Abrakadabra drei, vier, fünf, sechs, hier steht jetzt ein Memotext! Hex hex ',
|
||||
createdAt: '2022-03-17T16:10:28.000Z',
|
||||
validUntil: transactionLinkValidExpireDate(),
|
||||
redeemedAt: null,
|
||||
deletedAt: null,
|
||||
user: { firstName: 'Peter', publisherId: 0, email: 'peter@listig.de' },
|
||||
},
|
||||
},
|
||||
})
|
||||
wrapper = Wrapper()
|
||||
})
|
||||
|
||||
it('pushes the route to overview', () => {
|
||||
expect(routerPushMock).toBeCalledWith('/overview')
|
||||
it('has a RedeemValid component', () => {
|
||||
expect(wrapper.findComponent({ name: 'RedeemValid' }).exists()).toBe(true)
|
||||
})
|
||||
|
||||
it('has a button with redeem text', () => {
|
||||
expect(wrapper.findComponent({ name: 'RedeemValid' }).find('button').text()).toBe(
|
||||
'gdd_per_link.redeem',
|
||||
)
|
||||
})
|
||||
|
||||
describe('redeem link with success', () => {
|
||||
beforeAll(async () => {
|
||||
apolloMutateMock.mockResolvedValue()
|
||||
await wrapper.findComponent({ name: 'RedeemValid' }).find('button').trigger('click')
|
||||
})
|
||||
|
||||
it('calls the API', () => {
|
||||
expect(apolloMutateMock).toBeCalledWith(
|
||||
expect.objectContaining({
|
||||
mutation: redeemTransactionLink,
|
||||
variables: {
|
||||
code: 'some-code',
|
||||
},
|
||||
}),
|
||||
)
|
||||
})
|
||||
|
||||
it('toasts a success message', () => {
|
||||
expect(mocks.$t).toBeCalledWith('gdd_per_link.redeem')
|
||||
expect(toastSuccessSpy).toBeCalledWith('gdd_per_link.redeemed; ')
|
||||
})
|
||||
|
||||
it('pushes the route to overview', () => {
|
||||
expect(routerPushMock).toBeCalledWith('/overview')
|
||||
})
|
||||
})
|
||||
|
||||
describe('redeem link with error', () => {
|
||||
beforeAll(async () => {
|
||||
apolloMutateMock.mockRejectedValue({ message: 'Oh Noo!' })
|
||||
await wrapper.findComponent({ name: 'RedeemValid' }).find('button').trigger('click')
|
||||
})
|
||||
|
||||
it('toasts an error message', () => {
|
||||
expect(toastErrorSpy).toBeCalledWith('Oh Noo!')
|
||||
})
|
||||
|
||||
it('pushes the route to overview', () => {
|
||||
expect(routerPushMock).toBeCalledWith('/overview')
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('redeem link with error', () => {
|
||||
beforeEach(async () => {
|
||||
apolloMutateMock.mockRejectedValue({ message: 'Oh Noo!' })
|
||||
await wrapper.findComponent({ name: 'RedeemValid' }).find('button').trigger('click')
|
||||
describe('no sufficient token time in store', () => {
|
||||
beforeAll(() => {
|
||||
mocks.$store.state.tokenTime = 1665125185
|
||||
apolloQueryMock.mockResolvedValue({
|
||||
data: {
|
||||
queryTransactionLink: {
|
||||
__typename: 'TransactionLink',
|
||||
id: 92,
|
||||
amount: '22',
|
||||
memo:
|
||||
'Abrakadabra drei, vier, fünf, sechs, hier steht jetzt ein Memotext! Hex hex ',
|
||||
createdAt: '2022-03-17T16:10:28.000Z',
|
||||
validUntil: transactionLinkValidExpireDate(),
|
||||
redeemedAt: null,
|
||||
deletedAt: null,
|
||||
user: { firstName: 'Bibi', publisherId: 0, email: 'bibi@bloxberg.de' },
|
||||
},
|
||||
},
|
||||
})
|
||||
wrapper = Wrapper()
|
||||
})
|
||||
|
||||
it('toasts an error message', () => {
|
||||
expect(toastErrorSpy).toBeCalledWith('Oh Noo!')
|
||||
it('has a RedeemLoggedOut component', () => {
|
||||
expect(wrapper.findComponent({ name: 'RedeemLoggedOut' }).exists()).toBe(true)
|
||||
})
|
||||
|
||||
it('pushes the route to overview', () => {
|
||||
expect(routerPushMock).toBeCalledWith('/overview')
|
||||
it('has a link to register with code', () => {
|
||||
expect(wrapper.find('a[href="/register/some-code"]').exists()).toBe(true)
|
||||
})
|
||||
|
||||
it('has a link to login with code', () => {
|
||||
expect(wrapper.find('a[href="/login/some-code"]').exists()).toBe(true)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@ -103,6 +103,12 @@ export default {
|
||||
isContributionLink() {
|
||||
return this.$route.params.code.search(/^CL-/) === 0
|
||||
},
|
||||
tokenExpiresInSeconds() {
|
||||
const remainingSecs = Math.floor(
|
||||
(new Date(this.$store.state.tokenTime * 1000).getTime() - new Date().getTime()) / 1000,
|
||||
)
|
||||
return remainingSecs <= 0 ? 0 : remainingSecs
|
||||
},
|
||||
itemType() {
|
||||
// link is deleted: at, from
|
||||
if (this.linkData.deletedAt) {
|
||||
@ -130,7 +136,9 @@ export default {
|
||||
return `TEXT`
|
||||
}
|
||||
|
||||
if (this.$store.state.token) {
|
||||
if (this.$store.state.token && this.$store.state.tokenTime) {
|
||||
if (this.tokenExpiresInSeconds < 5) return `LOGGED_OUT`
|
||||
|
||||
// logged in, nicht berechtigt einzulösen, eigener link
|
||||
if (this.linkData.user && this.$store.state.email === this.linkData.user.email) {
|
||||
return `SELF_CREATOR`
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user