Skip to content

Commit

Permalink
fix(api): fix broken providers creation (#354)
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelmasse committed Feb 11, 2022
1 parent 6136e6a commit 1527d39
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions packages/server/src/clients/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,17 @@ export class ClientApi {
}

async create(req: Request, res: Response) {
const clientId: uuid = req.body.id
let clientId: uuid | undefined = req.body.id

if (clientId && (await this.clients.fetchById(clientId))) {
return res.status(403).send(`client with id "${clientId}" already exists`)
}

const provider = await this.providers.create(clientId || uuidv4(), false)
if (!clientId) {
clientId = uuidv4()
}

const provider = await this.providers.create(clientId, false)
const client = await this.clients.create(provider.id, clientId)

const rawToken = await this.clientTokens.generateToken()
Expand Down

0 comments on commit 1527d39

Please sign in to comment.