Merge pull request #172 from shocknet/not-auth-responses
respect NOT_AUTH constant
This commit is contained in:
commit
0fb327b8e0
4 changed files with 31 additions and 20 deletions
|
|
@ -246,7 +246,7 @@ const getGun = () => {
|
|||
const getUser = () => {
|
||||
if (!user.is) {
|
||||
logger.warn('called getUser() without being authed')
|
||||
throw new Error('NOT_AUTH')
|
||||
throw new Error(Constants.ErrorCode.NOT_AUTH)
|
||||
}
|
||||
return user
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
/** @format */
|
||||
const logger = require('winston')
|
||||
const { Constants } = require('shock-common')
|
||||
|
||||
const Key = require('../key')
|
||||
|
||||
|
|
@ -23,7 +24,7 @@ const onLastSentReqIDs = cb => {
|
|||
const user = require('../../Mediator').getUser()
|
||||
if (!user.is) {
|
||||
logger.warn('lastSentReqID() -> tried to sub without authing')
|
||||
throw new Error('NOT_AUTH')
|
||||
throw new Error(Constants.ErrorCode.NOT_AUTH)
|
||||
}
|
||||
|
||||
user.get(Key.USER_TO_LAST_REQUEST_SENT).open(data => {
|
||||
|
|
|
|||
|
|
@ -129,7 +129,7 @@ const tryAndWait = async (promGen, shouldRetry = () => false) => {
|
|||
} catch (e) {
|
||||
logger.error(e)
|
||||
logger.info(JSON.stringify(e))
|
||||
if (e.message === 'NOT_AUTH') {
|
||||
if (e.message === Constants.ErrorCode.NOT_AUTH) {
|
||||
throw e
|
||||
}
|
||||
}
|
||||
|
|
@ -159,7 +159,7 @@ const tryAndWait = async (promGen, shouldRetry = () => false) => {
|
|||
}
|
||||
} catch (e) {
|
||||
logger.error(e)
|
||||
if (e.message === 'NOT_AUTH') {
|
||||
if (e.message === Constants.ErrorCode.NOT_AUTH) {
|
||||
throw e
|
||||
}
|
||||
}
|
||||
|
|
@ -189,7 +189,7 @@ const tryAndWait = async (promGen, shouldRetry = () => false) => {
|
|||
}
|
||||
} catch (e) {
|
||||
logger.error(e)
|
||||
if (e.message === 'NOT_AUTH') {
|
||||
if (e.message === Constants.ErrorCode.NOT_AUTH) {
|
||||
throw e
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1944,7 +1944,9 @@ module.exports = async (
|
|||
} catch (err) {
|
||||
logger.info('Error in Chats poll:')
|
||||
logger.error(err)
|
||||
res.status(err.message === 'NON_AUTH' ? 401 : 500).json({
|
||||
res
|
||||
.status(err.message === Common.Constants.ErrorCode.NOT_AUTH ? 401 : 500)
|
||||
.json({
|
||||
errorMessage: typeof err === 'string' ? err : err.message
|
||||
})
|
||||
}
|
||||
|
|
@ -1966,7 +1968,9 @@ module.exports = async (
|
|||
} catch (err) {
|
||||
logger.info('Error in Avatar poll:')
|
||||
logger.error(err)
|
||||
res.status(err.message === 'NON_AUTH' ? 401 : 500).json({
|
||||
res
|
||||
.status(err.message === Common.Constants.ErrorCode.NOT_AUTH ? 401 : 500)
|
||||
.json({
|
||||
errorMessage: typeof err === 'string' ? err : err.message
|
||||
})
|
||||
}
|
||||
|
|
@ -1988,7 +1992,9 @@ module.exports = async (
|
|||
} catch (err) {
|
||||
logger.info('Error in Display Name poll:')
|
||||
logger.error(err)
|
||||
res.status(err.message === 'NON_AUTH' ? 401 : 500).json({
|
||||
res
|
||||
.status(err.message === Common.Constants.ErrorCode.NOT_AUTH ? 401 : 500)
|
||||
.json({
|
||||
errorMessage: typeof err === 'string' ? err : err.message
|
||||
})
|
||||
}
|
||||
|
|
@ -2007,7 +2013,9 @@ module.exports = async (
|
|||
} catch (err) {
|
||||
logger.info('Error in Handshake Address poll:')
|
||||
logger.error(err)
|
||||
res.status(err.message === 'NON_AUTH' ? 401 : 500).json({
|
||||
res
|
||||
.status(err.message === Common.Constants.ErrorCode.NOT_AUTH ? 401 : 500)
|
||||
.json({
|
||||
errorMessage: typeof err === 'string' ? err : err.message
|
||||
})
|
||||
}
|
||||
|
|
@ -2024,7 +2032,9 @@ module.exports = async (
|
|||
} catch (err) {
|
||||
logger.info('Error in BIO poll:')
|
||||
logger.error(err)
|
||||
res.status(err.message === 'NON_AUTH' ? 401 : 500).json({
|
||||
res
|
||||
.status(err.message === Common.Constants.ErrorCode.NOT_AUTH ? 401 : 500)
|
||||
.json({
|
||||
errorMessage: typeof err === 'string' ? err : err.message
|
||||
})
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue