Skip to content

Commit

Permalink
Merge pull request #25 from topcoder-platform/Issue_13
Browse files Browse the repository at this point in the history
Issue 13
  • Loading branch information
callmekatootie authored Apr 20, 2020
2 parents 2958c3d + 7706721 commit 4cdf234
Show file tree
Hide file tree
Showing 23 changed files with 955 additions and 211 deletions.
11 changes: 10 additions & 1 deletion app-routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ module.exports = (app) => {
actions.push((req, res, next) => {
authenticator(_.pick(config, ['AUTH_SECRET', 'VALID_ISSUERS']))(req, res, next)
})

actions.push((req, res, next) => {
if (!req.authUser) {
return next(new errors.UnauthorizedError('Action is not allowed for invalid token'))
Expand Down Expand Up @@ -95,6 +94,16 @@ module.exports = (app) => {
next()
}
})
} else {
// Allow public access, but process the jwt token, if one is passed
// This is for GET requests where admin users can access soft deleted records
actions.push((req, res, next) => {
if (req.headers.authorization) {
authenticator(_.pick(config, ['AUTH_SECRET', 'VALID_ISSUERS']))(req, res, next)
} else {
next()
}
})
}

actions.push(method)
Expand Down
29 changes: 28 additions & 1 deletion docs/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ paths:
parameters:
- $ref: '#/parameters/page'
- $ref: '#/parameters/perPage'
- $ref: '#/parameters/includeSoftDeleted'
- name: type
in: query
description: Filter by type, case insensitive, partial match is used
Expand Down Expand Up @@ -121,6 +122,7 @@ paths:
parameters:
- $ref: '#/parameters/page'
- $ref: '#/parameters/perPage'
- $ref: '#/parameters/includeSoftDeleted'
- name: type
in: query
description: Filter by type, case insensitive, partial match is used
Expand Down Expand Up @@ -225,6 +227,7 @@ paths:
- Device
description: Retrieve the device by id
parameters:
- $ref: '#/parameters/includeSoftDeleted'
- name: id
in: path
required: true
Expand Down Expand Up @@ -253,6 +256,7 @@ paths:
- Device
description: Retrieve the device head by id
parameters:
- $ref: '#/parameters/includeSoftDeleted'
- name: id
in: path
required: true
Expand Down Expand Up @@ -380,6 +384,7 @@ paths:
security:
- bearer: []
parameters:
- $ref: '#/parameters/destroy'
- name: id
in: path
required: true
Expand Down Expand Up @@ -465,6 +470,7 @@ paths:
parameters:
- $ref: '#/parameters/page'
- $ref: '#/parameters/perPage'
- $ref: '#/parameters/includeSoftDeleted'
- name: name
in: query
description: Filter by name, case insensitive, partial match is used
Expand Down Expand Up @@ -520,6 +526,7 @@ paths:
parameters:
- $ref: '#/parameters/page'
- $ref: '#/parameters/perPage'
- $ref: '#/parameters/includeSoftDeleted'
- name: name
in: query
description: Filter by name, case insensitive, partial match is used
Expand Down Expand Up @@ -609,6 +616,7 @@ paths:
- Country
description: Retrieve the country by id
parameters:
- $ref: '#/parameters/includeSoftDeleted'
- name: id
in: path
required: true
Expand Down Expand Up @@ -637,6 +645,7 @@ paths:
- Country
description: Retrieve the country head by id
parameters:
- $ref: '#/parameters/includeSoftDeleted'
- name: id
in: path
required: true
Expand Down Expand Up @@ -764,6 +773,7 @@ paths:
security:
- bearer: []
parameters:
- $ref: '#/parameters/destroy'
- name: id
in: path
required: true
Expand Down Expand Up @@ -803,6 +813,7 @@ paths:
parameters:
- $ref: '#/parameters/page'
- $ref: '#/parameters/perPage'
- $ref: '#/parameters/includeSoftDeleted'
- name: name
in: query
description: Filter by name, case insensitive, partial match is used
Expand Down Expand Up @@ -853,6 +864,7 @@ paths:
parameters:
- $ref: '#/parameters/page'
- $ref: '#/parameters/perPage'
- $ref: '#/parameters/includeSoftDeleted'
- name: name
in: query
description: Filter by name, case insensitive, partial match is used
Expand Down Expand Up @@ -937,6 +949,7 @@ paths:
- Educational Institution
description: Retrieve the educational institution by id
parameters:
- $ref: '#/parameters/includeSoftDeleted'
- name: id
in: path
required: true
Expand Down Expand Up @@ -965,6 +978,7 @@ paths:
- Educational Institution
description: Retrieve the educational institution head by id
parameters:
- $ref: '#/parameters/includeSoftDeleted'
- name: id
in: path
required: true
Expand Down Expand Up @@ -1092,6 +1106,7 @@ paths:
security:
- bearer: []
parameters:
- $ref: '#/parameters/destroy'
- name: id
in: path
required: true
Expand Down Expand Up @@ -1158,6 +1173,18 @@ parameters:
type: integer
default: 20
maximum: 100
includeSoftDeleted:
name: includeSoftDeleted
in: query
description: Include items that have been soft deleted (Only allowed for admin)
type: boolean
default: false
destroy:
name: destroy
in: query
description: Hard delete the item (Only allowed for admin)
type: boolean
default: false
definitions:
Country:
type: object
Expand Down Expand Up @@ -1241,4 +1268,4 @@ definitions:
operatingSystem:
type: string
operatingSystemVersion:
type: string
type: string
Loading

0 comments on commit 4cdf234

Please sign in to comment.