Updating environment in auth package, easily see required env settings.
This commit is contained in:
parent
77c98009b8
commit
a76964d12e
|
@ -1,8 +1,9 @@
|
|||
const PouchDB = require("pouchdb")
|
||||
const env = require("../environment")
|
||||
|
||||
// level option is purely for testing (development)
|
||||
const COUCH_DB_URL =
|
||||
process.env.COUCH_DB_URL || "http://budibase:budibase@localhost:10000/db/"
|
||||
env.COUCH_DB_URL || "http://budibase:budibase@localhost:10000/db/"
|
||||
|
||||
const Pouch = PouchDB.defaults({
|
||||
prefix: COUCH_DB_URL,
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
module.exports = {
|
||||
JWT_SECRET: process.env.JWT_SECRET,
|
||||
COUCH_DB_URL: process.env.COUCH_DB_URL,
|
||||
SALT_ROUNDS: process.env.SALT_ROUNDS,
|
||||
GOOGLE_CLIENT_ID: process.env.GOOGLE_CLIENT_ID,
|
||||
GOOGLE_CLIENT_SECRET: process.env.GOOGLE_CLIENT_SECRET,
|
||||
GOOGLE_AUTH_CALLBACK_URL: process.env.GOOGLE_AUTH_CALLBACK_URL,
|
||||
}
|
|
@ -1,6 +1,7 @@
|
|||
const bcrypt = require("bcryptjs")
|
||||
const env = require("./environment")
|
||||
|
||||
const SALT_ROUNDS = process.env.SALT_ROUNDS || 10
|
||||
const SALT_ROUNDS = env.SALT_ROUNDS || 10
|
||||
|
||||
exports.hash = async data => {
|
||||
const salt = await bcrypt.genSalt(SALT_ROUNDS)
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
// const CouchDB = require("../db")
|
||||
const env = require("../../environment")
|
||||
|
||||
exports.options = {
|
||||
clientId: process.env.GOOGLE_CLIENT_ID,
|
||||
clientSecret: process.env.GOOGLE_CLIENT_SECRET,
|
||||
callbackURL: process.env.GOOGLE_AUTH_CALLBACK_URL,
|
||||
// "http://localhost:" + (process.env.PORT || 3000) + "/auth/google/callback",
|
||||
clientId: env.GOOGLE_CLIENT_ID,
|
||||
clientSecret: env.GOOGLE_CLIENT_SECRET,
|
||||
callbackURL: env.GOOGLE_AUTH_CALLBACK_URL,
|
||||
}
|
||||
|
||||
exports.authenticate = async function(token, tokenSecret, profile, done) {
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
const { Cookies } = require("../../constants")
|
||||
const env = require("../../environment")
|
||||
|
||||
exports.options = {
|
||||
secretOrKey: process.env.JWT_SECRET,
|
||||
secretOrKey: env.JWT_SECRET,
|
||||
jwtFromRequest: function(ctx) {
|
||||
return ctx.cookies.get(Cookies.Auth)
|
||||
},
|
||||
|
|
|
@ -3,6 +3,7 @@ const { UserStatus } = require("../../constants")
|
|||
const CouchDB = require("../../db")
|
||||
const { StaticDatabases, generateUserID } = require("../../db/utils")
|
||||
const { compare } = require("../../hashing")
|
||||
const env = require("../../environment")
|
||||
|
||||
const INVALID_ERR = "Invalid Credentials"
|
||||
|
||||
|
@ -40,13 +41,12 @@ exports.authenticate = async function(username, password, done) {
|
|||
const payload = {
|
||||
userId: dbUser._id,
|
||||
builder: dbUser.builder,
|
||||
email: dbUser.email,
|
||||
}
|
||||
|
||||
const token = jwt.sign(payload, process.env.JWT_SECRET, {
|
||||
dbUser.token = jwt.sign(payload, env.JWT_SECRET, {
|
||||
expiresIn: "1 day",
|
||||
})
|
||||
|
||||
dbUser.token = token
|
||||
// Remove users password in payload
|
||||
delete dbUser.password
|
||||
|
||||
|
|
Loading…
Reference in New Issue