1
0
mirror of https://github.com/sasjs/server.git synced 2026-01-08 15:00:05 +00:00

test(auth): added for authorize + token

This commit is contained in:
Saad Jutt
2021-11-02 18:42:06 +05:00
parent f7e0849148
commit b48e674468
8 changed files with 895 additions and 50 deletions

View File

@@ -0,0 +1,22 @@
import Client from '../model/Client'
export const createClient = async (data: any) => {
const { clientid, clientsecret } = data
// Checking if client is already in the database
const clientExist = await Client.findOne({ clientid })
if (clientExist) throw new Error('Client ID already exists.')
// Create a new client
const client = new Client({
clientid,
clientsecret
})
const savedClient = await client.save()
return {
clientid: savedClient.clientid,
clientsecret: savedClient.clientsecret
}
}