Skip to content

Commit c1e53e4

Browse files
author
Michael Salinger
committed
Fixed access to wrong context
1 parent d63bd43 commit c1e53e4

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

index.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,15 @@ function ExpressOAuthServer(options) {
3737
*/
3838

3939
ExpressOAuthServer.prototype.authenticate = function(options) {
40-
var server = this.server;
40+
var that = this;
4141

4242
return function(req, res, next) {
4343
var request = new Request(req);
4444
var response = new Response(res);
4545

46-
return Promise.bind(this)
46+
return Promise.bind(that)
4747
.then(function() {
48-
return server.authenticate(request, response, options);
48+
return this.server.authenticate(request, response, options);
4949
})
5050
.tap(function(token) {
5151
res.locals.oauth = { token: token };
@@ -66,15 +66,15 @@ ExpressOAuthServer.prototype.authenticate = function(options) {
6666
*/
6767

6868
ExpressOAuthServer.prototype.authorize = function(options) {
69-
var server = this.server;
69+
var that = this;
7070

7171
return function(req, res, next) {
7272
var request = new Request(req);
7373
var response = new Response(res);
7474

75-
return Promise.bind(this)
75+
return Promise.bind(that)
7676
.then(function() {
77-
return server.authorize(request, response, options);
77+
return this.server.authorize(request, response, options);
7878
})
7979
.tap(function(code) {
8080
res.locals.oauth = { code: code };
@@ -97,15 +97,15 @@ ExpressOAuthServer.prototype.authorize = function(options) {
9797
*/
9898

9999
ExpressOAuthServer.prototype.token = function(options) {
100-
var server = this.server;
100+
var that = this;
101101

102102
return function(req, res, next) {
103103
var request = new Request(req);
104104
var response = new Response(res);
105105

106-
return Promise.bind(this)
106+
return Promise.bind(that)
107107
.then(function() {
108-
return server.token(request, response, options);
108+
return this.server.token(request, response, options);
109109
})
110110
.tap(function(token) {
111111
res.locals.oauth = { token: token };

0 commit comments

Comments
 (0)