mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
Merge branch 'backend_setup' of github.com:gradido/gradido into backend_setup
This commit is contained in:
commit
ca4998318f
@ -82,23 +82,23 @@ export class UpdateUserInfosArgs {
|
||||
@Field(() => String)
|
||||
email!: string
|
||||
|
||||
@Field(() => String)
|
||||
firstName?: string
|
||||
@Field({ nullable: true })
|
||||
firstName?: string | null
|
||||
|
||||
@Field(() => String)
|
||||
lastName?: string
|
||||
@Field({ nullable: true })
|
||||
lastName?: string | null
|
||||
|
||||
@Field(() => String)
|
||||
username?: string
|
||||
@Field({ nullable: true })
|
||||
username?: string | null
|
||||
|
||||
@Field(() => String)
|
||||
language?: string
|
||||
@Field({ nullable: true })
|
||||
language?: string | null
|
||||
|
||||
@Field(() => String)
|
||||
password?: string
|
||||
@Field({ nullable: true })
|
||||
password?: string | null
|
||||
|
||||
@Field(() => String)
|
||||
passwordNew?: string
|
||||
@Field({ nullable: true })
|
||||
passwordNew?: string | null
|
||||
}
|
||||
|
||||
@ArgsType()
|
||||
|
||||
@ -1,9 +0,0 @@
|
||||
import { Entity, BaseEntity } from 'typeorm'
|
||||
import { ObjectType, Field } from 'type-graphql'
|
||||
|
||||
@Entity()
|
||||
@ObjectType()
|
||||
export class BaseResponse extends BaseEntity {
|
||||
@Field(() => Boolean)
|
||||
success: boolean
|
||||
}
|
||||
@ -1,9 +0,0 @@
|
||||
import { Entity, BaseEntity } from 'typeorm'
|
||||
import { ObjectType, Field } from 'type-graphql'
|
||||
|
||||
@Entity()
|
||||
@ObjectType()
|
||||
export class ChangePasswordResponse extends BaseEntity {
|
||||
@Field(() => String)
|
||||
state: string
|
||||
}
|
||||
@ -1,9 +1,18 @@
|
||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
|
||||
import { Entity, BaseEntity } from 'typeorm'
|
||||
import { ObjectType, Field } from 'type-graphql'
|
||||
|
||||
@Entity()
|
||||
@ObjectType()
|
||||
export class CheckUsernameResponse extends BaseEntity {
|
||||
constructor(json: any) {
|
||||
super()
|
||||
this.state = json.state
|
||||
this.msg = json.msg
|
||||
this.groupId = json.group_id
|
||||
}
|
||||
|
||||
@Field(() => String)
|
||||
state: string
|
||||
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
|
||||
import { Entity, BaseEntity } from 'typeorm'
|
||||
import { ObjectType, Field } from 'type-graphql'
|
||||
|
||||
|
||||
16
backend/src/graphql/models/ResetPasswordResponse.ts
Normal file
16
backend/src/graphql/models/ResetPasswordResponse.ts
Normal file
@ -0,0 +1,16 @@
|
||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
|
||||
import { Entity, BaseEntity } from 'typeorm'
|
||||
import { ObjectType, Field } from 'type-graphql'
|
||||
|
||||
@Entity()
|
||||
@ObjectType()
|
||||
export class ResetPasswordResponse extends BaseEntity {
|
||||
constructor(json: any) {
|
||||
super()
|
||||
this.state = json.state
|
||||
}
|
||||
|
||||
@Field(() => String)
|
||||
state: string
|
||||
}
|
||||
@ -1,9 +1,11 @@
|
||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
|
||||
import { Entity, BaseEntity } from 'typeorm'
|
||||
import { ObjectType, Field } from 'type-graphql'
|
||||
|
||||
@Entity()
|
||||
@ObjectType()
|
||||
export class SendEmailResponse extends BaseEntity {
|
||||
export class SendPasswordResetEmailResponse extends BaseEntity {
|
||||
constructor(json: any) {
|
||||
super()
|
||||
this.state = json.state
|
||||
@ -1,3 +1,5 @@
|
||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
|
||||
import { Entity, BaseEntity } from 'typeorm'
|
||||
import { ObjectType, Field } from 'type-graphql'
|
||||
|
||||
|
||||
@ -1,15 +1,16 @@
|
||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
|
||||
import { Entity, BaseEntity } from 'typeorm'
|
||||
import { ObjectType, Field } from 'type-graphql'
|
||||
|
||||
@Entity()
|
||||
@ObjectType()
|
||||
export class UpdateUserInfosResponse extends BaseEntity {
|
||||
@Field(() => String)
|
||||
state: string
|
||||
constructor(json: any) {
|
||||
super()
|
||||
this.validValues = json.valid_values
|
||||
}
|
||||
|
||||
@Field(() => Number)
|
||||
validValues: number
|
||||
|
||||
@Field(() => [String])
|
||||
errors: [string]
|
||||
}
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
|
||||
import { Entity, BaseEntity } from 'typeorm'
|
||||
import { ObjectType, Field } from 'type-graphql'
|
||||
import { Server } from './Server'
|
||||
|
||||
@ -1,13 +1,13 @@
|
||||
// import jwt from 'jsonwebtoken'
|
||||
import { Resolver, Query, /* Mutation, */ Args, Arg } from 'type-graphql'
|
||||
import { Resolver, Query, Args, Arg } from 'type-graphql'
|
||||
import CONFIG from '../../config'
|
||||
import { ChangePasswordResponse } from '../models/ChangePasswordResponse'
|
||||
import { ResetPasswordResponse } from '../models/ResetPasswordResponse'
|
||||
import { CheckUsernameResponse } from '../models/CheckUsernameResponse'
|
||||
import { CreateResponse } from '../models/CreateResponse'
|
||||
import { GetUserInfoResponse } from '../models/UserInfoData'
|
||||
import { LoginResponse } from '../models/LoginResponse'
|
||||
import { LoginViaVerificationCode } from '../models/LoginViaVerificationCode'
|
||||
import { SendEmailResponse } from '../models/SendEmailResponse'
|
||||
import { SendPasswordResetEmailResponse } from '../models/SendPasswordResetEmailResponse'
|
||||
import { UpdateUserInfosResponse } from '../models/UpdateUserInfosResponse'
|
||||
import {
|
||||
ChangePasswordArgs,
|
||||
@ -66,17 +66,16 @@ export class UserResolver {
|
||||
return new LoginViaVerificationCode(result.data)
|
||||
}
|
||||
|
||||
/* @Query(() => LogoutResponse)
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
async logout(@Arg('sessionId') sessionId: number): Promise<LogoutResponse> {
|
||||
@Query(() => String)
|
||||
async logout(@Arg('sessionId') sessionId: number): Promise<string> {
|
||||
const payload = { session_id: sessionId }
|
||||
const result = apiPost(CONFIG.LOGIN_API_URL + 'logout', payload)
|
||||
const result = await apiPost(CONFIG.LOGIN_API_URL + 'logout', payload)
|
||||
if (!result.success) {
|
||||
throw new Error(result.data)
|
||||
}
|
||||
return result.data
|
||||
return 'success'
|
||||
}
|
||||
*/
|
||||
|
||||
@Query(() => CreateResponse)
|
||||
async create(
|
||||
@Args() { email, firstName, lastName, password }: CreateUserArgs,
|
||||
@ -96,17 +95,20 @@ export class UserResolver {
|
||||
return new CreateResponse(result.data)
|
||||
}
|
||||
|
||||
@Query(() => SendEmailResponse)
|
||||
async sendEmail(
|
||||
// TODO
|
||||
@Query(() => SendPasswordResetEmailResponse)
|
||||
async sendResetPasswordEmail(
|
||||
@Args()
|
||||
{ email, emailText = 7, emailVerificationCodeType = 'resetPassword' }: SendEmailArgs,
|
||||
): Promise<any> {
|
||||
): Promise<SendPasswordResetEmailResponse> {
|
||||
const payload = {
|
||||
email,
|
||||
email_text: emailText,
|
||||
email_verification_code_type: emailVerificationCodeType,
|
||||
}
|
||||
return apiPost(CONFIG.LOGIN_API_URL + 'sendEmail', payload)
|
||||
const response = await apiPost(CONFIG.LOGIN_API_URL + 'sendEmail', payload)
|
||||
if (!response.success) throw new Error(response.data)
|
||||
return new SendPasswordResetEmailResponse(response.data)
|
||||
}
|
||||
|
||||
@Query(() => GetUserInfoResponse)
|
||||
@ -119,16 +121,19 @@ export class UserResolver {
|
||||
return apiPost(CONFIG.LOGIN_API_URL + 'getUserInfos', payload)
|
||||
}
|
||||
|
||||
@Query(() => ChangePasswordResponse)
|
||||
async changePassword(@Args() { sessionId, email, password }: ChangePasswordArgs): Promise<any> {
|
||||
@Query(() => ResetPasswordResponse)
|
||||
async resetPassword(
|
||||
@Args()
|
||||
{ sessionId, email, password }: ChangePasswordArgs,
|
||||
): Promise<ResetPasswordResponse> {
|
||||
const payload = {
|
||||
session_id: sessionId,
|
||||
email,
|
||||
password,
|
||||
}
|
||||
const result = await apiPost(CONFIG.LOGIN_API_URL + 'resetPassword', payload)
|
||||
if (result.success) return result.result.data.state
|
||||
return result.result
|
||||
if (!result.success) throw new Error(result.data)
|
||||
return new ResetPasswordResponse(result.data)
|
||||
}
|
||||
|
||||
@Query(() => UpdateUserInfosResponse)
|
||||
@ -137,32 +142,39 @@ export class UserResolver {
|
||||
{
|
||||
sessionId,
|
||||
email,
|
||||
firstName,
|
||||
lastName,
|
||||
username,
|
||||
language,
|
||||
password,
|
||||
passwordNew,
|
||||
firstName = null,
|
||||
lastName = null,
|
||||
username = null,
|
||||
language = null,
|
||||
password = null,
|
||||
passwordNew = null,
|
||||
}: UpdateUserInfosArgs,
|
||||
): Promise<any> {
|
||||
): Promise<UpdateUserInfosResponse> {
|
||||
const payload = {
|
||||
session_id: sessionId,
|
||||
email,
|
||||
update: {
|
||||
'User.first_name': firstName,
|
||||
'User.last_name': lastName,
|
||||
// 'User.description': data.description,
|
||||
'User.username': username,
|
||||
'User.language': language,
|
||||
'User.password_old': password,
|
||||
'User.password': passwordNew,
|
||||
'User.first_name': firstName !== null ? firstName : undefined,
|
||||
'User.last_name': lastName !== null ? lastName : undefined,
|
||||
'User.username': username !== null ? username : undefined,
|
||||
'User.language': language !== null ? language : undefined,
|
||||
'User.password': passwordNew !== null ? passwordNew : undefined,
|
||||
'User.password_old': password !== null ? password : undefined,
|
||||
},
|
||||
}
|
||||
return apiPost(CONFIG.LOGIN_API_URL + 'updateUserInfos', payload)
|
||||
const result = await apiPost(CONFIG.LOGIN_API_URL + 'updateUserInfos', payload)
|
||||
if (!result.success) throw new Error(result.data)
|
||||
return new UpdateUserInfosResponse(result.data)
|
||||
}
|
||||
|
||||
@Query(() => CheckUsernameResponse)
|
||||
async checkUsername(@Args() { username, groupId = 1 }: CheckUsernameArgs): Promise<any> {
|
||||
return apiGet(CONFIG.LOGIN_API_URL + `checkUsername?username=${username}&group_id=${groupId}`)
|
||||
async checkUsername(
|
||||
@Args() { username, groupId = 1 }: CheckUsernameArgs,
|
||||
): Promise<CheckUsernameResponse> {
|
||||
const response = await apiGet(
|
||||
CONFIG.LOGIN_API_URL + `checkUsername?username=${username}&group_id=${groupId}`,
|
||||
)
|
||||
if (!response.success) throw new Error(response.data)
|
||||
return new CheckUsernameResponse(response.data)
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user