"Enable CF Merge branch 'OpenSAP-week3-unit5' of https://github.com/SAP-samples/cloud-cap-samples into OpenSAP-week3-unit5
This commit is contained in:
29
packages/bookshop/package-lock.json
generated
29
packages/bookshop/package-lock.json
generated
@@ -1,4 +1,5 @@
|
||||
{
|
||||
<<<<<<< HEAD
|
||||
"name": "@sap/capire-bookshop",
|
||||
"version": "1.0.0",
|
||||
"lockfileVersion": 1,
|
||||
@@ -980,3 +981,31 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
=======
|
||||
"name": "@sap/capire-bookshop",
|
||||
"version": "1.0.0",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
"passport": {
|
||||
"version": "0.4.1",
|
||||
"resolved": "https://registry.npmjs.org/passport/-/passport-0.4.1.tgz",
|
||||
"integrity": "sha512-IxXgZZs8d7uFSt3eqNjM9NQ3g3uQCW5avD8mRNoXV99Yig50vjuaez6dQK2qC0kVWPRTujxY0dWgGfT09adjYg==",
|
||||
"requires": {
|
||||
"passport-strategy": "1.x.x",
|
||||
"pause": "0.0.1"
|
||||
}
|
||||
},
|
||||
"passport-strategy": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/passport-strategy/-/passport-strategy-1.0.0.tgz",
|
||||
"integrity": "sha1-tVOaqPwiWj0a0XlHbd8ja0QPUuQ="
|
||||
},
|
||||
"pause": {
|
||||
"version": "0.0.1",
|
||||
"resolved": "https://registry.npmjs.org/pause/-/pause-0.0.1.tgz",
|
||||
"integrity": "sha1-HUCLP9t2kjuVQ9lvtMnf1TXZy10="
|
||||
}
|
||||
}
|
||||
}
|
||||
>>>>>>> cad3a32c78620f4c4558fad34991dd48866af8d3
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
{
|
||||
<<<<<<< HEAD
|
||||
"name": "@sap/capire-bookshop",
|
||||
"version": "1.0.0",
|
||||
"description": "A simple bookshop application, build in a self-contained all-in-one fashion, i.e. w/o reusing other packages.",
|
||||
@@ -27,4 +28,39 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
=======
|
||||
"name": "@sap/capire-bookshop",
|
||||
"version": "1.0.0",
|
||||
"description": "A simple bookshop application, build in a self-contained all-in-one fashion, i.e. w/o reusing other packages.",
|
||||
"license": "SAP SAMPLE CODE LICENSE",
|
||||
"dependencies": {
|
||||
"@sap/cds": "latest",
|
||||
"express": "*",
|
||||
"passport": "^0.4.1"
|
||||
},
|
||||
"cds": {
|
||||
"auth": {
|
||||
"passport": {
|
||||
"strategy": "mock",
|
||||
"users": {
|
||||
"alice": {
|
||||
"password": "123",
|
||||
"ID": "alice",
|
||||
"roles": ["admin", "authenticated-user"],
|
||||
"xs.user.attributes": { "currency": [ "USD" ] }
|
||||
},
|
||||
"bob": {
|
||||
"password": "123",
|
||||
"ID": "bob",
|
||||
"roles": ["authenticated-user"]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
"start": "cds run --in-memory?",
|
||||
"watch": "cds watch"
|
||||
}
|
||||
>>>>>>> cad3a32c78620f4c4558fad34991dd48866af8d3
|
||||
}
|
||||
|
||||
@@ -14,7 +14,10 @@ annotate AdminService.Orders with @odata.draft.enabled;
|
||||
extend service AdminService with {
|
||||
entity OrderItems as select from my.OrderItems;
|
||||
}
|
||||
<<<<<<< HEAD
|
||||
|
||||
=======
|
||||
>>>>>>> cad3a32c78620f4c4558fad34991dd48866af8d3
|
||||
// Restrict access to orders to users with role "admin"
|
||||
annotate AdminService.Orders with @(restrict: [
|
||||
{ grant: 'READ', to: 'admin' }
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
/** Service implementation for AdminService */
|
||||
module.exports = cds.service.impl(function() {
|
||||
<<<<<<< HEAD
|
||||
this.before ('CREATE', 'Orders', _checkOrderCreateAuth)
|
||||
})
|
||||
|
||||
@@ -8,3 +9,13 @@ module.exports = cds.service.impl(function() {
|
||||
function _checkOrderCreateAuth (req) {
|
||||
req.user.currency[0] === req.data.currency_code || req.reject(403)
|
||||
}
|
||||
=======
|
||||
this.before ('CREATE', 'Orders', _checkOrderCreateAuth)
|
||||
})
|
||||
|
||||
|
||||
/** Check authorization */
|
||||
function _checkOrderCreateAuth (req) {
|
||||
req.user.currency[0] === req.data.currency_code || req.reject(403)
|
||||
}
|
||||
>>>>>>> cad3a32c78620f4c4558fad34991dd48866af8d3
|
||||
|
||||
@@ -24,3 +24,6 @@ async function _reduceStock (req) {
|
||||
)
|
||||
}))
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user