mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
Merge branch 'master' into pubKey-in-JWT
This commit is contained in:
commit
3e8835304d
2
.github/workflows/test.yml
vendored
2
.github/workflows/test.yml
vendored
@ -344,7 +344,7 @@ jobs:
|
||||
report_name: Coverage Frontend
|
||||
type: lcov
|
||||
result_path: ./coverage/lcov.info
|
||||
min_coverage: 67
|
||||
min_coverage: 69
|
||||
token: ${{ github.token }}
|
||||
|
||||
##############################################################################
|
||||
|
||||
4712
backend/package-lock.json
generated
4712
backend/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -9,7 +9,7 @@ export class TransactionListInput {
|
||||
items: number
|
||||
|
||||
@Field(() => String)
|
||||
order: string
|
||||
order: 'ASC' | 'DESC'
|
||||
}
|
||||
|
||||
@ArgsType()
|
||||
|
||||
@ -1,29 +1,43 @@
|
||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
|
||||
import { ObjectType, Field, Int } from 'type-graphql'
|
||||
import { Transaction } from '../../typeorm/entity/Transaction'
|
||||
|
||||
@ObjectType()
|
||||
export class Decay {
|
||||
constructor(json: any) {
|
||||
this.balance = Number(json.balance)
|
||||
this.decayStart = json.decay_start
|
||||
this.decayEnd = json.decay_end
|
||||
this.decayDuration = json.decay_duration
|
||||
this.decayStartBlock = json.decay_start_block
|
||||
if (json) {
|
||||
this.balance = Number(json.balance)
|
||||
this.decayStart = json.decay_start
|
||||
this.decayEnd = json.decay_end
|
||||
this.decayDuration = json.decay_duration
|
||||
this.decayStartBlock = json.decay_start_block
|
||||
}
|
||||
}
|
||||
|
||||
static async getDecayStartBlock(): Promise<Transaction | undefined> {
|
||||
if (!this.decayStartBlockTransaction) {
|
||||
this.decayStartBlockTransaction = await Transaction.getDecayStartBlock()
|
||||
}
|
||||
return this.decayStartBlockTransaction
|
||||
}
|
||||
|
||||
@Field(() => Number)
|
||||
balance: number
|
||||
|
||||
// timestamp in seconds
|
||||
@Field(() => Int, { nullable: true })
|
||||
decayStart?: number
|
||||
decayStart: string
|
||||
|
||||
// timestamp in seconds
|
||||
@Field(() => Int, { nullable: true })
|
||||
decayEnd?: number
|
||||
decayEnd: string
|
||||
|
||||
@Field(() => String, { nullable: true })
|
||||
decayDuration?: string
|
||||
decayDuration?: number
|
||||
|
||||
@Field(() => Int, { nullable: true })
|
||||
decayStartBlock?: number
|
||||
decayStartBlock?: string
|
||||
|
||||
static decayStartBlockTransaction: Transaction | undefined
|
||||
}
|
||||
|
||||
@ -10,18 +10,11 @@ import { Decay } from './Decay'
|
||||
|
||||
@ObjectType()
|
||||
export class Transaction {
|
||||
constructor(json: any) {
|
||||
this.type = json.type
|
||||
this.balance = Number(json.balance)
|
||||
this.decayStart = json.decay_start
|
||||
this.decayEnd = json.decay_end
|
||||
this.decayDuration = json.decay_duration
|
||||
this.memo = json.memo
|
||||
this.transactionId = json.transaction_id
|
||||
this.name = json.name
|
||||
this.email = json.email
|
||||
this.date = json.date
|
||||
this.decay = json.decay ? new Decay(json.decay) : undefined
|
||||
constructor() {
|
||||
this.type = ''
|
||||
this.balance = 0
|
||||
this.totalBalance = 0
|
||||
this.memo = ''
|
||||
}
|
||||
|
||||
@Field(() => String)
|
||||
@ -30,14 +23,17 @@ export class Transaction {
|
||||
@Field(() => Number)
|
||||
balance: number
|
||||
|
||||
@Field({ nullable: true })
|
||||
decayStart?: number
|
||||
@Field(() => Number)
|
||||
totalBalance: number
|
||||
|
||||
@Field({ nullable: true })
|
||||
decayEnd?: number
|
||||
decayStart?: string
|
||||
|
||||
@Field({ nullable: true })
|
||||
decayDuration?: string
|
||||
decayEnd?: string
|
||||
|
||||
@Field({ nullable: true })
|
||||
decayDuration?: number
|
||||
|
||||
@Field(() => String)
|
||||
memo: string
|
||||
@ -60,15 +56,12 @@ export class Transaction {
|
||||
|
||||
@ObjectType()
|
||||
export class TransactionList {
|
||||
constructor(json: any) {
|
||||
this.gdtSum = Number(json.gdtSum)
|
||||
this.count = json.count
|
||||
this.balance = Number(json.balance)
|
||||
this.decay = Number(json.decay)
|
||||
this.decayDate = json.decay_date
|
||||
this.transactions = json.transactions.map((el: any) => {
|
||||
return new Transaction(el)
|
||||
})
|
||||
constructor() {
|
||||
this.gdtSum = 0
|
||||
this.count = 0
|
||||
this.balance = 0
|
||||
this.decay = 0
|
||||
this.decayDate = ''
|
||||
}
|
||||
|
||||
@Field(() => Number)
|
||||
|
||||
@ -5,7 +5,7 @@ import { Resolver, Query, Ctx, Authorized } from 'type-graphql'
|
||||
import { Balance } from '../models/Balance'
|
||||
import { User as dbUser } from '../../typeorm/entity/User'
|
||||
import { Balance as dbBalance } from '../../typeorm/entity/Balance'
|
||||
import calculateDecay from '../../util/decay'
|
||||
import { calculateDecay } from '../../util/decay'
|
||||
import { roundFloorFrom4 } from '../../util/round'
|
||||
|
||||
@Resolver()
|
||||
@ -16,11 +16,23 @@ export class BalanceResolver {
|
||||
// load user and balance
|
||||
const userEntity = await dbUser.findByPubkeyHex(context.pubKey)
|
||||
const balanceEntity = await dbBalance.findByUser(userEntity.id)
|
||||
let balance: Balance
|
||||
const now = new Date()
|
||||
return new Balance({
|
||||
balance: roundFloorFrom4(balanceEntity.amount),
|
||||
decay: roundFloorFrom4(calculateDecay(balanceEntity.amount, balanceEntity.recordDate, now)),
|
||||
decay_date: now.toString(),
|
||||
})
|
||||
if (balanceEntity) {
|
||||
balance = new Balance({
|
||||
balance: roundFloorFrom4(balanceEntity.amount),
|
||||
decay: roundFloorFrom4(
|
||||
await calculateDecay(balanceEntity.amount, balanceEntity.recordDate, now),
|
||||
),
|
||||
decay_date: now.toString(),
|
||||
})
|
||||
} else {
|
||||
balance = new Balance({
|
||||
balance: 0,
|
||||
decay: 0,
|
||||
decay_date: now.toString(),
|
||||
})
|
||||
}
|
||||
return balance
|
||||
}
|
||||
}
|
||||
|
||||
@ -6,6 +6,11 @@ import CONFIG from '../../config'
|
||||
import { TransactionList } from '../models/Transaction'
|
||||
import { TransactionListInput, TransactionSendArgs } from '../inputs/TransactionInput'
|
||||
import { apiGet, apiPost } from '../../apis/HttpRequest'
|
||||
import { User as dbUser } from '../../typeorm/entity/User'
|
||||
import { Balance as dbBalance } from '../../typeorm/entity/Balance'
|
||||
import listTransactions from './listTransactions'
|
||||
import { roundFloorFrom4 } from '../../util/round'
|
||||
import { calculateDecay } from '../../util/decay'
|
||||
|
||||
@Resolver()
|
||||
export class TransactionResolver {
|
||||
@ -15,11 +20,34 @@ export class TransactionResolver {
|
||||
@Args() { firstPage = 1, items = 25, order = 'DESC' }: TransactionListInput,
|
||||
@Ctx() context: any,
|
||||
): Promise<TransactionList> {
|
||||
const result = await apiGet(
|
||||
`${CONFIG.COMMUNITY_API_URL}listTransactions/${firstPage}/${items}/${order}/${context.sessionId}`,
|
||||
)
|
||||
// get public key for current logged in user
|
||||
const result = await apiGet(CONFIG.LOGIN_API_URL + 'login?session_id=' + context.sessionId)
|
||||
if (!result.success) throw new Error(result.data)
|
||||
return new TransactionList(result.data)
|
||||
|
||||
// load user
|
||||
const userEntity = await dbUser.findByPubkeyHex(result.data.user.public_hex)
|
||||
|
||||
const transactions = await listTransactions(firstPage, items, order, userEntity)
|
||||
|
||||
// get gdt sum
|
||||
const resultGDTSum = await apiPost(`${CONFIG.GDT_API_URL}/GdtEntries/sumPerEmailApi`, {
|
||||
email: userEntity.email,
|
||||
})
|
||||
if (!resultGDTSum.success) throw new Error(resultGDTSum.data)
|
||||
transactions.gdtSum = resultGDTSum.data.sum
|
||||
|
||||
// get balance
|
||||
const balanceEntity = await dbBalance.findByUser(userEntity.id)
|
||||
if (balanceEntity) {
|
||||
const now = new Date()
|
||||
transactions.balance = roundFloorFrom4(balanceEntity.amount)
|
||||
transactions.decay = roundFloorFrom4(
|
||||
await calculateDecay(balanceEntity.amount, balanceEntity.recordDate, now),
|
||||
)
|
||||
transactions.decayDate = now.toString()
|
||||
}
|
||||
|
||||
return transactions
|
||||
}
|
||||
|
||||
@Authorized()
|
||||
|
||||
194
backend/src/graphql/resolvers/listTransactions.ts
Normal file
194
backend/src/graphql/resolvers/listTransactions.ts
Normal file
@ -0,0 +1,194 @@
|
||||
import { User as dbUser } from '../../typeorm/entity/User'
|
||||
import { TransactionList, Transaction } from '../models/Transaction'
|
||||
import { UserTransaction as dbUserTransaction } from '../../typeorm/entity/UserTransaction'
|
||||
import { Transaction as dbTransaction } from '../../typeorm/entity/Transaction'
|
||||
import { Decay } from '../models/Decay'
|
||||
import { calculateDecayWithInterval } from '../../util/decay'
|
||||
import { roundFloorFrom4 } from '../../util/round'
|
||||
|
||||
async function calculateAndAddDecayTransactions(
|
||||
userTransactions: dbUserTransaction[],
|
||||
user: dbUser,
|
||||
decay: boolean,
|
||||
skipFirstTransaction: boolean,
|
||||
): Promise<Transaction[]> {
|
||||
const finalTransactions: Transaction[] = []
|
||||
const transactionIds: number[] = []
|
||||
const involvedUserIds: number[] = []
|
||||
|
||||
userTransactions.forEach((userTransaction: dbUserTransaction) => {
|
||||
transactionIds.push(userTransaction.transactionId)
|
||||
})
|
||||
|
||||
const transactions = await dbTransaction
|
||||
.createQueryBuilder('transaction')
|
||||
.where('transaction.id IN (:...transactions)', { transactions: transactionIds })
|
||||
.leftJoinAndSelect(
|
||||
'transaction.transactionSendCoin',
|
||||
'transactionSendCoin',
|
||||
// 'transactionSendCoin.transaction_id = transaction.id',
|
||||
)
|
||||
.leftJoinAndSelect(
|
||||
'transaction.transactionCreation',
|
||||
'transactionCreation',
|
||||
// 'transactionSendCoin.transaction_id = transaction.id',
|
||||
)
|
||||
.getMany()
|
||||
|
||||
const transactionIndiced: dbTransaction[] = []
|
||||
transactions.forEach((transaction: dbTransaction) => {
|
||||
transactionIndiced[transaction.id] = transaction
|
||||
if (transaction.transactionTypeId === 2) {
|
||||
involvedUserIds.push(transaction.transactionSendCoin.userId)
|
||||
involvedUserIds.push(transaction.transactionSendCoin.recipiantUserId)
|
||||
}
|
||||
})
|
||||
// remove duplicates
|
||||
// https://stackoverflow.com/questions/1960473/get-all-unique-values-in-a-javascript-array-remove-duplicates
|
||||
const involvedUsersUnique = involvedUserIds.filter((v, i, a) => a.indexOf(v) === i)
|
||||
const userIndiced = await dbUser.getUsersIndiced(involvedUsersUnique)
|
||||
|
||||
const decayStartTransaction = await Decay.getDecayStartBlock()
|
||||
|
||||
for (let i = 0; i < userTransactions.length; i++) {
|
||||
const userTransaction = userTransactions[i]
|
||||
const transaction = transactionIndiced[userTransaction.transactionId]
|
||||
const finalTransaction = new Transaction()
|
||||
finalTransaction.transactionId = transaction.id
|
||||
finalTransaction.date = transaction.received.toISOString()
|
||||
finalTransaction.memo = transaction.memo
|
||||
finalTransaction.totalBalance = roundFloorFrom4(userTransaction.balance)
|
||||
const prev = i > 0 ? userTransactions[i - 1] : null
|
||||
|
||||
if (prev && prev.balance > 0) {
|
||||
const current = userTransaction
|
||||
const decay = await calculateDecayWithInterval(
|
||||
prev.balance,
|
||||
prev.balanceDate,
|
||||
current.balanceDate,
|
||||
)
|
||||
const balance = prev.balance - decay.balance
|
||||
|
||||
if (balance) {
|
||||
finalTransaction.decay = decay
|
||||
finalTransaction.decay.balance = roundFloorFrom4(balance)
|
||||
if (
|
||||
decayStartTransaction &&
|
||||
prev.transactionId < decayStartTransaction.id &&
|
||||
current.transactionId > decayStartTransaction.id
|
||||
) {
|
||||
finalTransaction.decay.decayStartBlock = (
|
||||
decayStartTransaction.received.getTime() / 1000
|
||||
).toString()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// sender or receiver when user has sended money
|
||||
// group name if creation
|
||||
// type: gesendet / empfangen / geschöpft
|
||||
// transaktion nr / id
|
||||
// date
|
||||
// balance
|
||||
if (userTransaction.transactionTypeId === 1) {
|
||||
// creation
|
||||
const creation = transaction.transactionCreation
|
||||
|
||||
finalTransaction.name = 'Gradido Akademie'
|
||||
finalTransaction.type = 'creation'
|
||||
// finalTransaction.targetDate = creation.targetDate
|
||||
finalTransaction.balance = roundFloorFrom4(creation.amount)
|
||||
} else if (userTransaction.transactionTypeId === 2) {
|
||||
// send coin
|
||||
const sendCoin = transaction.transactionSendCoin
|
||||
let otherUser: dbUser | undefined
|
||||
finalTransaction.balance = roundFloorFrom4(sendCoin.amount)
|
||||
if (sendCoin.userId === user.id) {
|
||||
finalTransaction.type = 'send'
|
||||
otherUser = userIndiced[sendCoin.recipiantUserId]
|
||||
// finalTransaction.pubkey = sendCoin.recipiantPublic
|
||||
} else if (sendCoin.recipiantUserId === user.id) {
|
||||
finalTransaction.type = 'receive'
|
||||
otherUser = userIndiced[sendCoin.userId]
|
||||
// finalTransaction.pubkey = sendCoin.senderPublic
|
||||
} else {
|
||||
throw new Error('invalid transaction')
|
||||
}
|
||||
if (otherUser) {
|
||||
finalTransaction.name = otherUser.firstName + ' ' + otherUser.lastName
|
||||
finalTransaction.email = otherUser.email
|
||||
}
|
||||
}
|
||||
if (i > 0 || !skipFirstTransaction) {
|
||||
finalTransactions.push(finalTransaction)
|
||||
}
|
||||
|
||||
if (i === userTransactions.length - 1 && decay) {
|
||||
const now = new Date()
|
||||
const decay = await calculateDecayWithInterval(
|
||||
userTransaction.balance,
|
||||
userTransaction.balanceDate,
|
||||
now.getTime(),
|
||||
)
|
||||
const balance = userTransaction.balance - decay.balance
|
||||
if (balance) {
|
||||
const decayTransaction = new Transaction()
|
||||
decayTransaction.type = 'decay'
|
||||
decayTransaction.balance = roundFloorFrom4(balance)
|
||||
decayTransaction.decayDuration = decay.decayDuration
|
||||
decayTransaction.decayStart = decay.decayStart
|
||||
decayTransaction.decayEnd = decay.decayEnd
|
||||
finalTransactions.push(decayTransaction)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return finalTransactions
|
||||
}
|
||||
|
||||
export default async function listTransactions(
|
||||
firstPage: number,
|
||||
items: number,
|
||||
order: 'ASC' | 'DESC',
|
||||
user: dbUser,
|
||||
): Promise<TransactionList> {
|
||||
let limit = items
|
||||
let offset = 0
|
||||
let skipFirstTransaction = false
|
||||
if (firstPage > 1) {
|
||||
offset = (firstPage - 1) * items - 1
|
||||
limit++
|
||||
}
|
||||
|
||||
if (offset && order === 'ASC') {
|
||||
offset--
|
||||
}
|
||||
let [userTransactions, userTransactionsCount] = await dbUserTransaction.findByUserPaged(
|
||||
user.id,
|
||||
limit,
|
||||
offset,
|
||||
order,
|
||||
)
|
||||
skipFirstTransaction = userTransactionsCount > offset + limit
|
||||
const decay = !(firstPage > 1)
|
||||
let transactions: Transaction[] = []
|
||||
if (userTransactions.length) {
|
||||
if (order === 'DESC') {
|
||||
userTransactions = userTransactions.reverse()
|
||||
}
|
||||
transactions = await calculateAndAddDecayTransactions(
|
||||
userTransactions,
|
||||
user,
|
||||
decay,
|
||||
skipFirstTransaction,
|
||||
)
|
||||
if (order === 'DESC') {
|
||||
transactions = transactions.reverse()
|
||||
}
|
||||
}
|
||||
|
||||
const transactionList = new TransactionList()
|
||||
transactionList.count = userTransactionsCount
|
||||
transactionList.transactions = transactions
|
||||
return transactionList
|
||||
}
|
||||
@ -17,9 +17,7 @@ export class Balance extends BaseEntity {
|
||||
@Column({ type: 'bigint' })
|
||||
amount: number
|
||||
|
||||
static findByUser(userId: number): Promise<Balance> {
|
||||
return this.createQueryBuilder('balance')
|
||||
.where('balance.userId = :userId', { userId })
|
||||
.getOneOrFail()
|
||||
static findByUser(userId: number): Promise<Balance | undefined> {
|
||||
return this.createQueryBuilder('balance').where('balance.userId = :userId', { userId }).getOne()
|
||||
}
|
||||
}
|
||||
|
||||
45
backend/src/typeorm/entity/Transaction.ts
Normal file
45
backend/src/typeorm/entity/Transaction.ts
Normal file
@ -0,0 +1,45 @@
|
||||
import { BaseEntity, Entity, PrimaryGeneratedColumn, Column, OneToOne } from 'typeorm'
|
||||
import { TransactionCreation } from './TransactionCreation'
|
||||
import { TransactionSendCoin } from './TransactionSendCoin'
|
||||
|
||||
@Entity('transactions')
|
||||
export class Transaction extends BaseEntity {
|
||||
@PrimaryGeneratedColumn()
|
||||
id: number
|
||||
|
||||
@Column({ name: 'transaction_type_id' })
|
||||
transactionTypeId: number
|
||||
|
||||
@Column({ name: 'tx_hash', type: 'binary', length: 48 })
|
||||
txHash: Buffer
|
||||
|
||||
@Column()
|
||||
memo: string
|
||||
|
||||
@Column({ type: 'timestamp' })
|
||||
received: Date
|
||||
|
||||
@Column({ name: 'blockchain_type_id' })
|
||||
blockchainTypeId: number
|
||||
|
||||
@OneToOne(() => TransactionSendCoin, (transactionSendCoin) => transactionSendCoin.transaction)
|
||||
transactionSendCoin: TransactionSendCoin
|
||||
|
||||
@OneToOne(() => TransactionCreation, (transactionCreation) => transactionCreation.transaction)
|
||||
transactionCreation: TransactionCreation
|
||||
|
||||
static async findByTransactionTypeId(transactionTypeId: number): Promise<Transaction[]> {
|
||||
return this.createQueryBuilder('transaction')
|
||||
.where('transaction.transactionTypeId = :transactionTypeId', {
|
||||
transactionTypeId: transactionTypeId,
|
||||
})
|
||||
.getMany()
|
||||
}
|
||||
|
||||
static async getDecayStartBlock(): Promise<Transaction | undefined> {
|
||||
return this.createQueryBuilder('transaction')
|
||||
.where('transaction.transactionTypeId = :transactionTypeId', { transactionTypeId: 9 })
|
||||
.orderBy('received', 'ASC')
|
||||
.getOne()
|
||||
}
|
||||
}
|
||||
32
backend/src/typeorm/entity/TransactionCreation.ts
Normal file
32
backend/src/typeorm/entity/TransactionCreation.ts
Normal file
@ -0,0 +1,32 @@
|
||||
import {
|
||||
BaseEntity,
|
||||
Entity,
|
||||
PrimaryGeneratedColumn,
|
||||
Column,
|
||||
Timestamp,
|
||||
OneToOne,
|
||||
JoinColumn,
|
||||
} from 'typeorm'
|
||||
import { Transaction } from './Transaction'
|
||||
|
||||
@Entity('transaction_creations')
|
||||
export class TransactionCreation extends BaseEntity {
|
||||
@PrimaryGeneratedColumn()
|
||||
id: number
|
||||
|
||||
@Column({ name: 'transaction_id' })
|
||||
transactionId: number
|
||||
|
||||
@Column({ name: 'state_user_id' })
|
||||
userId: number
|
||||
|
||||
@Column()
|
||||
amount: number
|
||||
|
||||
@Column({ name: 'target_date', type: 'timestamp' })
|
||||
targetDate: Timestamp
|
||||
|
||||
@OneToOne(() => Transaction)
|
||||
@JoinColumn({ name: 'transaction_id' })
|
||||
transaction: Transaction
|
||||
}
|
||||
30
backend/src/typeorm/entity/TransactionSendCoin.ts
Normal file
30
backend/src/typeorm/entity/TransactionSendCoin.ts
Normal file
@ -0,0 +1,30 @@
|
||||
import { BaseEntity, Entity, PrimaryGeneratedColumn, Column, OneToOne, JoinColumn } from 'typeorm'
|
||||
import { Transaction } from './Transaction'
|
||||
|
||||
@Entity('transaction_send_coins')
|
||||
export class TransactionSendCoin extends BaseEntity {
|
||||
@PrimaryGeneratedColumn()
|
||||
id: number
|
||||
|
||||
@Column({ name: 'transaction_id' })
|
||||
transactionId: number
|
||||
|
||||
@Column({ name: 'sender_public_key', type: 'binary', length: 32 })
|
||||
senderPublic: Buffer
|
||||
|
||||
@Column({ name: 'state_user_id' })
|
||||
userId: number
|
||||
|
||||
@Column({ name: 'receiver_public_key', type: 'binary', length: 32 })
|
||||
recipiantPublic: Buffer
|
||||
|
||||
@Column({ name: 'receiver_user_id' })
|
||||
recipiantUserId: number
|
||||
|
||||
@Column()
|
||||
amount: number
|
||||
|
||||
@OneToOne(() => Transaction)
|
||||
@JoinColumn({ name: 'transaction_id' })
|
||||
transaction: Transaction
|
||||
}
|
||||
@ -37,4 +37,16 @@ export class User extends BaseEntity {
|
||||
.where('hex(user.pubkey) = :pubkeyHex', { pubkeyHex })
|
||||
.getOneOrFail()
|
||||
}
|
||||
|
||||
static async getUsersIndiced(userIds: number[]): Promise<User[]> {
|
||||
const users = await this.createQueryBuilder('user')
|
||||
.select(['user.id', 'user.firstName', 'user.lastName', 'user.email'])
|
||||
.where('user.id IN (:...users)', { users: userIds })
|
||||
.getMany()
|
||||
const usersIndiced: User[] = []
|
||||
users.forEach((value) => {
|
||||
usersIndiced[value.id] = value
|
||||
})
|
||||
return usersIndiced
|
||||
}
|
||||
}
|
||||
|
||||
36
backend/src/typeorm/entity/UserTransaction.ts
Normal file
36
backend/src/typeorm/entity/UserTransaction.ts
Normal file
@ -0,0 +1,36 @@
|
||||
import { BaseEntity, Entity, PrimaryGeneratedColumn, Column } from 'typeorm'
|
||||
|
||||
@Entity('state_user_transactions')
|
||||
export class UserTransaction extends BaseEntity {
|
||||
@PrimaryGeneratedColumn()
|
||||
id: number
|
||||
|
||||
@Column({ name: 'state_user_id' })
|
||||
userId: number
|
||||
|
||||
@Column({ name: 'transaction_id' })
|
||||
transactionId: number
|
||||
|
||||
@Column({ name: 'transaction_type_id' })
|
||||
transactionTypeId: number
|
||||
|
||||
@Column({ name: 'balance', type: 'bigint' })
|
||||
balance: number
|
||||
|
||||
@Column({ name: 'balance_date', type: 'timestamp' })
|
||||
balanceDate: Date
|
||||
|
||||
static findByUserPaged(
|
||||
userId: number,
|
||||
limit: number,
|
||||
offset: number,
|
||||
order: 'ASC' | 'DESC',
|
||||
): Promise<[UserTransaction[], number]> {
|
||||
return this.createQueryBuilder('userTransaction')
|
||||
.where('userTransaction.userId = :userId', { userId })
|
||||
.orderBy('userTransaction.balanceDate', order)
|
||||
.limit(limit)
|
||||
.offset(offset)
|
||||
.getManyAndCount()
|
||||
}
|
||||
}
|
||||
@ -1,4 +1,55 @@
|
||||
export default function (amount: number, from: Date, to: Date): number {
|
||||
const decayDuration = (to.getTime() - from.getTime()) / 1000
|
||||
return amount * Math.pow(0.99999997802044727, decayDuration)
|
||||
import { Decay } from '../graphql/models/Decay'
|
||||
|
||||
function decayFormula(amount: number, durationInSeconds: number): number {
|
||||
return amount * Math.pow(0.99999997802044727, durationInSeconds)
|
||||
}
|
||||
|
||||
async function calculateDecay(amount: number, from: Date, to: Date): Promise<number> {
|
||||
// load decay start block
|
||||
const decayStartBlock = await Decay.getDecayStartBlock()
|
||||
|
||||
// if decay hasn't started yet we return input amount
|
||||
if (!decayStartBlock) return amount
|
||||
|
||||
const decayDuration = (to.getTime() - from.getTime()) / 1000
|
||||
return decayFormula(amount, decayDuration)
|
||||
}
|
||||
|
||||
async function calculateDecayWithInterval(
|
||||
amount: number,
|
||||
from: number | Date,
|
||||
to: number | Date,
|
||||
): Promise<Decay> {
|
||||
const decayStartBlock = await Decay.getDecayStartBlock()
|
||||
|
||||
const result = new Decay(undefined)
|
||||
result.balance = amount
|
||||
const fromMillis = typeof from === 'number' ? from : from.getTime()
|
||||
const toMillis = typeof to === 'number' ? to : to.getTime()
|
||||
result.decayStart = (fromMillis / 1000).toString()
|
||||
result.decayEnd = (toMillis / 1000).toString()
|
||||
|
||||
// (amount, from.getTime(), to.getTime())
|
||||
|
||||
// if no decay start block exist or decay startet after end date
|
||||
if (!decayStartBlock || decayStartBlock.received.getTime() > toMillis) {
|
||||
return result
|
||||
}
|
||||
const decayStartBlockMillis = decayStartBlock.received.getTime()
|
||||
|
||||
// if decay start date is before start date we calculate decay for full duration
|
||||
if (decayStartBlockMillis < fromMillis) {
|
||||
result.decayDuration = toMillis - fromMillis
|
||||
}
|
||||
// if decay start in between start date and end date we caculcate decay from decay start time to end date
|
||||
else {
|
||||
result.decayDuration = toMillis - decayStartBlockMillis
|
||||
result.decayStart = (decayStartBlockMillis / 1000).toString()
|
||||
}
|
||||
// js use timestamp in milliseconds but we calculate with seconds
|
||||
result.decayDuration /= 1000
|
||||
result.balance = decayFormula(amount, result.decayDuration)
|
||||
return result
|
||||
}
|
||||
|
||||
export { calculateDecay, calculateDecayWithInterval }
|
||||
|
||||
103
docu/graphics/AnachBüberweisen.drawio
Normal file
103
docu/graphics/AnachBüberweisen.drawio
Normal file
@ -0,0 +1,103 @@
|
||||
<mxfile host="65bd71144e">
|
||||
<diagram id="ZvjvITeOyjQP4YKfGS0G" name="Page-1">
|
||||
<mxGraphModel dx="923" dy="562" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="827" pageHeight="1169" math="0" shadow="0">
|
||||
<root>
|
||||
<mxCell id="0"/>
|
||||
<mxCell id="1" parent="0"/>
|
||||
<mxCell id="29" value="" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#008a00;strokeColor=#005700;fontColor=#ffffff;" vertex="1" parent="1">
|
||||
<mxGeometry x="660" y="135" width="120" height="215" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="28" value="" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#60a917;strokeColor=#2D7600;fontColor=#ffffff;" vertex="1" parent="1">
|
||||
<mxGeometry x="540" y="135" width="120" height="215" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="27" value="" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#e3c800;strokeColor=#B09500;fontColor=#000000;" vertex="1" parent="1">
|
||||
<mxGeometry x="420" y="135" width="120" height="215" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="26" value="" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#f0a30a;strokeColor=#BD7000;fontColor=#000000;" vertex="1" parent="1">
|
||||
<mxGeometry x="300" y="135" width="120" height="215" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="25" value="" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#fa6800;strokeColor=#C73500;fontColor=#000000;" vertex="1" parent="1">
|
||||
<mxGeometry x="180" y="135" width="120" height="215" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="24" value="" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#e51400;strokeColor=#B20000;fontColor=#ffffff;" vertex="1" parent="1">
|
||||
<mxGeometry x="70" y="135" width="110" height="215" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="5" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=1;exitY=0.5;exitDx=0;exitDy=0;fillColor=#008a00;strokeColor=#005700;jumpSize=6;endSize=6;startSize=6;strokeWidth=3;" edge="1" parent="1" source="2" target="3">
|
||||
<mxGeometry relative="1" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="6" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=1;exitY=0.5;exitDx=0;exitDy=0;entryX=0;entryY=0.5;entryDx=0;entryDy=0;fillColor=#008a00;strokeColor=#005700;strokeWidth=3;" edge="1" parent="1" source="2" target="4">
|
||||
<mxGeometry relative="1" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="2" value="1.5.0<br>Register" style="whiteSpace=wrap;html=1;aspect=fixed;fillColor=#2A2A2A;strokeColor=#F0F0F0;fontColor=#F0F0F0;" vertex="1" parent="1">
|
||||
<mxGeometry x="80" y="200" width="80" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="11" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=1;exitY=0.5;exitDx=0;exitDy=0;entryX=0;entryY=0.5;entryDx=0;entryDy=0;" edge="1" parent="1" source="3" target="7">
|
||||
<mxGeometry relative="1" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="12" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=1;exitY=0.5;exitDx=0;exitDy=0;entryX=0;entryY=0.5;entryDx=0;entryDy=0;strokeWidth=3;fillColor=#60a917;strokeColor=#2D7600;" edge="1" parent="1" source="3" target="10">
|
||||
<mxGeometry relative="1" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="3" value="1.6.0<br>Kubernetes" style="whiteSpace=wrap;html=1;aspect=fixed;fillColor=#2A2A2A;strokeColor=#F0F0F0;fontColor=#F0F0F0;" vertex="1" parent="1">
|
||||
<mxGeometry x="200" y="150" width="80" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="13" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=1;exitY=0.5;exitDx=0;exitDy=0;entryX=0;entryY=0.5;entryDx=0;entryDy=0;strokeWidth=3;fillColor=#60a917;strokeColor=#2D7600;" edge="1" parent="1" source="4" target="7">
|
||||
<mxGeometry relative="1" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="14" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=1;exitY=0.5;exitDx=0;exitDy=0;entryX=0;entryY=0.5;entryDx=0;entryDy=0;strokeWidth=3;fillColor=#60a917;strokeColor=#2D7600;" edge="1" parent="1" source="4" target="10">
|
||||
<mxGeometry relative="1" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="4" value="1.6.0<br>Overview<br>Page" style="whiteSpace=wrap;html=1;aspect=fixed;fillColor=#2A2A2A;strokeColor=#F0F0F0;fontColor=#F0F0F0;" vertex="1" parent="1">
|
||||
<mxGeometry x="200" y="250" width="80" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="16" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=1;exitY=0.5;exitDx=0;exitDy=0;entryX=0;entryY=0.5;entryDx=0;entryDy=0;strokeWidth=3;fillColor=#e3c800;strokeColor=#B09500;" edge="1" parent="1" source="7" target="15">
|
||||
<mxGeometry relative="1" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="7" value="1.7.0<br>Federation" style="whiteSpace=wrap;html=1;aspect=fixed;fillColor=#2A2A2A;strokeColor=#F0F0F0;fontColor=#F0F0F0;" vertex="1" parent="1">
|
||||
<mxGeometry x="320" y="150" width="80" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="17" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=1;exitY=0.5;exitDx=0;exitDy=0;entryX=0;entryY=0.5;entryDx=0;entryDy=0;strokeWidth=3;fillColor=#e3c800;strokeColor=#B09500;" edge="1" parent="1" source="10" target="15">
|
||||
<mxGeometry relative="1" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="10" value="1.7.0<br>Statistics(?)" style="whiteSpace=wrap;html=1;aspect=fixed;fillColor=#2A2A2A;strokeColor=#F0F0F0;fontColor=#F0F0F0;" vertex="1" parent="1">
|
||||
<mxGeometry x="320" y="250" width="80" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="20" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=1;exitY=0.5;exitDx=0;exitDy=0;entryX=0;entryY=0.5;entryDx=0;entryDy=0;dashed=1;fillColor=#f0a30a;strokeColor=#BD7000;strokeWidth=3;" edge="1" parent="1" source="15" target="18">
|
||||
<mxGeometry relative="1" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="15" value="1.8.0<br>Activities" style="whiteSpace=wrap;html=1;aspect=fixed;fillColor=#2A2A2A;strokeColor=#F0F0F0;fontColor=#F0F0F0;" vertex="1" parent="1">
|
||||
<mxGeometry x="440" y="200" width="80" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="21" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=1;exitY=0.5;exitDx=0;exitDy=0;entryX=0;entryY=0.5;entryDx=0;entryDy=0;dashed=1;fillColor=#fa6800;strokeColor=#C73500;strokeWidth=3;" edge="1" parent="1" source="18" target="19">
|
||||
<mxGeometry relative="1" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="18" value="1.X.0<br>???" style="whiteSpace=wrap;html=1;aspect=fixed;fillColor=#2A2A2A;strokeColor=#F0F0F0;fontColor=#F0F0F0;" vertex="1" parent="1">
|
||||
<mxGeometry x="560" y="200" width="80" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="19" value="Von A nach B überweisen&nbsp;" style="whiteSpace=wrap;html=1;aspect=fixed;fillColor=#2A2A2A;strokeColor=#F0F0F0;fontColor=#F0F0F0;" vertex="1" parent="1">
|
||||
<mxGeometry x="680" y="200" width="80" height="80" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="30" value="The background color symbolizes how far away we are from the goal. The arrow color symbolizes how sure we can be that this will be the course of action" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontColor=#F0F0F0;" vertex="1" parent="1">
|
||||
<mxGeometry x="70" y="640" width="330" height="50" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="31" value="Our current release" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=top;whiteSpace=wrap;rounded=0;fontColor=#F0F0F0;" vertex="1" parent="1">
|
||||
<mxGeometry x="70" y="360" width="110" height="240" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="32" value="The Release 1.6.0 will make sure we can actually deploy multiple instances of our Software.<br>Additionally we will create the Overview Page in the Frontend" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=top;whiteSpace=wrap;rounded=0;fontColor=#F0F0F0;" vertex="1" parent="1">
|
||||
<mxGeometry x="185" y="360" width="110" height="240" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="33" value="The Release 1.7.0 will focus on the Federation. Maybe we will be able to send Coins at this stage, but its likely this will be done in the next steps. Here we most likely get to know the other communties only.<br>In the Frontend we consider to show some statisticts with the amount of known Communities" style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=top;whiteSpace=wrap;rounded=0;fontColor=#F0F0F0;" vertex="1" parent="1">
|
||||
<mxGeometry x="305" y="361" width="110" height="239" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="35" value="The Release 1.8.0 will implement Activities in order to allow other communities to actually create GDD." style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=top;whiteSpace=wrap;rounded=0;fontColor=#F0F0F0;" vertex="1" parent="1">
|
||||
<mxGeometry x="425" y="360" width="110" height="240" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="36" value="More Steps might be needed to have the usable full functionallity of sending from A to B." style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=top;whiteSpace=wrap;rounded=0;fontColor=#F0F0F0;" vertex="1" parent="1">
|
||||
<mxGeometry x="545" y="360" width="110" height="240" as="geometry"/>
|
||||
</mxCell>
|
||||
<mxCell id="37" value="Be aware that we might decide to split some Releases into two. Especially the Federation Release might need a followup Release in oder to actually send coins, since this will not be part of the Federation itself." style="text;html=1;strokeColor=none;fillColor=none;align=left;verticalAlign=middle;whiteSpace=wrap;rounded=0;fontColor=#F0F0F0;" vertex="1" parent="1">
|
||||
<mxGeometry x="70" y="710" width="330" height="50" as="geometry"/>
|
||||
</mxCell>
|
||||
</root>
|
||||
</mxGraphModel>
|
||||
</diagram>
|
||||
</mxfile>
|
||||
BIN
docu/graphics/AnachBüberweisen.png
Normal file
BIN
docu/graphics/AnachBüberweisen.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 100 KiB |
@ -1,5 +1,3 @@
|
||||
LOGIN_API_URL=http://localhost/login_api/
|
||||
COMMUNITY_API_URL=http://localhost/api/
|
||||
ALLOW_REGISTER=true
|
||||
GRAPHQL_URI=http://localhost:4000/graphql
|
||||
//BUILD_COMMIT=0000000
|
||||
@ -9,6 +9,8 @@
|
||||
containsUppercaseCharacter: true,
|
||||
containsNumericCharacter: true,
|
||||
atLeastEightCharactera: true,
|
||||
atLeastOneSpecialCharater: true,
|
||||
noWhitespaceCharacters: true,
|
||||
}"
|
||||
:label="register ? $t('form.password') : $t('form.password_new')"
|
||||
:showAllErrors="true"
|
||||
|
||||
@ -14,7 +14,6 @@ export default {
|
||||
return {
|
||||
selected: null,
|
||||
options: [
|
||||
{ value: null, text: this.$t('select_language') },
|
||||
{ value: 'de', text: this.$t('languages.de') },
|
||||
{ value: 'en', text: this.$t('languages.en') },
|
||||
],
|
||||
|
||||
@ -18,8 +18,6 @@ const environment = {
|
||||
}
|
||||
|
||||
const server = {
|
||||
LOGIN_API_URL: process.env.LOGIN_API_URL || 'http://localhost/login_api/',
|
||||
COMMUNITY_API_URL: process.env.COMMUNITY_API_URL || 'http://localhost/api/',
|
||||
GRAPHQL_URI: process.env.GRAPHQL_URI || 'http://localhost:4000/graphql',
|
||||
}
|
||||
|
||||
|
||||
@ -45,21 +45,14 @@
|
||||
"amount": "Betrag",
|
||||
"at": "am",
|
||||
"cancel": "Abbrechen",
|
||||
"change": "ändern",
|
||||
"change-name": "Name ändern",
|
||||
"change-password": "Passwort ändern",
|
||||
"changeLanguage": "Sprache ändern",
|
||||
"change_username_info": "Einmal gespeichert, kann der Username ncht mehr geändert werden!",
|
||||
"close": "schließen",
|
||||
"date": "Datum",
|
||||
"description": "Beschreibung",
|
||||
"edit": "bearbeiten",
|
||||
"email": "E-Mail",
|
||||
"email_repeat": "eMail wiederholen",
|
||||
"firstname": "Vorname",
|
||||
"from": "von",
|
||||
"lastname": "Nachname",
|
||||
"max_gdd_info": "Maximale anzahl GDD zum versenden erreicht!",
|
||||
"memo": "Nachricht",
|
||||
"message": "Nachricht",
|
||||
"password": "Passwort",
|
||||
@ -81,7 +74,6 @@
|
||||
"time": "Zeit",
|
||||
"to": "bis",
|
||||
"to1": "an",
|
||||
"username": "Username",
|
||||
"validation": {
|
||||
"gddSendAmount": "Das Feld {_field_} muss eine Zahl zwischen {min} und {max} mit höchstens zwei Nachkommastellen sein",
|
||||
"is-not": "Du kannst dir selbst keine Gradidos überweisen",
|
||||
@ -106,29 +98,40 @@
|
||||
},
|
||||
"imprint": "Impressum",
|
||||
"language": "Sprache",
|
||||
"languages": {
|
||||
"de": "Deutsch",
|
||||
"en": "English",
|
||||
"success": "Deine Sprache wurde erfolgreich geändert."
|
||||
},
|
||||
"login": "Anmeldung",
|
||||
"logout": "Abmelden",
|
||||
"members_area": "Mitgliederbereich",
|
||||
"message": "hallo gradido !!",
|
||||
"privacy_policy": "Datenschutzerklärung",
|
||||
"reset": "Passwort zurücksetzen",
|
||||
"reset-password": {
|
||||
"not-authenticated": "Leider konnten wir dich nicht authentifizieren. Bitte wende dich an den Support.",
|
||||
"text": "Jetzt kannst du ein neues Passwort speichern, mit dem du dich zukünftig in der Gradido-App anmelden kannst.",
|
||||
"title": "Passwort zurücksetzen"
|
||||
},
|
||||
"select_language": "Bitte wähle eine Sprache für die App und Newsletter",
|
||||
"send": "Senden",
|
||||
"setting": {
|
||||
"changeNewsletter": "Newsletter Status ändern",
|
||||
"newsletter": "Newsletter",
|
||||
"newsletterFalse": "Du bist aus Newslettersystem ausgetragen.",
|
||||
"newsletterTrue": "Du bist im Newslettersystem eingetraten."
|
||||
"settings": {
|
||||
"language": {
|
||||
"changeLanguage": "Sprache ändern",
|
||||
"de": "Deutsch",
|
||||
"en": "English",
|
||||
"select_language": "Bitte wähle eine Sprache.",
|
||||
"success": "Deine Sprache wurde erfolgreich geändert."
|
||||
},
|
||||
"name": {
|
||||
"change-name": "Name ändern",
|
||||
"change-success": "Dein Name wurde erfolgreich geändert."
|
||||
},
|
||||
"newsletter": {
|
||||
"newsletter": "Newsletter",
|
||||
"newsletterFalse": "Du bist aus Newslettersystem ausgetragen.",
|
||||
"newsletterTrue": "Du bist im Newslettersystem eingetraten."
|
||||
},
|
||||
"password": {
|
||||
"change-password": "Passwort ändern",
|
||||
"forgot_pwd": "Passwort vergessen?",
|
||||
"reset": "Passwort zurücksetzen",
|
||||
"reset-password": {
|
||||
"not-authenticated": "Leider konnten wir dich nicht authentifizieren. Bitte wende dich an den Support.",
|
||||
"text": "Jetzt kannst du ein neues Passwort speichern, mit dem du dich zukünftig in der Gradido-App anmelden kannst."
|
||||
},
|
||||
"send_now": "Jetzt senden",
|
||||
"subtitle": "Wenn du dein Passwort vergessen hast, kannst du es hier zurücksetzen."
|
||||
}
|
||||
},
|
||||
"signup": "Registrieren",
|
||||
"site": {
|
||||
@ -143,34 +146,21 @@
|
||||
},
|
||||
"login": {
|
||||
"community": "Tausend Dank, weil du bei uns bist!",
|
||||
"forgot_pwd": "Passwort vergessen?",
|
||||
"new_wallet": "Neues Konto erstellen",
|
||||
"remember": "Passwort merken",
|
||||
"signin": "Anmelden"
|
||||
},
|
||||
"navbar": {
|
||||
"activity": "Aktivität",
|
||||
"my-profil": "Mein Profil",
|
||||
"settings": "Einstellungen",
|
||||
"support": "Support"
|
||||
},
|
||||
"overview": {
|
||||
"account_overview": "Kontoübersicht",
|
||||
"add_work": "neuer Gemeinschaftsbeitrag",
|
||||
"send_gradido": "Gradido versenden",
|
||||
"since_last_month": "seid letzten Monat"
|
||||
},
|
||||
"password": {
|
||||
"send_now": "Jetzt senden",
|
||||
"subtitle": "Wenn du dein Passwort vergessen hast, kannst du es hier zurücksetzen.",
|
||||
"title": "Passwort zurücksetzen"
|
||||
},
|
||||
"signup": {
|
||||
"agree": "Ich stimme der <a href='https://gradido.net/de/datenschutz/' target='_blank' >Datenschutzerklärung</a> zu.",
|
||||
"dont_match": "Die Passwörter stimmen nicht überein.",
|
||||
"lowercase": "Ein Kleinbuchstabe erforderlich.",
|
||||
"minimum": "Mindestens 8 Zeichen.",
|
||||
"no-whitespace": "Keine Leerzeichen und Tabulatoren",
|
||||
"one_number": "Eine Zahl erforderlich.",
|
||||
"special-char": "Ein Sonderzeichen erforderlich (z.B. _ oder ä)",
|
||||
"subtitle": "Werde Teil der Gemeinschaft!",
|
||||
"title": "Erstelle dein Gradido-Konto",
|
||||
"uppercase": "Ein Großbuchstabe erforderlich."
|
||||
@ -192,6 +182,5 @@
|
||||
"show_all": "Alle <strong>{count}</strong> Transaktionen ansehen"
|
||||
},
|
||||
"transactions": "Transaktionen",
|
||||
"welcome": "Willkommen!",
|
||||
"whitepaper": "Whitepaper"
|
||||
}
|
||||
|
||||
@ -45,21 +45,14 @@
|
||||
"amount": "Amount",
|
||||
"at": "at",
|
||||
"cancel": "Cancel",
|
||||
"change": "change",
|
||||
"change-name": "Change name",
|
||||
"change-password": "Change password",
|
||||
"changeLanguage": "Change language",
|
||||
"change_username_info": "Once saved, the username cannot be changed again!",
|
||||
"close": "Close",
|
||||
"date": "Date",
|
||||
"description": "Description",
|
||||
"edit": "Edit",
|
||||
"email": "Email",
|
||||
"email_repeat": "Repeat Email",
|
||||
"firstname": "Firstname",
|
||||
"from": "from",
|
||||
"lastname": "Lastname",
|
||||
"max_gdd_info": "Maximum number of GDDs to be sent has been reached!",
|
||||
"memo": "Message",
|
||||
"message": "Message",
|
||||
"password": "Password",
|
||||
@ -81,7 +74,6 @@
|
||||
"time": "Time",
|
||||
"to": "to",
|
||||
"to1": "to",
|
||||
"username": "Username",
|
||||
"validation": {
|
||||
"gddSendAmount": "The {_field_} field must be a number between {min} and {max} with at most two digits",
|
||||
"is-not": "You cannot send Gradidos to yourself",
|
||||
@ -106,29 +98,40 @@
|
||||
},
|
||||
"imprint": "Legal notice",
|
||||
"language": "Language",
|
||||
"languages": {
|
||||
"de": "Deutsch",
|
||||
"en": "English",
|
||||
"success": "Your language has been successfully updated."
|
||||
},
|
||||
"login": "Login",
|
||||
"logout": "Logout",
|
||||
"members_area": "Member's area",
|
||||
"message": "hello gradido !!",
|
||||
"privacy_policy": "Privacy policy",
|
||||
"reset": "Reset password",
|
||||
"reset-password": {
|
||||
"not-authenticated": "Unfortunately we could not authenticate you. Please contact the support.",
|
||||
"text": "Now you can save a new password to login to the Gradido-App in the future.",
|
||||
"title": "Reset Password"
|
||||
},
|
||||
"select_language": "Please choose a language for the app and newsletter",
|
||||
"send": "Send",
|
||||
"setting": {
|
||||
"changeNewsletter": "Newsletter status change",
|
||||
"newsletter": "Newsletter",
|
||||
"newsletterFalse": "You are unsubscribed from newsletter system.",
|
||||
"newsletterTrue": "You are subscribed to newsletter system."
|
||||
"settings": {
|
||||
"language": {
|
||||
"changeLanguage": "Change language",
|
||||
"de": "Deutsch",
|
||||
"en": "English",
|
||||
"select_language": "Please choose a language.",
|
||||
"success": "Your language has been successfully updated."
|
||||
},
|
||||
"name": {
|
||||
"change-name": "Change name",
|
||||
"change-success": "Your name has been successfully changed."
|
||||
},
|
||||
"newsletter": {
|
||||
"newsletter": "Newsletter",
|
||||
"newsletterFalse": "You are unsubscribed from newsletter system.",
|
||||
"newsletterTrue": "You are subscribed to newsletter system."
|
||||
},
|
||||
"password": {
|
||||
"change-password": "Change password",
|
||||
"forgot_pwd": "Forgot password?",
|
||||
"reset": "Reset password",
|
||||
"reset-password": {
|
||||
"not-authenticated": "Unfortunately we could not authenticate you. Please contact the support.",
|
||||
"text": "Now you can save a new password to login to the Gradido-App in the future."
|
||||
},
|
||||
"send_now": "Send now",
|
||||
"subtitle": "If you have forgotten your password, you can reset it here."
|
||||
}
|
||||
},
|
||||
"signup": "Sign up",
|
||||
"site": {
|
||||
@ -143,34 +146,21 @@
|
||||
},
|
||||
"login": {
|
||||
"community": "A thousand thanks for being with us!",
|
||||
"forgot_pwd": "Forgot password?",
|
||||
"new_wallet": "Create new account",
|
||||
"remember": "Remember password",
|
||||
"signin": "Sign in"
|
||||
},
|
||||
"navbar": {
|
||||
"activity": "Activity",
|
||||
"my-profil": "My profile",
|
||||
"settings": "Settings",
|
||||
"support": "Support"
|
||||
},
|
||||
"overview": {
|
||||
"account_overview": "Account overview",
|
||||
"add_work": "New Community Contribution",
|
||||
"send_gradido": "Send Gradido",
|
||||
"since_last_month": "since last month"
|
||||
},
|
||||
"password": {
|
||||
"send_now": "Send now",
|
||||
"subtitle": "If you have forgotten your password, you can reset it here.",
|
||||
"title": "Reset password"
|
||||
},
|
||||
"signup": {
|
||||
"agree": "I agree to the <a href='https://gradido.net/en/datenschutz/' target='_blank' > privacy policy</a>.",
|
||||
"dont_match": "Passwords don't match.",
|
||||
"lowercase": "One lowercase letter required.",
|
||||
"minimum": "8 characters minimum.",
|
||||
"no-whitespace": "No white spaces and tabs",
|
||||
"one_number": "One number required.",
|
||||
"special-char": "One special character required (e.g. _ or ä)",
|
||||
"subtitle": "Become a part of the community!",
|
||||
"title": "Create your Gradido account",
|
||||
"uppercase": "One uppercase letter required."
|
||||
@ -192,6 +182,5 @@
|
||||
"show_all": "View all <strong>{count}</strong> transactions."
|
||||
},
|
||||
"transactions": "Transactions",
|
||||
"welcome": "Welcome!",
|
||||
"whitepaper": "Whitepaper"
|
||||
}
|
||||
|
||||
@ -112,6 +112,20 @@ export const loadAllRules = (i18nCallback) => {
|
||||
message: (_, values) => i18nCallback.t('site.signup.minimum', values),
|
||||
})
|
||||
|
||||
extend('atLeastOneSpecialCharater', {
|
||||
validate(value) {
|
||||
return !!value.match(/[^a-zA-Z0-9 \t\n\r]/)
|
||||
},
|
||||
message: (_, values) => i18nCallback.t('site.signup.special-char', values),
|
||||
})
|
||||
|
||||
extend('noWhitespaceCharacters', {
|
||||
validate(value) {
|
||||
return !value.match(/[ \t\n\r]+/)
|
||||
},
|
||||
message: (_, values) => i18nCallback.t('site.signup.no-whitespace', values),
|
||||
})
|
||||
|
||||
extend('samePassword', {
|
||||
validate(value, [pwd]) {
|
||||
return value === pwd
|
||||
|
||||
@ -32,6 +32,9 @@ describe('DashboardLayoutGdd', () => {
|
||||
},
|
||||
$router: {
|
||||
push: routerPushMock,
|
||||
currentRoute: {
|
||||
path: '/overview',
|
||||
},
|
||||
},
|
||||
$toasted: {
|
||||
error: toasterMock,
|
||||
@ -143,21 +146,23 @@ describe('DashboardLayoutGdd', () => {
|
||||
it('redirects to login page', () => {
|
||||
expect(routerPushMock).toBeCalledWith('/login')
|
||||
})
|
||||
})
|
||||
|
||||
describe('logout fails', () => {
|
||||
beforeEach(() => {
|
||||
apolloMock.mockRejectedValue({
|
||||
message: 'error',
|
||||
})
|
||||
describe('logout fails', () => {
|
||||
beforeEach(async () => {
|
||||
apolloMock.mockRejectedValue({
|
||||
message: 'error',
|
||||
})
|
||||
await wrapper.findComponent({ name: 'sidebar' }).vm.$emit('logout')
|
||||
await flushPromises()
|
||||
})
|
||||
|
||||
it('dispatches logout to store', () => {
|
||||
expect(storeDispatchMock).toBeCalledWith('logout')
|
||||
})
|
||||
it('dispatches logout to store', () => {
|
||||
expect(storeDispatchMock).toBeCalledWith('logout')
|
||||
})
|
||||
|
||||
it('redirects to login page', () => {
|
||||
expect(routerPushMock).toBeCalledWith('/login')
|
||||
})
|
||||
it('redirects to login page', () => {
|
||||
expect(routerPushMock).toBeCalledWith('/login')
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
@ -101,7 +101,7 @@ export default {
|
||||
.catch(() => {
|
||||
this.$sidebar.displaySidebar(false)
|
||||
this.$store.dispatch('logout')
|
||||
this.$router.push('/login')
|
||||
if (this.$router.currentRoute.path !== '/login') this.$router.push('/login')
|
||||
})
|
||||
},
|
||||
async updateTransactions(pagination) {
|
||||
|
||||
@ -54,7 +54,7 @@ describe('GddTransactionList', () => {
|
||||
await wrapper.setProps({
|
||||
transactions: [
|
||||
{
|
||||
balance: '19.93',
|
||||
balance: 19.93,
|
||||
date: '2021-05-25T17:38:13+00:00',
|
||||
memo: 'Alles Gute zum Geburtstag',
|
||||
name: 'Bob der Baumeister',
|
||||
@ -63,7 +63,7 @@ describe('GddTransactionList', () => {
|
||||
decay: { balance: '0.5' },
|
||||
},
|
||||
{
|
||||
balance: '1000',
|
||||
balance: 1000,
|
||||
date: '2021-04-29T15:34:49+00:00',
|
||||
memo: 'Gut das du da bist!',
|
||||
name: 'Gradido Akademie',
|
||||
@ -71,7 +71,7 @@ describe('GddTransactionList', () => {
|
||||
type: 'creation',
|
||||
},
|
||||
{
|
||||
balance: '314.98',
|
||||
balance: 314.98,
|
||||
date: '2021-04-29T17:26:40+00:00',
|
||||
memo: 'Für das Fahrrad!',
|
||||
name: 'Jan Ulrich',
|
||||
|
||||
@ -39,11 +39,11 @@ describe('ForgotPassword', () => {
|
||||
})
|
||||
|
||||
it('has a title', () => {
|
||||
expect(wrapper.find('h1').text()).toEqual('site.password.title')
|
||||
expect(wrapper.find('h1').text()).toEqual('settings.password.reset')
|
||||
})
|
||||
|
||||
it('has a subtitle', () => {
|
||||
expect(wrapper.find('p.text-lead').text()).toEqual('site.password.subtitle')
|
||||
expect(wrapper.find('p.text-lead').text()).toEqual('settings.password.subtitle')
|
||||
})
|
||||
|
||||
describe('back button', () => {
|
||||
|
||||
@ -5,8 +5,8 @@
|
||||
<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('site.password.title') }}</h1>
|
||||
<p class="text-lead">{{ $t('site.password.subtitle') }}</p>
|
||||
<h1>{{ $t('settings.password.reset') }}</h1>
|
||||
<p class="text-lead">{{ $t('settings.password.subtitle') }}</p>
|
||||
</b-col>
|
||||
</b-row>
|
||||
</div>
|
||||
@ -22,7 +22,7 @@
|
||||
<input-email v-model="form.email"></input-email>
|
||||
<div class="text-center">
|
||||
<b-button type="submit" variant="primary">
|
||||
{{ $t('site.password.send_now') }}
|
||||
{{ $t('settings.password.send_now') }}
|
||||
</b-button>
|
||||
</div>
|
||||
</b-form>
|
||||
|
||||
@ -71,7 +71,7 @@ describe('Login', () => {
|
||||
describe('links', () => {
|
||||
it('has a link "Forgot Password?"', () => {
|
||||
expect(wrapper.findAllComponents(RouterLinkStub).at(0).text()).toEqual(
|
||||
'site.login.forgot_pwd',
|
||||
'settings.password.forgot_pwd',
|
||||
)
|
||||
})
|
||||
|
||||
|
||||
@ -40,7 +40,7 @@
|
||||
<b-row class="mt-3">
|
||||
<b-col cols="6">
|
||||
<router-link to="/password">
|
||||
{{ $t('site.login.forgot_pwd') }}
|
||||
{{ $t('settings.password.forgot_pwd') }}
|
||||
</router-link>
|
||||
</b-col>
|
||||
<b-col cols="6" class="text-right" v-show="allowRegister">
|
||||
|
||||
@ -25,7 +25,7 @@ describe('Register', () => {
|
||||
$store: {
|
||||
state: {
|
||||
email: 'peter@lustig.de',
|
||||
language: null,
|
||||
language: 'en',
|
||||
},
|
||||
},
|
||||
}
|
||||
@ -55,11 +55,11 @@ describe('Register', () => {
|
||||
|
||||
describe('links', () => {
|
||||
it('has a link "Back"', () => {
|
||||
expect(wrapper.findAllComponents(RouterLinkStub).at(0).text()).toEqual('back')
|
||||
expect(wrapper.find('.test-button-back').text()).toEqual('back')
|
||||
})
|
||||
|
||||
it('links to /login when clicking "Back"', () => {
|
||||
expect(wrapper.findAllComponents(RouterLinkStub).at(0).props().to).toBe('/login')
|
||||
expect(wrapper.find('.test-button-back').props().to).toBe('/login')
|
||||
})
|
||||
})
|
||||
|
||||
@ -89,17 +89,17 @@ describe('Register', () => {
|
||||
it('has Language selected field', () => {
|
||||
expect(wrapper.find('.selectedLanguage').exists()).toBeTruthy()
|
||||
})
|
||||
it('selected Language value de', async () => {
|
||||
it('selects Language value en', async () => {
|
||||
wrapper.find('.selectedLanguage').findAll('option').at(1).setSelected()
|
||||
expect(wrapper.find('.selectedLanguage').element.value).toBe('de')
|
||||
expect(wrapper.find('.selectedLanguage').element.value).toBe('en')
|
||||
})
|
||||
|
||||
it('has 1 checkbox input fields', () => {
|
||||
expect(wrapper.find('#registerCheckbox').exists()).toBeTruthy()
|
||||
})
|
||||
|
||||
it('has no submit button when not completely filled', () => {
|
||||
expect(wrapper.find('button[type="submit"]').exists()).toBe(false)
|
||||
it('has disabled submit button when not completely filled', () => {
|
||||
expect(wrapper.find('button[type="submit"]').attributes('disabled')).toBe('disabled')
|
||||
})
|
||||
|
||||
it('displays a message that Email is required', async () => {
|
||||
@ -127,70 +127,20 @@ describe('Register', () => {
|
||||
})
|
||||
})
|
||||
|
||||
describe('resetForm', () => {
|
||||
beforeEach(() => {
|
||||
wrapper.find('#registerFirstname').setValue('Max')
|
||||
wrapper.find('#registerLastname').setValue('Mustermann')
|
||||
wrapper.find('#Email-input-field').setValue('max.mustermann@gradido.net')
|
||||
wrapper.find('input[name="form.password"]').setValue('Aa123456')
|
||||
wrapper.find('input[name="form.passwordRepeat"]').setValue('Aa123456')
|
||||
wrapper.find('.language-switch-select').findAll('option').at(1).setSelected()
|
||||
wrapper.find('input[name="site.signup.agree"]').setChecked(true)
|
||||
})
|
||||
|
||||
it('reset selected value language', async () => {
|
||||
await wrapper.find('button.ml-2').trigger('click')
|
||||
await flushPromises()
|
||||
expect(wrapper.find('.language-switch-select').element.value).toBe(undefined)
|
||||
})
|
||||
|
||||
it('resets the firstName field after clicking the reset button', async () => {
|
||||
await wrapper.find('button.ml-2').trigger('click')
|
||||
await flushPromises()
|
||||
expect(wrapper.find('#registerFirstname').element.value).toBe('')
|
||||
})
|
||||
|
||||
it('resets the lastName field after clicking the reset button', async () => {
|
||||
await wrapper.find('button.ml-2').trigger('click')
|
||||
await flushPromises()
|
||||
expect(wrapper.find('#registerLastname').element.value).toBe('')
|
||||
})
|
||||
|
||||
it('resets the email field after clicking the reset button', async () => {
|
||||
await wrapper.find('button.ml-2').trigger('click')
|
||||
await flushPromises()
|
||||
expect(wrapper.find('#Email-input-field').element.value).toBe('')
|
||||
})
|
||||
|
||||
it.skip('resets the password field after clicking the reset button', async () => {
|
||||
await wrapper.find('button.ml-2').trigger('click')
|
||||
await flushPromises()
|
||||
expect(wrapper.find('input[name="form.password"]').element.value).toBe('')
|
||||
})
|
||||
|
||||
it.skip('resets the passwordRepeat field after clicking the reset button', async () => {
|
||||
await wrapper.find('button.ml-2').trigger('click')
|
||||
await flushPromises()
|
||||
expect(wrapper.find('input[name="form.passwordRepeat"]').element.value).toBe('')
|
||||
})
|
||||
|
||||
it('resets the firstName field after clicking the reset button', async () => {
|
||||
await wrapper.find('button.ml-2').trigger('click')
|
||||
await flushPromises()
|
||||
expect(wrapper.find('input[name="site.signup.agree"]').props.checked).not.toBeTruthy()
|
||||
})
|
||||
})
|
||||
|
||||
describe('API calls', () => {
|
||||
beforeEach(() => {
|
||||
wrapper.find('#registerFirstname').setValue('Max')
|
||||
wrapper.find('#registerLastname').setValue('Mustermann')
|
||||
wrapper.find('#Email-input-field').setValue('max.mustermann@gradido.net')
|
||||
wrapper.find('input[name="form.password"]').setValue('Aa123456')
|
||||
wrapper.find('input[name="form.passwordRepeat"]').setValue('Aa123456')
|
||||
wrapper.find('input[name="form.password"]').setValue('Aa123456_')
|
||||
wrapper.find('input[name="form.passwordRepeat"]').setValue('Aa123456_')
|
||||
wrapper.find('.language-switch-select').findAll('option').at(1).setSelected()
|
||||
})
|
||||
|
||||
it('has enabled submit button when completely filled', () => {
|
||||
expect(wrapper.find('button[type="submit"]').attributes('disabled')).toBe('disabled')
|
||||
})
|
||||
|
||||
describe('server sends back error', () => {
|
||||
beforeEach(async () => {
|
||||
registerUserMutationMock.mockRejectedValue({ message: 'Ouch!' })
|
||||
@ -234,8 +184,8 @@ describe('Register', () => {
|
||||
email: 'max.mustermann@gradido.net',
|
||||
firstName: 'Max',
|
||||
lastName: 'Mustermann',
|
||||
password: 'Aa123456',
|
||||
language: 'de',
|
||||
password: 'Aa123456_',
|
||||
language: 'en',
|
||||
},
|
||||
}),
|
||||
)
|
||||
|
||||
@ -116,13 +116,19 @@
|
||||
</span>
|
||||
</b-alert>
|
||||
|
||||
<div
|
||||
class="text-center"
|
||||
v-if="namesFilled && emailFilled && form.agree && languageFilled"
|
||||
>
|
||||
<div class="text-center">
|
||||
<div class="text-center">
|
||||
<b-button class="ml-2" @click="resetForm()">{{ $t('form.reset') }}</b-button>
|
||||
<b-button type="submit" variant="primary">{{ $t('signup') }}</b-button>
|
||||
<b-button class="ml-2 test-button-back" to="/login">
|
||||
{{ $t('back') }}
|
||||
</b-button>
|
||||
|
||||
<b-button
|
||||
:disabled="!(namesFilled && emailFilled && form.agree && languageFilled)"
|
||||
type="submit"
|
||||
variant="primary"
|
||||
>
|
||||
{{ $t('signup') }}
|
||||
</b-button>
|
||||
</div>
|
||||
</div>
|
||||
</b-form>
|
||||
@ -131,9 +137,6 @@
|
||||
</b-card>
|
||||
</b-col>
|
||||
</b-row>
|
||||
<div class="text-center py-lg-4">
|
||||
<router-link to="/login" class="mt-3">{{ $t('back') }}</router-link>
|
||||
</div>
|
||||
</b-container>
|
||||
</div>
|
||||
</template>
|
||||
@ -172,22 +175,6 @@ export default {
|
||||
getValidationState({ dirty, validated, valid = null }) {
|
||||
return dirty || validated ? valid : null
|
||||
},
|
||||
resetForm() {
|
||||
this.form = {
|
||||
firstname: '',
|
||||
lastname: '',
|
||||
email: '',
|
||||
password: {
|
||||
password: '',
|
||||
passwordRepeat: '',
|
||||
},
|
||||
agree: false,
|
||||
}
|
||||
this.language = ''
|
||||
this.$nextTick(() => {
|
||||
this.$refs.observer.reset()
|
||||
})
|
||||
},
|
||||
async onSubmit() {
|
||||
this.$apollo
|
||||
.mutate({
|
||||
@ -238,7 +225,7 @@ export default {
|
||||
return this.form.email !== ''
|
||||
},
|
||||
languageFilled() {
|
||||
return this.language !== null && this.language !== ''
|
||||
return !!this.language
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
@ -71,8 +71,10 @@ describe('ResetPassword', () => {
|
||||
})
|
||||
|
||||
it('has a message suggesting to contact the support', () => {
|
||||
expect(wrapper.find('div.header').text()).toContain('reset-password.title')
|
||||
expect(wrapper.find('div.header').text()).toContain('reset-password.not-authenticated')
|
||||
expect(wrapper.find('div.header').text()).toContain('settings.password.reset')
|
||||
expect(wrapper.find('div.header').text()).toContain(
|
||||
'settings.password.reset-password.not-authenticated',
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
@ -99,8 +101,10 @@ describe('ResetPassword', () => {
|
||||
|
||||
describe('Register header', () => {
|
||||
it('has a welcome message', async () => {
|
||||
expect(wrapper.find('div.header').text()).toContain('reset-password.title')
|
||||
expect(wrapper.find('div.header').text()).toContain('reset-password.text')
|
||||
expect(wrapper.find('div.header').text()).toContain('settings.password.reset')
|
||||
expect(wrapper.find('div.header').text()).toContain(
|
||||
'settings.password.reset-password.text',
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
@ -140,8 +144,8 @@ describe('ResetPassword', () => {
|
||||
beforeEach(async () => {
|
||||
await wrapper.setData({ authenticated: true, sessionId: 1 })
|
||||
await wrapper.vm.$nextTick()
|
||||
await wrapper.findAll('input').at(0).setValue('Aa123456')
|
||||
await wrapper.findAll('input').at(1).setValue('Aa123456')
|
||||
await wrapper.findAll('input').at(0).setValue('Aa123456_')
|
||||
await wrapper.findAll('input').at(1).setValue('Aa123456_')
|
||||
await flushPromises()
|
||||
await wrapper.find('form').trigger('submit')
|
||||
})
|
||||
@ -169,7 +173,7 @@ describe('ResetPassword', () => {
|
||||
variables: {
|
||||
sessionId: 1,
|
||||
email: 'user@example.org',
|
||||
password: 'Aa123456',
|
||||
password: 'Aa123456_',
|
||||
},
|
||||
}),
|
||||
)
|
||||
|
||||
@ -5,13 +5,13 @@
|
||||
<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('reset-password.title') }}</h1>
|
||||
<h1>{{ $t('settings.password.reset') }}</h1>
|
||||
<div class="pb-4" v-if="!pending">
|
||||
<span v-if="authenticated">
|
||||
{{ $t('reset-password.text') }}
|
||||
{{ $t('settings.password.reset-password.text') }}
|
||||
</span>
|
||||
<span v-else>
|
||||
{{ $t('reset-password.not-authenticated') }}
|
||||
{{ $t('settings.password.reset-password.not-authenticated') }}
|
||||
</span>
|
||||
</div>
|
||||
</b-col>
|
||||
@ -29,7 +29,7 @@
|
||||
<input-password-confirmation v-model="form" :register="register" />
|
||||
<div class="text-center">
|
||||
<b-button type="submit" variant="primary" class="mt-4">
|
||||
{{ $t('reset') }}
|
||||
{{ $t('settings.password.reset') }}
|
||||
</b-button>
|
||||
</div>
|
||||
</b-form>
|
||||
|
||||
@ -139,7 +139,7 @@ describe('UserCard_FormUserData', () => {
|
||||
})
|
||||
|
||||
it('toasts a success message', () => {
|
||||
expect(toastSuccessMock).toBeCalledWith('site.profil.user-data.change-success')
|
||||
expect(toastSuccessMock).toBeCalledWith('settings.name.change-success')
|
||||
})
|
||||
|
||||
it('has an edit button again', () => {
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
<b-row class="mb-4 text-right">
|
||||
<b-col class="text-right">
|
||||
<a @click="showUserData ? (showUserData = !showUserData) : cancelEdit()">
|
||||
<span class="pointer mr-3">{{ $t('form.change-name') }}</span>
|
||||
<span class="pointer mr-3">{{ $t('settings.name.change-name') }}</span>
|
||||
<b-icon v-if="showUserData" class="pointer ml-3" icon="pencil"></b-icon>
|
||||
<b-icon v-else icon="x-circle" class="pointer ml-3" variant="danger"></b-icon>
|
||||
</a>
|
||||
@ -122,7 +122,7 @@ export default {
|
||||
this.$store.commit('lastName', this.form.lastName)
|
||||
this.$store.commit('description', this.form.description)
|
||||
this.showUserData = true
|
||||
this.$toasted.success(this.$t('site.profil.user-data.change-success'))
|
||||
this.$toasted.success(this.$t('settings.name.change-success'))
|
||||
})
|
||||
.catch((error) => {
|
||||
this.$toasted.error(error.message)
|
||||
|
||||
@ -47,7 +47,7 @@ describe('UserCard_FormUserPasswort', () => {
|
||||
})
|
||||
|
||||
it('has a change password button with text "form.change-password"', () => {
|
||||
expect(wrapper.find('a').text()).toEqual('form.change-password')
|
||||
expect(wrapper.find('a').text()).toEqual('settings.password.change-password')
|
||||
})
|
||||
|
||||
it('has a change password button with a pencil icon', () => {
|
||||
@ -105,12 +105,21 @@ describe('UserCard_FormUserPasswort', () => {
|
||||
describe('validation', () => {
|
||||
it('displays all password requirements', () => {
|
||||
const feedbackArray = wrapper.findAll('div.invalid-feedback').at(1).findAll('span')
|
||||
expect(feedbackArray).toHaveLength(5)
|
||||
expect(feedbackArray).toHaveLength(6)
|
||||
expect(feedbackArray.at(0).text()).toBe('validations.messages.required')
|
||||
expect(feedbackArray.at(1).text()).toBe('site.signup.lowercase')
|
||||
expect(feedbackArray.at(2).text()).toBe('site.signup.uppercase')
|
||||
expect(feedbackArray.at(3).text()).toBe('site.signup.one_number')
|
||||
expect(feedbackArray.at(4).text()).toBe('site.signup.minimum')
|
||||
expect(feedbackArray.at(5).text()).toBe('site.signup.special-char')
|
||||
})
|
||||
|
||||
it('displays no whitespace error when a space character is entered', async () => {
|
||||
await wrapper.findAll('input').at(1).setValue(' ')
|
||||
await flushPromises()
|
||||
const feedbackArray = wrapper.findAll('div.invalid-feedback').at(1).findAll('span')
|
||||
expect(feedbackArray).toHaveLength(7)
|
||||
expect(feedbackArray.at(6).text()).toBe('site.signup.no-whitespace')
|
||||
})
|
||||
|
||||
it('removes first message when a character is given', async () => {
|
||||
@ -125,7 +134,7 @@ describe('UserCard_FormUserPasswort', () => {
|
||||
await wrapper.findAll('input').at(1).setValue('a')
|
||||
await flushPromises()
|
||||
const feedbackArray = wrapper.findAll('div.invalid-feedback').at(1).findAll('span')
|
||||
expect(feedbackArray).toHaveLength(3)
|
||||
expect(feedbackArray).toHaveLength(4)
|
||||
expect(feedbackArray.at(0).text()).toBe('site.signup.uppercase')
|
||||
})
|
||||
|
||||
@ -133,7 +142,7 @@ describe('UserCard_FormUserPasswort', () => {
|
||||
await wrapper.findAll('input').at(1).setValue('Aa')
|
||||
await flushPromises()
|
||||
const feedbackArray = wrapper.findAll('div.invalid-feedback').at(1).findAll('span')
|
||||
expect(feedbackArray).toHaveLength(2)
|
||||
expect(feedbackArray).toHaveLength(3)
|
||||
expect(feedbackArray.at(0).text()).toBe('site.signup.one_number')
|
||||
})
|
||||
|
||||
@ -141,14 +150,22 @@ describe('UserCard_FormUserPasswort', () => {
|
||||
await wrapper.findAll('input').at(1).setValue('Aa1')
|
||||
await flushPromises()
|
||||
const feedbackArray = wrapper.findAll('div.invalid-feedback').at(1).findAll('span')
|
||||
expect(feedbackArray).toHaveLength(1)
|
||||
expect(feedbackArray).toHaveLength(2)
|
||||
expect(feedbackArray.at(0).text()).toBe('site.signup.minimum')
|
||||
})
|
||||
|
||||
it('removes all messages when all rules are fulfilled', async () => {
|
||||
it('removes the first five messages when a eight lowercase, uppercase and numeric characters are given', async () => {
|
||||
await wrapper.findAll('input').at(1).setValue('Aa123456')
|
||||
await flushPromises()
|
||||
const feedbackArray = wrapper.findAll('div.invalid-feedback').at(1).findAll('span')
|
||||
expect(feedbackArray).toHaveLength(1)
|
||||
expect(feedbackArray.at(0).text()).toBe('site.signup.special-char')
|
||||
})
|
||||
|
||||
it('removes all messages when a eight lowercase, uppercase and numeric characters are given', async () => {
|
||||
await wrapper.findAll('input').at(1).setValue('Aa123456_')
|
||||
await flushPromises()
|
||||
const feedbackArray = wrapper.findAll('div.invalid-feedback').at(1).findAll('span')
|
||||
expect(feedbackArray).toHaveLength(0)
|
||||
})
|
||||
})
|
||||
@ -164,8 +181,8 @@ describe('UserCard_FormUserPasswort', () => {
|
||||
},
|
||||
})
|
||||
await form.findAll('input').at(0).setValue('1234')
|
||||
await form.findAll('input').at(1).setValue('Aa123456')
|
||||
await form.findAll('input').at(2).setValue('Aa123456')
|
||||
await form.findAll('input').at(1).setValue('Aa123456_')
|
||||
await form.findAll('input').at(2).setValue('Aa123456_')
|
||||
await form.trigger('submit')
|
||||
await flushPromises()
|
||||
})
|
||||
@ -176,7 +193,7 @@ describe('UserCard_FormUserPasswort', () => {
|
||||
variables: {
|
||||
email: 'user@example.org',
|
||||
password: '1234',
|
||||
passwordNew: 'Aa123456',
|
||||
passwordNew: 'Aa123456_',
|
||||
},
|
||||
}),
|
||||
)
|
||||
@ -197,8 +214,8 @@ describe('UserCard_FormUserPasswort', () => {
|
||||
message: 'error',
|
||||
})
|
||||
await form.findAll('input').at(0).setValue('1234')
|
||||
await form.findAll('input').at(1).setValue('Aa123456')
|
||||
await form.findAll('input').at(2).setValue('Aa123456')
|
||||
await form.findAll('input').at(1).setValue('Aa123456_')
|
||||
await form.findAll('input').at(2).setValue('Aa123456_')
|
||||
await form.trigger('submit')
|
||||
await flushPromises()
|
||||
})
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
<b-row class="mb-4 text-right">
|
||||
<b-col class="text-right">
|
||||
<a @click="showPassword ? (showPassword = !showPassword) : cancelEdit()">
|
||||
<span class="pointer mr-3">{{ $t('form.change-password') }}</span>
|
||||
<span class="pointer mr-3">{{ $t('settings.password.change-password') }}</span>
|
||||
<b-icon v-if="showPassword" class="pointer ml-3" icon="pencil"></b-icon>
|
||||
<b-icon v-else icon="x-circle" class="pointer ml-3" variant="danger"></b-icon>
|
||||
</a>
|
||||
|
||||
@ -125,7 +125,7 @@ describe('UserCard_FormUsername', () => {
|
||||
})
|
||||
|
||||
it('toasts an success message', () => {
|
||||
expect(toastSuccessMock).toBeCalledWith('site.profil.user-data.change-success')
|
||||
expect(toastSuccessMock).toBeCalledWith('settings.name.change-success')
|
||||
})
|
||||
|
||||
it('has no edit button anymore', () => {
|
||||
|
||||
@ -98,7 +98,7 @@ export default {
|
||||
this.$store.commit('username', this.form.username)
|
||||
this.username = this.form.username
|
||||
this.showUsername = true
|
||||
this.$toasted.success(this.$t('site.profil.user-data.change-success'))
|
||||
this.$toasted.success(this.$t('settings.name.change-success'))
|
||||
})
|
||||
.catch((error) => {
|
||||
this.$toasted.error(error.message)
|
||||
|
||||
@ -3,7 +3,13 @@ import UserCardLanguage from './UserCard_Language'
|
||||
|
||||
const localVue = global.localVue
|
||||
|
||||
const mockAPIcall = jest.fn()
|
||||
const mockAPIcall = jest.fn().mockResolvedValue({
|
||||
data: {
|
||||
updateUserInfos: {
|
||||
validValues: 1,
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
const toastErrorMock = jest.fn()
|
||||
const toastSuccessMock = jest.fn()
|
||||
@ -17,6 +23,7 @@ describe('UserCard_Language', () => {
|
||||
$store: {
|
||||
state: {
|
||||
language: 'de',
|
||||
email: 'peter@lustig.de',
|
||||
},
|
||||
commit: storeCommitMock,
|
||||
},
|
||||
@ -27,6 +34,9 @@ describe('UserCard_Language', () => {
|
||||
$apollo: {
|
||||
mutate: mockAPIcall,
|
||||
},
|
||||
$i18n: {
|
||||
locale: 'de',
|
||||
},
|
||||
}
|
||||
|
||||
const Wrapper = () => {
|
||||
@ -45,5 +55,119 @@ describe('UserCard_Language', () => {
|
||||
it('has an edit icon', () => {
|
||||
expect(wrapper.find('svg.bi-pencil').exists()).toBeTruthy()
|
||||
})
|
||||
|
||||
it('has change language as text', () => {
|
||||
expect(wrapper.find('a').text()).toBe('form.changeLanguage')
|
||||
})
|
||||
|
||||
it('has no select field by default', () => {
|
||||
expect(wrapper.find('select').exists()).toBeFalsy()
|
||||
})
|
||||
|
||||
describe('edit button', () => {
|
||||
beforeEach(() => {
|
||||
wrapper.find('a').trigger('click')
|
||||
})
|
||||
|
||||
it('has no edit icon anymore', () => {
|
||||
expect(wrapper.find('svg.bi-pencil').exists()).toBeFalsy()
|
||||
})
|
||||
|
||||
it('has x-circle icon', () => {
|
||||
expect(wrapper.find('svg.bi-x-circle').exists()).toBeTruthy()
|
||||
})
|
||||
|
||||
it('has a submit button', () => {
|
||||
expect(wrapper.find('button[type="submit"]').exists()).toBeTruthy()
|
||||
})
|
||||
|
||||
it('has the submit button disbaled by default', () => {
|
||||
expect(wrapper.find('button[type="submit"]').attributes('disabled')).toBe('disabled')
|
||||
})
|
||||
|
||||
describe('change language', () => {
|
||||
it('does not enable the submit button when same language is chosen', () => {
|
||||
wrapper.findAll('option').at(1).setSelected()
|
||||
expect(wrapper.find('button[type="submit"]').attributes('disabled')).toBe('disabled')
|
||||
})
|
||||
|
||||
it('enables the submit button when other language is chosen', async () => {
|
||||
await wrapper.findAll('option').at(2).setSelected()
|
||||
expect(wrapper.find('button[type="submit"]').attributes('disabled')).toBe(undefined)
|
||||
})
|
||||
|
||||
it('updates language data in component', async () => {
|
||||
await wrapper.findAll('option').at(2).setSelected()
|
||||
expect(wrapper.vm.language).toBe('en')
|
||||
})
|
||||
|
||||
describe('cancel edit', () => {
|
||||
beforeEach(async () => {
|
||||
await wrapper.findAll('option').at(2).setSelected()
|
||||
wrapper.find('a').trigger('click')
|
||||
})
|
||||
|
||||
it('sets the language to initial value', () => {
|
||||
expect(wrapper.vm.language).toBe('de')
|
||||
})
|
||||
|
||||
it('has no select field anymore', () => {
|
||||
expect(wrapper.find('select').exists()).toBeFalsy()
|
||||
})
|
||||
})
|
||||
|
||||
describe('submit', () => {
|
||||
beforeEach(async () => {
|
||||
await wrapper.findAll('option').at(2).setSelected()
|
||||
wrapper.find('form').trigger('submit')
|
||||
})
|
||||
|
||||
describe('with success', () => {
|
||||
it('calls the API', () => {
|
||||
expect(mockAPIcall).toBeCalledWith(
|
||||
expect.objectContaining({
|
||||
variables: {
|
||||
email: 'peter@lustig.de',
|
||||
locale: 'en',
|
||||
},
|
||||
}),
|
||||
)
|
||||
})
|
||||
|
||||
it('commits new language to store', () => {
|
||||
expect(storeCommitMock).toBeCalledWith('language', 'en')
|
||||
})
|
||||
|
||||
it('changes the i18n locale', () => {
|
||||
expect(mocks.$i18n.locale).toBe('en')
|
||||
})
|
||||
|
||||
it('has no select field anymore', () => {
|
||||
expect(wrapper.find('select').exists()).toBeFalsy()
|
||||
})
|
||||
|
||||
it('toasts a success message', () => {
|
||||
expect(toastSuccessMock).toBeCalledWith('languages.success')
|
||||
})
|
||||
})
|
||||
|
||||
describe('with error', () => {
|
||||
beforeEach(() => {
|
||||
mockAPIcall.mockRejectedValue({
|
||||
message: 'Ouch!',
|
||||
})
|
||||
})
|
||||
|
||||
it('sets the language back to initial value', () => {
|
||||
expect(wrapper.vm.language).toBe('de')
|
||||
})
|
||||
|
||||
it('toasts an error message', () => {
|
||||
expect(toastErrorMock).toBeCalledWith('Ouch!')
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
<b-row class="mb-4 text-right">
|
||||
<b-col class="text-right">
|
||||
<a @click="showLanguage ? (showLanguage = !showLanguage) : cancelEdit()">
|
||||
<span class="pointer mr-3">{{ $t('form.changeLanguage') }}</span>
|
||||
<span class="pointer mr-3">{{ $t('settings.language.changeLanguage') }}</span>
|
||||
<b-icon v-if="showLanguage" class="pointer ml-3" icon="pencil"></b-icon>
|
||||
<b-icon v-else icon="x-circle" class="pointer ml-3" variant="danger"></b-icon>
|
||||
</a>
|
||||
@ -82,6 +82,7 @@ export default {
|
||||
},
|
||||
cancelEdit() {
|
||||
this.showLanguage = true
|
||||
this.language = this.$store.state.language
|
||||
},
|
||||
async onSubmit() {
|
||||
this.$apollo
|
||||
@ -97,14 +98,13 @@ export default {
|
||||
this.$i18n.locale = this.language
|
||||
localeChanged(this.language)
|
||||
this.cancelEdit()
|
||||
this.$toasted.success(this.$t('languages.success'))
|
||||
this.$toasted.success(this.$t('settings.language.success'))
|
||||
})
|
||||
.catch((error) => {
|
||||
this.language = this.$store.state.language
|
||||
this.$toasted.error(error.message)
|
||||
})
|
||||
},
|
||||
|
||||
buildTagFromLanguageString() {
|
||||
return 'languages.' + this.$store.state.language
|
||||
},
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { mount } from '@vue/test-utils'
|
||||
import UserCardNewsletter from './UserCard_Newsletter'
|
||||
import { unsubscribeNewsletter } from '../../../graphql/mutations'
|
||||
import { unsubscribeNewsletter, subscribeNewsletter } from '../../../graphql/mutations'
|
||||
|
||||
const localVue = global.localVue
|
||||
|
||||
@ -9,7 +9,6 @@ const mockAPIcall = jest.fn()
|
||||
const toastErrorMock = jest.fn()
|
||||
const toastSuccessMock = jest.fn()
|
||||
const storeCommitMock = jest.fn()
|
||||
const newsletterStateMock = jest.fn().mockReturnValue(true)
|
||||
|
||||
describe('UserCard_Newsletter', () => {
|
||||
let wrapper
|
||||
@ -20,7 +19,7 @@ describe('UserCard_Newsletter', () => {
|
||||
state: {
|
||||
language: 'de',
|
||||
email: 'peter@lustig.de',
|
||||
newsletterState: newsletterStateMock,
|
||||
newsletterState: true,
|
||||
},
|
||||
commit: storeCommitMock,
|
||||
},
|
||||
@ -50,14 +49,15 @@ describe('UserCard_Newsletter', () => {
|
||||
expect(wrapper.find('.Test-BFormCheckbox').exists()).toBeTruthy()
|
||||
})
|
||||
|
||||
describe('unsubscribe with sucess', () => {
|
||||
beforeEach(() => {
|
||||
describe('unsubscribe with success', () => {
|
||||
beforeEach(async () => {
|
||||
await wrapper.setData({ newsletterState: false })
|
||||
mockAPIcall.mockResolvedValue({
|
||||
data: {
|
||||
unsubscribeNewsletter: true,
|
||||
},
|
||||
})
|
||||
wrapper.find('input').trigger('change')
|
||||
await wrapper.find('input').trigger('change')
|
||||
})
|
||||
|
||||
it('calls the unsubscribe mutation', () => {
|
||||
@ -73,6 +73,36 @@ describe('UserCard_Newsletter', () => {
|
||||
expect(storeCommitMock).toBeCalledWith('newsletterState', false)
|
||||
})
|
||||
|
||||
it('toasts a success message', () => {
|
||||
expect(toastSuccessMock).toBeCalledWith('settings.newsletter.newsletterFalse')
|
||||
})
|
||||
})
|
||||
|
||||
describe('subscribe with success', () => {
|
||||
beforeEach(async () => {
|
||||
await wrapper.setData({ newsletterState: true })
|
||||
mockAPIcall.mockResolvedValue({
|
||||
data: {
|
||||
subscribeNewsletter: true,
|
||||
},
|
||||
})
|
||||
wrapper.find('input').trigger('change')
|
||||
})
|
||||
|
||||
it('calls the subscribe mutation', () => {
|
||||
expect(mockAPIcall).toBeCalledWith({
|
||||
mutation: subscribeNewsletter,
|
||||
variables: {
|
||||
email: 'peter@lustig.de',
|
||||
language: 'de',
|
||||
},
|
||||
})
|
||||
})
|
||||
|
||||
it('updates the store', () => {
|
||||
expect(storeCommitMock).toBeCalledWith('newsletterState', true)
|
||||
})
|
||||
|
||||
it('toasts a success message', () => {
|
||||
expect(toastSuccessMock).toBeCalledWith('setting.newsletterFalse')
|
||||
})
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
<b-row class="mb-3">
|
||||
<b-col class="mb-2 col-12">
|
||||
<small>
|
||||
<b>{{ $t('setting.newsletter') }}</b>
|
||||
<b>{{ $t('settings.newsletter.newsletter') }}</b>
|
||||
</small>
|
||||
</b-col>
|
||||
<b-col class="col-12">
|
||||
@ -15,7 +15,11 @@
|
||||
switch
|
||||
@change="onSubmit"
|
||||
>
|
||||
{{ newsletterState ? $t('setting.newsletterTrue') : $t('setting.newsletterFalse') }}
|
||||
{{
|
||||
newsletterState
|
||||
? $t('settings.newsletter.newsletterTrue')
|
||||
: $t('settings.newsletter.newsletterFalse')
|
||||
}}
|
||||
</b-form-checkbox>
|
||||
</b-col>
|
||||
</b-row>
|
||||
@ -46,8 +50,8 @@ export default {
|
||||
this.$store.commit('newsletterState', this.newsletterState)
|
||||
this.$toasted.success(
|
||||
this.newsletterState
|
||||
? this.$t('setting.newsletterTrue')
|
||||
: this.$t('setting.newsletterFalse'),
|
||||
? this.$t('settings.newsletter.newsletterTrue')
|
||||
: this.$t('settings.newsletter.newsletterFalse'),
|
||||
)
|
||||
})
|
||||
.catch((error) => {
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
import { createLocalVue } from '@vue/test-utils'
|
||||
import { BootstrapVue, IconsPlugin } from 'bootstrap-vue'
|
||||
import Vuex from 'vuex'
|
||||
import Vue from 'vue'
|
||||
|
||||
import { ValidationProvider, ValidationObserver, extend } from 'vee-validate'
|
||||
import * as rules from 'vee-validate/dist/rules'
|
||||
@ -47,3 +48,8 @@ global.localVue.component('validation-provider', ValidationProvider)
|
||||
global.localVue.component('validation-observer', ValidationObserver)
|
||||
global.localVue.directive('click-outside', clickOutside)
|
||||
global.localVue.directive('focus', focus)
|
||||
|
||||
// throw errors for vue warnings to force the programmers to take care about warnings
|
||||
Vue.config.warnHandler = (w) => {
|
||||
throw new Error(w)
|
||||
}
|
||||
|
||||
Binary file not shown.
@ -7,8 +7,8 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: \n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2021-06-21 13:37+0200\n"
|
||||
"PO-Revision-Date: 2021-06-21 13:38+0200\n"
|
||||
"POT-Creation-Date: 2021-09-23 17:56+0200\n"
|
||||
"PO-Revision-Date: 2021-09-27 13:31+0200\n"
|
||||
"Last-Translator: \n"
|
||||
"Language-Team: \n"
|
||||
"Language: de_DE\n"
|
||||
@ -455,11 +455,10 @@ msgstr "Gradido: Passwort zurücksetzen"
|
||||
#: src/cpp/SingletonManager/SessionManager.cpp:604
|
||||
msgid ""
|
||||
"Please enter a valid password with at least 8 characters, upper and lower "
|
||||
"case letters, at least one number and one special character (@$!%*?&+-_)!"
|
||||
"case letters, at least one number and one special character!"
|
||||
msgstr ""
|
||||
"Bitte gebe ein gültiges Password ein mit mindestens 8 Zeichen, Groß- und "
|
||||
"Kleinbuchstaben, mindestens einer Zahl und einem Sonderzeichen (@$!%*?&+-_) "
|
||||
"ein!"
|
||||
"Kleinbuchstaben, mindestens einer Zahl und einem Sonderzeichen!"
|
||||
|
||||
#: src/cpp/SingletonManager/SessionManager.cpp:610
|
||||
msgid "Your password is to short!"
|
||||
@ -478,8 +477,8 @@ msgid "Your password does not contain any number!"
|
||||
msgstr "Dein Passwort enthält keine Zahlen!"
|
||||
|
||||
#: src/cpp/SingletonManager/SessionManager.cpp:630
|
||||
msgid "Your password does not contain special characters (@$!%*?&+-)!"
|
||||
msgstr "Dein Passwort enthält keine Sonderzeichen (@$!%*?&+-)!"
|
||||
msgid "Your password does not contain special characters!"
|
||||
msgstr "Dein Passwort enthält keine Sonderzeichen!"
|
||||
|
||||
#~ msgid "Account"
|
||||
#~ msgstr "Konto"
|
||||
|
||||
@ -46,22 +46,22 @@ bool SessionManager::init()
|
||||
case VALIDATE_NAME: mValidations[i] = new Poco::RegularExpression("^[^<>&;]{2,}$"); break;
|
||||
case VALIDATE_USERNAME: mValidations[i] = new Poco::RegularExpression("^[a-zA-Z][a-zA-Z0-9_-]*$"); break;
|
||||
case VALIDATE_EMAIL: mValidations[i] = new Poco::RegularExpression("^[a-zA-Z0-9.!#$%&?*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$"); break;
|
||||
case VALIDATE_PASSWORD: mValidations[i] = new Poco::RegularExpression("^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[@$!%*?&+-_])[A-Za-z0-9@$!%*?&+-_]{8,}$"); break;
|
||||
case VALIDATE_PASSWORD: mValidations[i] = new Poco::RegularExpression("^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[^a-zA-Z0-9 \\t\\n\\r]).{8,}$"); break;
|
||||
case VALIDATE_PASSPHRASE: mValidations[i] = new Poco::RegularExpression("^(?:[a-z]* ){23}[a-z]*\s*$"); break;
|
||||
case VALIDATE_GROUP_ALIAS: mValidations[i] = new Poco::RegularExpression("^[a-z0-9-]{3,120}"); break;
|
||||
case VALIDATE_HEDERA_ID: mValidations[i] = new Poco::RegularExpression("^[0-9]*\.[0-9]*\.[0-9]\.$"); break;
|
||||
case VALIDATE_HAS_NUMBER: mValidations[i] = new Poco::RegularExpression(".*[0-9].*"); break;
|
||||
case VALIDATE_HAS_NUMBER: mValidations[i] = new Poco::RegularExpression("[0-9]"); break;
|
||||
case VALIDATE_ONLY_INTEGER: mValidations[i] = new Poco::RegularExpression("^[0-9]*$"); break;
|
||||
case VALIDATE_ONLY_DECIMAL: mValidations[i] = new Poco::RegularExpression("^[0-9]*(\.|,)[0-9]*$"); break;
|
||||
case VALIDATE_ONLY_HEX: mValidations[i] = new Poco::RegularExpression("^(0x)?[a-fA-F0-9]*$"); break;
|
||||
//case VALIDATE_ONLY_URL: mValidations[i] = new Poco::RegularExpression("^https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}$"); break;
|
||||
case VALIDATE_ONLY_URL: mValidations[i] = new Poco::RegularExpression("^https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\/?"); break;
|
||||
case VALIDATE_HAS_SPECIAL_CHARACTER: mValidations[i] = new Poco::RegularExpression(".*[@$!%*?&+-].*"); break;
|
||||
case VALIDATE_HAS_SPECIAL_CHARACTER: mValidations[i] = new Poco::RegularExpression("[^a-zA-Z0-9 \\t\\n\\r]"); break;
|
||||
case VALIDATE_HAS_UPPERCASE_LETTER:
|
||||
mValidations[i] = new Poco::RegularExpression(".*[A-Z].*");
|
||||
mValidations[i] = new Poco::RegularExpression("[A-Z]");
|
||||
ServerConfig::g_ServerKeySeed->put(i, DRRandom::r64());
|
||||
break;
|
||||
case VALIDATE_HAS_LOWERCASE_LETTER: mValidations[i] = new Poco::RegularExpression(".*[a-z].*"); break;
|
||||
case VALIDATE_HAS_LOWERCASE_LETTER: mValidations[i] = new Poco::RegularExpression("[a-z]"); break;
|
||||
default: printf("[SessionManager::%s] unknown validation type\n", __FUNCTION__);
|
||||
}
|
||||
}
|
||||
@ -601,7 +601,7 @@ bool SessionManager::checkPwdValidation(const std::string& pwd, NotificationList
|
||||
if (!isValid(pwd, VALIDATE_PASSWORD)) {
|
||||
errorReciver->addError(new Error(
|
||||
lang->gettext("Password"),
|
||||
lang->gettext("Please enter a valid password with at least 8 characters, upper and lower case letters, at least one number and one special character (@$!%*?&+-_)!")));
|
||||
lang->gettext("Please enter a valid password with at least 8 characters, upper and lower case letters, at least one number and one special character!")));
|
||||
|
||||
// @$!%*?&+-
|
||||
if (pwd.size() < 8) {
|
||||
@ -627,7 +627,7 @@ bool SessionManager::checkPwdValidation(const std::string& pwd, NotificationList
|
||||
else if (!isValid(pwd, VALIDATE_HAS_SPECIAL_CHARACTER)) {
|
||||
errorReciver->addError(new Error(
|
||||
lang->gettext("Password"),
|
||||
lang->gettext("Your password does not contain special characters (@$!%*?&+-)!")));
|
||||
lang->gettext("Your password does not contain special characters!")));
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
@ -85,7 +85,7 @@ enum PageState {
|
||||
<form method="POST">
|
||||
<p>
|
||||
Bitte denke dir ein sicheres Passwort aus, das mindestens 8 Zeichen lang ist, einen Klein- und einen Großbuchstaben enthält,
|
||||
eine Zahl und eines der folgenden Sonderzeichen: @$!%*?&+-
|
||||
eine Zahl und ein Sonderzeichen.
|
||||
</p>
|
||||
<label class="form-label" for="register-password">Passwort</label>
|
||||
<input class="form-control" id="register-password" type="password" name="register-password"/>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user