File tree 1 file changed +17
-0
lines changed
1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change 1
1
// Helper functions for accessing the twitter API.
2
2
var OAuth = require ( './OAuth1Client' ) ;
3
3
var Parse = require ( 'parse/node' ) . Parse ;
4
+ var logger = require ( '../logger' ) ;
4
5
5
6
// Returns a promise that fulfills iff this user id is valid.
6
7
function validateAuthData ( authData , options ) {
8
+ if ( Array . isArray ( options ) ) {
9
+ let consumer_key = authData . consumer_key ;
10
+ if ( ! consumer_key ) {
11
+ logger . error ( 'Twitter Auth' , 'Multiple twitter configurations are available, by no consumer_key was sent by the client.' ) ;
12
+ throw new Parse . Error ( Parse . Error . OBJECT_NOT_FOUND , 'Twitter auth is invalid for this user.' ) ;
13
+ }
14
+ options = options . filter ( ( option ) => {
15
+ return option . consumer_key == consumer_key ;
16
+ } ) ;
17
+
18
+ if ( options . length == 0 ) {
19
+ logger . error ( 'Twitter Auth' , 'Cannot find a configuration for the provided consumer_key' ) ;
20
+ throw new Parse . Error ( Parse . Error . OBJECT_NOT_FOUND , 'Twitter auth is invalid for this user.' ) ;
21
+ }
22
+ options = options [ 0 ] ;
23
+ }
7
24
var client = new OAuth ( options ) ;
8
25
client . host = "api.twitter.com" ;
9
26
client . auth_token = authData . auth_token ;
You can’t perform that action at this time.
0 commit comments