Skip to content

Commit

Permalink
RHMAP-11703 - refactor auth endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
rachael-oregan committed Dec 8, 2016
1 parent 90cfe24 commit 70c544b
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 13 deletions.
19 changes: 13 additions & 6 deletions lib/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,18 +58,25 @@ var auth = {
* correctly in local development/Studio Preview -
* the js sdk dertermines envrironment mode from url string.
* New endpoint determines environment mode from env var,
* sends request (req) and calls user provided function (cb).
* optionally sends request (localAuth - for local dev)
* and calls user provided function (cb).
* @param {object} req
* @param {object} res
* @param {function} localAuth - optional for local development.
* @param {object} cb
*/
performAuth: function (req, res, cb) {
performAuth: function (req, localAuth, cb) {
// "FH_USE_LOCAL_DB" env var determines if the app is running in local mode.
if (process.env.FH_USE_LOCAL_DB) {
// In local mode, invoke user function
return cb(undefined, res);
// In local mode, invoke user function/object
if (_.isFunction(localAuth)) {
return localAuth(req, cb);
} else if (_.isObject(localAuth)) {
return cb(undefined, localAuth);
} else {
return cb(undefined, {status: 200, body: {}});
}
} else {
// In production mode, proxy request back to Core platform.
// In production mode, proxy request back to Core platform.
return call("admin/authpolicy/auth", req.body, cb);
}
}
Expand Down
12 changes: 6 additions & 6 deletions npm-shrinkwrap.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
Expand Up @@ -10,7 +10,7 @@
"eyes": "0.1.8",
"fh-db": "1.2.5",
"fh-mbaas-client": "0.15.0",
"fh-mbaas-express": "5.6.3",
"fh-mbaas-express": "5.6.4",
"fh-security": "0.2.0",
"fh-statsc": "0.3.0",
"lodash-contrib": "^393.0.1",
Expand Down

0 comments on commit 70c544b

Please sign in to comment.