mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
middleware for register a new user
This commit is contained in:
parent
0ef60ab92c
commit
c7d044b532
@ -1,5 +1,5 @@
|
|||||||
// import jwt from 'jsonwebtoken'
|
// import jwt from 'jsonwebtoken'
|
||||||
import { Resolver, Query, Args, Arg } from 'type-graphql'
|
import { Resolver, Query, Args, Arg, UseMiddleware } from 'type-graphql'
|
||||||
import CONFIG from '../../config'
|
import CONFIG from '../../config'
|
||||||
import { CheckUsernameResponse } from '../models/CheckUsernameResponse'
|
import { CheckUsernameResponse } from '../models/CheckUsernameResponse'
|
||||||
import { LoginResponse } from '../models/LoginResponse'
|
import { LoginResponse } from '../models/LoginResponse'
|
||||||
@ -15,6 +15,7 @@ import {
|
|||||||
} from '../inputs/LoginUserInput'
|
} from '../inputs/LoginUserInput'
|
||||||
import { apiPost, apiGet } from '../../apis/HttpRequest'
|
import { apiPost, apiGet } from '../../apis/HttpRequest'
|
||||||
import { KlicktippConnector } from '../../apis/klicktippAPI'
|
import { KlicktippConnector } from '../../apis/klicktippAPI'
|
||||||
|
import { registerMiddleware } from '../../middleware/registerMiddleware'
|
||||||
|
|
||||||
@Resolver()
|
@Resolver()
|
||||||
export class UserResolver {
|
export class UserResolver {
|
||||||
@ -73,6 +74,7 @@ export class UserResolver {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Query(() => String)
|
@Query(() => String)
|
||||||
|
@UseMiddleware(registerMiddleware)
|
||||||
async create(
|
async create(
|
||||||
@Args() { email, firstName, lastName, password, language }: CreateUserArgs,
|
@Args() { email, firstName, lastName, password, language }: CreateUserArgs,
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
@ -94,11 +96,12 @@ export class UserResolver {
|
|||||||
// CONFIG.KLICKTIPP_PASSWORD,
|
// CONFIG.KLICKTIPP_PASSWORD,
|
||||||
// )
|
// )
|
||||||
// if (loginSuccessful) {
|
// if (loginSuccessful) {
|
||||||
const fields = {}
|
// const fields = {}
|
||||||
const apiKey = language === 'de' ? CONFIG.KLICKTIPP_APIKEY_DE : CONFIG.KLICKTIPP_APIKEY_EN
|
// const apiKey = language === 'de' ? CONFIG.KLICKTIPP_APIKEY_DE : CONFIG.KLICKTIPP_APIKEY_EN
|
||||||
await this.connector.signin(apiKey, email, fields)
|
// await this.connector.signin(apiKey, email, fields)
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
// I think we need something more than success here to process the returned data in the middleware
|
||||||
return 'success'
|
return 'success'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
8
backend/src/middleware/registerMiddleware.ts
Normal file
8
backend/src/middleware/registerMiddleware.ts
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
import { MiddlewareFn } from 'type-graphql'
|
||||||
|
|
||||||
|
/* eslint-disable-next-line @typescript-eslint/no-unused-vars */
|
||||||
|
export const registerMiddleware: MiddlewareFn = async ({ root, args, context, info }, next) => {
|
||||||
|
const result = await next()
|
||||||
|
// do something here
|
||||||
|
return result
|
||||||
|
}
|
||||||
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
/* Basic Options */
|
/* Basic Options */
|
||||||
// "incremental": true, /* Enable incremental compilation */
|
// "incremental": true, /* Enable incremental compilation */
|
||||||
"target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', 'ES2021', or 'ESNEXT'. */
|
"target": "es6", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', 'ES2021', or 'ESNEXT'. */
|
||||||
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */
|
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */
|
||||||
// "lib": [], /* Specify library files to be included in the compilation. */
|
// "lib": [], /* Specify library files to be included in the compilation. */
|
||||||
// "allowJs": true, /* Allow javascript files to be compiled. */
|
// "allowJs": true, /* Allow javascript files to be compiled. */
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user