Skip to content

Commit

Permalink
Merge pull request #162 from fdhhhdjd/developer
Browse files Browse the repository at this point in the history
#161 [Backend] Full Authentication Admin
  • Loading branch information
fdhhhdjd authored Mar 1, 2023
2 parents d6a9ad2 + 0fe0b30 commit 40494df
Show file tree
Hide file tree
Showing 36 changed files with 1,144 additions and 158 deletions.
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@
"[sql]": {
"editor.defaultFormatter": "adpyke.vscode-sql-formatter"
},
"cSpell.words": ["Middlawre"]
"cSpell.words": ["MIDDLAWARE", "Middlawre", "mutilp"]
}
2 changes: 2 additions & 0 deletions backend-manager-student/docker-compose-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ services:
networks:
- libary_school
- server-send-email-student_sendemail
- server-media-service_upload-network
healthcheck:
test: ['CMD', 'redis-cli', 'ping']
interval: 30s
Expand Down Expand Up @@ -152,6 +153,7 @@ services:
- .env
networks:
- libary_school
- server-media-service_upload-network
healthcheck:
test: ['CMD-SHELL', "sh -c 'pg_isready -U ${POSTGRES_USER} -d ${POSTGRES_DB}'"]
interval: 10s
Expand Down
7 changes: 7 additions & 0 deletions backend-manager-student/src/admin_api/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,13 @@ const CONFIGS = require('../share/configs/config');
const CONSTANTS = require('../share/configs/constants');
const OPTIONS = require('../share/configs/option');

//! IMPORT MIDDLEWARE
const DEVICE_MIDDLEWARE = require('../share/middleware/device.middleware');

//! CACHE MEMORY
const { REDIS_MASTER } = require('../share/db/init_multiple_redis');
let RedisStore = require('connect-redis')(session);

//! IMPORT ROUTES
const ADMIN_API = require('./v1/routes/index.route');

Expand Down Expand Up @@ -76,6 +80,9 @@ app.use(
}),
);

//! CHECK DEVICE
app.use(DEVICE_MIDDLEWARE);

//! ROUTE
app.use(ADMIN_API);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,10 @@ components:
element:
type: object
example: Out Of Service
#!@author Nguyễn Tiến Tài
#!created_at 31/01/2023
#!created_at 08/02/2023
#!description: Login Admin
#!@author Nguyễn Tiến Tài
#!created_at 31/01/2023
#!created_at 08/02/2023
#!description: Login Admin
paths:
/api/v1/admin/login:
post:
Expand All @@ -149,14 +149,14 @@ paths:
admin_login_input:
type: object
properties:
phone:
mssv:
type: number
example: 0791483642
example: 60136745
password:
type: string
example: '20000531'
required:
- phone
- mssv
- password
responses:
200:
Expand Down Expand Up @@ -203,9 +203,9 @@ paths:

#!@author Nguyễn Tiến Tài
#!created_at 31/01/2023
#!updated_at 08/02/2023
#!updated_at 08/02/2023 && 28/02/2023
#!description Add Student
/api/v1/admin/add/student:
/api/v1/admin/private/add/student:
post:
summary: Add Student
tags: [Add Student For Excel]
Expand Down Expand Up @@ -278,3 +278,107 @@ paths:
example: { result: string }
503:
$ref: '#/components/responses/ServerFail'

#!@author Nguyễn Tiến Tài
#!created_at 28/02/2023
#!description: New Token
/api/v1/admin/renew-token:
post:
summary: New Token
tags: [New Token]
operationId: reNewToken
parameters:
- $ref: '#/components/parameters/COOKIE-CLIENT'
- $ref: '#/components/parameters/X-DEVICE-ID'
- $ref: '#/components/parameters/X-OS-TYPE'
- $ref: '#/components/parameters/X-OS-VERSION'
- $ref: '#/components/parameters/X-APP-VERSION'
- $ref: '#/components/parameters/X-DEVICE-NAME'
- $ref: '#/components/parameters/TOKEN'
schema:
$ref: '#/components/headers/AuthHeader'
responses:
200:
description: New Token Success
headers:
$ref: '#/components/SaveCookie'
application/json:
schema:
type: object
properties:
status:
type: integer
example: 200
message:
type: string
example: Success
element:
type: object
example:
{
result:
{
access_token: string,
refresh_token: string,
role: number,
user_id: string,
name: string,
},
}
400:
description: Token is Blacklist or Invalid Header or The refresh token is invalid or Device Invalid
content:
application/json:
schema:
type: object
properties:
status:
type: integer
example: 400
message:
type: string
example: string
element:
type: object
example: { result: string }
503:
$ref: '#/components/responses/ServerFail'
#!@author Nguyễn Tiến Tài
#!created_at 28/02/2023
#!description: Logout admin
/api/v1/admin/private/logout:
post:
summary: Logout Admin
tags: [Logout Admin]
operationId: logoutAdmin
parameters:
- $ref: '#/components/parameters/COOKIE-CLIENT'
- $ref: '#/components/parameters/X-DEVICE-ID'
- $ref: '#/components/parameters/X-OS-TYPE'
- $ref: '#/components/parameters/X-OS-VERSION'
- $ref: '#/components/parameters/X-APP-VERSION'
- $ref: '#/components/parameters/X-DEVICE-NAME'
- $ref: '#/components/parameters/TOKEN'
schema:
$ref: '#/components/headers/AuthHeader'
responses:
200:
description: Logout Success
content:
application/json:
schema:
type: object
properties:
status:
type: integer
example: 200
message:
type: string
example: Success
401:
$ref: '#/components/responses/UnauthorizedError'
500:
$ref: '#/components/responses/ServerCURDFail'

503:
$ref: '#/components/responses/ServerFail'
Loading

0 comments on commit 40494df

Please sign in to comment.