Skip to content

Commit 1e6f05a

Browse files
committed
Merge pull request #1076 from Automattic/add/oauth-request-verification-code
Using a function for oauth constants
2 parents 9051e8c + 73db0d9 commit 1e6f05a

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

config/empty-secrets.json

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
11
{
2-
"wpcom_calypso_rest_api_key": false,
3-
"desktop_oauth_client_id": "",
4-
"desktop_oauth_client_secret": ""
2+
"wpcom_calypso_rest_api_key": false
53
}

server/api/oauth.js

+10-8
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,14 @@ var req = require( 'superagent' ),
99
*/
1010
var config = require( 'config' );
1111

12-
const oauth = {
13-
client_id: config( 'desktop_oauth_client_id' ),
14-
client_secret: config( 'desktop_oauth_client_secret' ),
15-
wpcom_supports_2fa: true,
16-
grant_type: 'password'
17-
};
12+
function oauth() {
13+
return {
14+
client_id: config( 'desktop_oauth_client_id' ),
15+
client_secret: config( 'desktop_oauth_client_secret' ),
16+
wpcom_supports_2fa: true,
17+
grant_type: 'password'
18+
}
19+
}
1820

1921
/*
2022
* Proxies an oauth login request to the WP API
@@ -25,7 +27,7 @@ function proxyOAuth( request, response ) {
2527
var data = Object.assign( {}, {
2628
username: request.body.username,
2729
password: request.body.password
28-
}, oauth );
30+
}, oauth() );
2931

3032
if ( request.body.auth_code ) {
3133
// Pass along the one-time password
@@ -78,7 +80,7 @@ function sms( request, response ) {
7880
username: request.body.username,
7981
password: request.body.password,
8082
wpcom_resend_otp: true
81-
}, oauth );
83+
}, oauth() );
8284

8385
req.post( config( 'desktop_oauth_token_endpoint' ) )
8486
.type( 'form' )

0 commit comments

Comments
 (0)