Skip to content
This repository has been archived by the owner on Oct 31, 2022. It is now read-only.

Commit

Permalink
Add: OAuth 클라이언트 삭제 기능
Browse files Browse the repository at this point in the history
  • Loading branch information
leehj050211 committed May 21, 2022
1 parent 8a21e7b commit fd925a3
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 6 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "BSM",
"version": "1.4.1",
"version": "1.5.0",
"scripts": {
"start": "node dist/main.js",
"prestart": "tsc && babel dist -d dist"
Expand Down
14 changes: 14 additions & 0 deletions src/api/oauth/oauth.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,20 @@ router.post('/client', loginCheck, async (req: express.Request, res: express.Res
}
})

router.delete('/client/:clientId', loginCheck, async (req: express.Request, res: express.Response, next: express.NextFunction) => {
const user = new User(jwt.verify(req.cookies.token).value);
try {
res.send(JSON.stringify(
await service.deleteClient(
req.params.clientId,
user
)
));
} catch(err) {
next(err);
}
})

router.get('/client', loginCheck, async (req: express.Request, res: express.Response, next: express.NextFunction) => {
const user = new User(jwt.verify(req.cookies.token).value);
try {
Expand Down
12 changes: 12 additions & 0 deletions src/api/oauth/oauth.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,17 @@ const uriCheck = (domain: string, str: string): boolean => {
return pattern.test(str);
}

const deleteClient = async (
clientId: string,
user: User
) => {
const clientInfo = await oauthClientReposiroty.getById(clientId);
if (clientInfo === null || clientInfo.usercode != user.getUser().code) {
throw new BadRequestException();
}
await oauthClientReposiroty.deleteClient(clientId);
}

const getClientList = async (
user: User
) => {
Expand Down Expand Up @@ -272,6 +283,7 @@ export {
getToken,
getResource,
createClient,
deleteClient,
getClientList,
getScopeInfo
}
17 changes: 16 additions & 1 deletion src/api/oauth/repository/client.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,23 @@ const createClient = async (
}
}

const deleteClient = async (
clientId: string
): Promise<void> => {
const deleteQuery='DELETE FROM oauth_client WHERE client_id=?';
// DELETE FROM oauth_client
// WHERE client_id=?
try {
await pool.query(deleteQuery, [clientId]);
} catch(err) {
console.error(err);
throw new InternalServerException();
}
}

export {
getById,
getByUsercode,
createClient
createClient,
deleteClient
}
4 changes: 2 additions & 2 deletions src/api/version/version.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ const getVersion = (
switch (isApp) {
case 'web':
return {
versionCode: 5,
versionName: '1.4.1'
versionCode: 6,
versionName: '1.5.0'
}
case 'app':
switch (os) {
Expand Down

0 comments on commit fd925a3

Please sign in to comment.