File tree Expand file tree Collapse file tree 1 file changed +3
-27
lines changed Expand file tree Collapse file tree 1 file changed +3
-27
lines changed Original file line number Diff line number Diff line change @@ -24,36 +24,12 @@ module.exports = function(options){
2424 var response = new Response ( res ) ;
2525
2626 oauth . authenticate ( request , response , options )
27- . then ( function ( data ) {
27+ . then ( function ( token ) {
2828 // Request is authorized.
2929 // Todo: Temporary for req.user or req.session
3030 var bearer = req . headers . authorization . replace ( 'Bearer' , '' ) . replace ( 'bearer' , '' ) . trim ( )
31- if ( config . db === 'mongo' ) {
32- return db . OAuthAccessToken . findOne ( { access_token : bearer } )
33- . populate ( 'User' )
34- . then ( function ( aT ) {
35- req . user = aT ? aT . User : { } ;
36- next ( )
37- } ) . catch ( function ( err ) {
38- console . log ( "Error while getting session" , err )
39- req . user = null
40- next ( )
41- } )
42- }
43- return db . OAuthAccessToken . findOne ( {
44- include : [ {
45- model :db . User ,
46- attributes : [ 'id' , 'username' ]
47- } ] ,
48- where : { access_token : bearer }
49- } ) . then ( function ( aT ) {
50- req . user = aT ? aT . User . toJSON ( ) : { } ;
51- next ( )
52- } ) . catch ( function ( err ) {
53- console . log ( "Error while getting session" , err )
54- req . user = null
55- next ( )
56- } )
31+ req . user = token
32+ next ( )
5733
5834 } )
5935 . catch ( function ( err ) {
You can’t perform that action at this time.
0 commit comments