Server: add module auth with Master API
This commit is contained in:
1 parent
f324b362a5
commit
32eac12dfa
5 files changed
+23
-3
No files matched your search
@@ -46,10 +46,10 @@ export const getUser = authId => {
|
||||
.catch(err => {
|
||||
logger.info('getUser err')
|
||||
logger.info(err)
|
||||
reject(new DatabaseError(err))
|
||||
reject(err)
|
||||
})
|
||||
} catch (error) {
|
||||
reject(new DatabaseError(error))
|
||||
reject(error)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
import moduleAuth from './moduleAuth'
|
||||
|
||||
export { moduleAuth }
|
||||
@@ -0,0 +1,13 @@
|
||||
import { logger } from '../logger'
|
||||
|
||||
export const moduleAuth = async (req, res, next, db) => {
|
||||
if (req.headers.preshared === process.env.PRESHARED_GATEWAY_KEY) {
|
||||
logger.info('Module authenticated')
|
||||
next();
|
||||
} else {
|
||||
logger.error('Module authentication error')
|
||||
res.send(wrongPreshared);
|
||||
}
|
||||
}
|
||||
|
||||
export default moduleAuth
|
||||
Reference in new issue
Block a user