mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
Merge branch 'master' into ADMINBEREICH-first-step
This commit is contained in:
commit
fa717e7046
2
.github/workflows/test.yml
vendored
2
.github/workflows/test.yml
vendored
@ -491,7 +491,7 @@ jobs:
|
|||||||
report_name: Coverage Backend
|
report_name: Coverage Backend
|
||||||
type: lcov
|
type: lcov
|
||||||
result_path: ./backend/coverage/lcov.info
|
result_path: ./backend/coverage/lcov.info
|
||||||
min_coverage: 38
|
min_coverage: 37
|
||||||
token: ${{ github.token }}
|
token: ${{ github.token }}
|
||||||
|
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
|||||||
@ -30,4 +30,6 @@ COMMUNITY_URL=
|
|||||||
COMMUNITY_REGISTER_URL=
|
COMMUNITY_REGISTER_URL=
|
||||||
COMMUNITY_DESCRIPTION=
|
COMMUNITY_DESCRIPTION=
|
||||||
LOGIN_APP_SECRET=21ffbbc616fe
|
LOGIN_APP_SECRET=21ffbbc616fe
|
||||||
LOGIN_SERVER_KEY=a51ef8ac7ef1abf162fb7a65261acd7a
|
LOGIN_SERVER_KEY=a51ef8ac7ef1abf162fb7a65261acd7a
|
||||||
|
|
||||||
|
WEBHOOK_ELOPAGE_SECRET=secret
|
||||||
@ -20,6 +20,7 @@
|
|||||||
"apollo-server-express": "^2.25.2",
|
"apollo-server-express": "^2.25.2",
|
||||||
"apollo-server-testing": "^2.25.2",
|
"apollo-server-testing": "^2.25.2",
|
||||||
"axios": "^0.21.1",
|
"axios": "^0.21.1",
|
||||||
|
"body-parser": "^1.19.0",
|
||||||
"class-validator": "^0.13.1",
|
"class-validator": "^0.13.1",
|
||||||
"cors": "^2.8.5",
|
"cors": "^2.8.5",
|
||||||
"dotenv": "^10.0.0",
|
"dotenv": "^10.0.0",
|
||||||
|
|||||||
@ -55,9 +55,21 @@ const email = {
|
|||||||
process.env.EMAIL_LINK_VERIFICATION || 'http://localhost/vue/checkEmail/$1',
|
process.env.EMAIL_LINK_VERIFICATION || 'http://localhost/vue/checkEmail/$1',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const webhook = {
|
||||||
|
WEBHOOK_ELOPAGE_SECRET: process.env.WEBHOOK_ELOPAGE_SECRET || 'secret',
|
||||||
|
}
|
||||||
|
|
||||||
// This is needed by graphql-directive-auth
|
// This is needed by graphql-directive-auth
|
||||||
process.env.APP_SECRET = server.JWT_SECRET
|
process.env.APP_SECRET = server.JWT_SECRET
|
||||||
|
|
||||||
const CONFIG = { ...server, ...database, ...klicktipp, ...community, ...email, ...loginServer }
|
const CONFIG = {
|
||||||
|
...server,
|
||||||
|
...database,
|
||||||
|
...klicktipp,
|
||||||
|
...community,
|
||||||
|
...email,
|
||||||
|
...loginServer,
|
||||||
|
...webhook,
|
||||||
|
}
|
||||||
|
|
||||||
export default CONFIG
|
export default CONFIG
|
||||||
|
|||||||
@ -12,10 +12,7 @@ export default class CreateUserArgs {
|
|||||||
lastName: string
|
lastName: string
|
||||||
|
|
||||||
@Field(() => String)
|
@Field(() => String)
|
||||||
password: string
|
language?: string // Will default to DEFAULT_LANGUAGE
|
||||||
|
|
||||||
@Field(() => String)
|
|
||||||
language: string
|
|
||||||
|
|
||||||
@Field(() => Int, { nullable: true })
|
@Field(() => Int, { nullable: true })
|
||||||
publisherId: number
|
publisherId: number
|
||||||
|
|||||||
@ -303,22 +303,23 @@ export class UserResolver {
|
|||||||
|
|
||||||
@Mutation(() => String)
|
@Mutation(() => String)
|
||||||
async createUser(
|
async createUser(
|
||||||
@Args() { email, firstName, lastName, password, language, publisherId }: CreateUserArgs,
|
@Args() { email, firstName, lastName, language, publisherId }: CreateUserArgs,
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
// TODO: wrong default value (should be null), how does graphql work here? Is it an required field?
|
// TODO: wrong default value (should be null), how does graphql work here? Is it an required field?
|
||||||
// default int publisher_id = 0;
|
// default int publisher_id = 0;
|
||||||
|
|
||||||
// Validate Language (no throw)
|
// Validate Language (no throw)
|
||||||
if (!isLanguage(language)) {
|
if (!language || !isLanguage(language)) {
|
||||||
language = DEFAULT_LANGUAGE
|
language = DEFAULT_LANGUAGE
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Register process
|
||||||
// Validate Password
|
// Validate Password
|
||||||
if (!isPassword(password)) {
|
// if (!isPassword(password)) {
|
||||||
throw new Error(
|
// throw new Error(
|
||||||
'Please enter a valid password with at least 8 characters, upper and lower case letters, at least one number and one special character!',
|
// 'Please enter a valid password with at least 8 characters, upper and lower case letters, at least one number and one special character!',
|
||||||
)
|
// )
|
||||||
}
|
// }
|
||||||
|
|
||||||
// Validate username
|
// Validate username
|
||||||
// TODO: never true
|
// TODO: never true
|
||||||
@ -336,11 +337,13 @@ export class UserResolver {
|
|||||||
throw new Error(`User already exists.`)
|
throw new Error(`User already exists.`)
|
||||||
}
|
}
|
||||||
|
|
||||||
const passphrase = PassphraseGenerate()
|
// TODO: Register process
|
||||||
const keyPair = KeyPairEd25519Create(passphrase) // return pub, priv Key
|
// const passphrase = PassphraseGenerate()
|
||||||
const passwordHash = SecretKeyCryptographyCreateKey(email, password) // return short and long hash
|
// const keyPair = KeyPairEd25519Create(passphrase) // return pub, priv Key
|
||||||
|
// const passwordHash = SecretKeyCryptographyCreateKey(email, password) // return short and long hash
|
||||||
|
// const encryptedPrivkey = SecretKeyCryptographyEncrypt(keyPair[1], passwordHash[1])
|
||||||
|
|
||||||
const emailHash = getEmailHash(email)
|
const emailHash = getEmailHash(email)
|
||||||
const encryptedPrivkey = SecretKeyCryptographyEncrypt(keyPair[1], passwordHash[1])
|
|
||||||
|
|
||||||
// Table: login_users
|
// Table: login_users
|
||||||
const loginUser = new LoginUser()
|
const loginUser = new LoginUser()
|
||||||
@ -349,13 +352,15 @@ export class UserResolver {
|
|||||||
loginUser.lastName = lastName
|
loginUser.lastName = lastName
|
||||||
loginUser.username = username
|
loginUser.username = username
|
||||||
loginUser.description = ''
|
loginUser.description = ''
|
||||||
loginUser.password = passwordHash[0].readBigUInt64LE() // using the shorthash
|
// TODO: Register process
|
||||||
|
// loginUser.password = passwordHash[0].readBigUInt64LE() // using the shorthash
|
||||||
loginUser.emailHash = emailHash
|
loginUser.emailHash = emailHash
|
||||||
loginUser.language = language
|
loginUser.language = language
|
||||||
loginUser.groupId = 1
|
loginUser.groupId = 1
|
||||||
loginUser.publisherId = publisherId
|
loginUser.publisherId = publisherId
|
||||||
loginUser.pubKey = keyPair[0]
|
// TODO: Register process
|
||||||
loginUser.privKey = encryptedPrivkey
|
// loginUser.pubKey = keyPair[0]
|
||||||
|
// loginUser.privKey = encryptedPrivkey
|
||||||
|
|
||||||
const queryRunner = getConnection().createQueryRunner()
|
const queryRunner = getConnection().createQueryRunner()
|
||||||
await queryRunner.connect()
|
await queryRunner.connect()
|
||||||
@ -367,21 +372,24 @@ export class UserResolver {
|
|||||||
throw new Error('insert user failed')
|
throw new Error('insert user failed')
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// TODO: Register process
|
||||||
// Table: login_user_backups
|
// Table: login_user_backups
|
||||||
const loginUserBackup = new LoginUserBackup()
|
// const loginUserBackup = new LoginUserBackup()
|
||||||
loginUserBackup.userId = loginUserId
|
// loginUserBackup.userId = loginUserId
|
||||||
loginUserBackup.passphrase = passphrase.join(' ') + ' ' // login server saves trailing space
|
// loginUserBackup.passphrase = passphrase.join(' ') + ' ' // login server saves trailing space
|
||||||
loginUserBackup.mnemonicType = 2 // ServerConfig::MNEMONIC_BIP0039_SORTED_ORDER;
|
// loginUserBackup.mnemonicType = 2 // ServerConfig::MNEMONIC_BIP0039_SORTED_ORDER;
|
||||||
|
|
||||||
await queryRunner.manager.save(loginUserBackup).catch((error) => {
|
// TODO: Register process
|
||||||
// eslint-disable-next-line no-console
|
// await queryRunner.manager.save(loginUserBackup).catch((error) => {
|
||||||
console.log('insert LoginUserBackup failed', error)
|
// // eslint-disable-next-line no-console
|
||||||
throw new Error('insert user backup failed')
|
// console.log('insert LoginUserBackup failed', error)
|
||||||
})
|
// throw new Error('insert user backup failed')
|
||||||
|
// })
|
||||||
|
|
||||||
// Table: state_users
|
// Table: state_users
|
||||||
const dbUser = new DbUser()
|
const dbUser = new DbUser()
|
||||||
dbUser.pubkey = keyPair[0]
|
// TODO: Register process
|
||||||
|
// dbUser.pubkey = keyPair[0]
|
||||||
dbUser.email = email
|
dbUser.email = email
|
||||||
dbUser.firstName = firstName
|
dbUser.firstName = firstName
|
||||||
dbUser.lastName = lastName
|
dbUser.lastName = lastName
|
||||||
|
|||||||
@ -6,6 +6,7 @@ import 'module-alias/register'
|
|||||||
|
|
||||||
import { ApolloServer } from 'apollo-server-express'
|
import { ApolloServer } from 'apollo-server-express'
|
||||||
import express from 'express'
|
import express from 'express'
|
||||||
|
import bodyParser from 'body-parser'
|
||||||
|
|
||||||
// database
|
// database
|
||||||
import connection from '../typeorm/connection'
|
import connection from '../typeorm/connection'
|
||||||
@ -22,6 +23,9 @@ import CONFIG from '../config'
|
|||||||
// graphql
|
// graphql
|
||||||
import schema from '../graphql/schema'
|
import schema from '../graphql/schema'
|
||||||
|
|
||||||
|
// webhooks
|
||||||
|
import { elopageWebhook } from '../webhook/elopage'
|
||||||
|
|
||||||
// TODO implement
|
// TODO implement
|
||||||
// import queryComplexity, { simpleEstimator, fieldConfigEstimator } from "graphql-query-complexity";
|
// import queryComplexity, { simpleEstimator, fieldConfigEstimator } from "graphql-query-complexity";
|
||||||
|
|
||||||
@ -50,6 +54,12 @@ const createServer = async (context: any = serverContext): Promise<any> => {
|
|||||||
// cors
|
// cors
|
||||||
app.use(cors)
|
app.use(cors)
|
||||||
|
|
||||||
|
// bodyparser
|
||||||
|
app.use(bodyParser.json())
|
||||||
|
|
||||||
|
// Elopage Webhook
|
||||||
|
app.post('/hook/elopage/' + CONFIG.WEBHOOK_ELOPAGE_SECRET, elopageWebhook)
|
||||||
|
|
||||||
// Apollo Server
|
// Apollo Server
|
||||||
const apollo = new ApolloServer({
|
const apollo = new ApolloServer({
|
||||||
schema: await schema(),
|
schema: await schema(),
|
||||||
|
|||||||
154
backend/src/webhook/elopage.ts
Normal file
154
backend/src/webhook/elopage.ts
Normal file
File diff suppressed because one or more lines are too long
@ -1552,7 +1552,7 @@ binary-extensions@^2.0.0:
|
|||||||
resolved "https://registry.yarnpkg.com/binary-extensions/-/binary-extensions-2.2.0.tgz#75f502eeaf9ffde42fc98829645be4ea76bd9e2d"
|
resolved "https://registry.yarnpkg.com/binary-extensions/-/binary-extensions-2.2.0.tgz#75f502eeaf9ffde42fc98829645be4ea76bd9e2d"
|
||||||
integrity sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA==
|
integrity sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA==
|
||||||
|
|
||||||
body-parser@1.19.0, body-parser@^1.18.3:
|
body-parser@1.19.0, body-parser@^1.18.3, body-parser@^1.19.0:
|
||||||
version "1.19.0"
|
version "1.19.0"
|
||||||
resolved "https://registry.yarnpkg.com/body-parser/-/body-parser-1.19.0.tgz#96b2709e57c9c4e09a6fd66a8fd979844f69f08a"
|
resolved "https://registry.yarnpkg.com/body-parser/-/body-parser-1.19.0.tgz#96b2709e57c9c4e09a6fd66a8fd979844f69f08a"
|
||||||
integrity sha512-dhEPs72UPbDnAQJ9ZKMNTP6ptJaionhP5cBb541nXPlW60Jepo9RV/a4fX4XWW9CuFNK22krhrj1+rgzifNCsw==
|
integrity sha512-dhEPs72UPbDnAQJ9ZKMNTP6ptJaionhP5cBb541nXPlW60Jepo9RV/a4fX4XWW9CuFNK22krhrj1+rgzifNCsw==
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user