Move the helpers out of the individual api versions, this way others can make usage of them without duplicating code
parent
38ddce1d9d
commit
40967e2720
@ -1,12 +0,0 @@ |
||||
RocketChat.API.default.helperMethods.set('getLoggedInUser', function _getLoggedInUser() { |
||||
let user; |
||||
|
||||
if (this.request.headers['x-auth-token'] && this.request.headers['x-user-id']) { |
||||
user = RocketChat.models.Users.findOne({ |
||||
'_id': this.request.headers['x-user-id'], |
||||
'services.resume.loginTokens.hashedToken': Accounts._hashLoginToken(this.request.headers['x-auth-token']) |
||||
}); |
||||
} |
||||
|
||||
return user; |
||||
}); |
||||
@ -1,4 +1,4 @@ |
||||
RocketChat.API.v1.helperMethods.set('getLoggedInUser', function _getLoggedInUser() { |
||||
RocketChat.API.helperMethods.set('getLoggedInUser', function _getLoggedInUser() { |
||||
let user; |
||||
|
||||
if (this.request.headers['x-auth-token'] && this.request.headers['x-user-id']) { |
||||
@ -1,5 +1,5 @@ |
||||
//Convenience method, almost need to turn it into a middleware of sorts
|
||||
RocketChat.API.v1.helperMethods.set('getUserFromParams', function _getUserFromParams() { |
||||
RocketChat.API.helperMethods.set('getUserFromParams', function _getUserFromParams() { |
||||
const doesntExist = { _doesntExist: true }; |
||||
let user; |
||||
const params = this.requestParams(); |
||||
@ -1,4 +1,4 @@ |
||||
RocketChat.API.v1.helperMethods.set('isUserFromParams', function _isUserFromParams() { |
||||
RocketChat.API.helperMethods.set('isUserFromParams', function _isUserFromParams() { |
||||
const params = this.requestParams(); |
||||
|
||||
return (!params.userId && !params.username && !params.user) || |
||||
@ -1,4 +1,4 @@ |
||||
RocketChat.API.v1.helperMethods.set('parseJsonQuery', function _parseJsonQuery() { |
||||
RocketChat.API.helperMethods.set('parseJsonQuery', function _parseJsonQuery() { |
||||
let sort; |
||||
if (this.queryParams.sort) { |
||||
try { |
||||
@ -1,3 +1,3 @@ |
||||
RocketChat.API.v1.helperMethods.set('requestParams', function _requestParams() { |
||||
RocketChat.API.helperMethods.set('requestParams', function _requestParams() { |
||||
return ['POST', 'PUT'].includes(this.request.method) ? this.bodyParams : this.queryParams; |
||||
}); |
||||
Loading…
Reference in new issue