style: replace var with let in /test files (#6164)
This commit is contained in:
@@ -1,13 +1,13 @@
|
||||
// from https://github.com/pedroetb/node-oauth2-server-example
|
||||
|
||||
var Http = require("http")
|
||||
var path = require("path")
|
||||
var express = require("express")
|
||||
var bodyParser = require("body-parser")
|
||||
var oauthserver = require("oauth2-server")
|
||||
var cors = require("cors")
|
||||
let Http = require("http")
|
||||
let path = require("path")
|
||||
let express = require("express")
|
||||
let bodyParser = require("body-parser")
|
||||
let oauthserver = require("oauth2-server")
|
||||
let cors = require("cors")
|
||||
|
||||
var app = express()
|
||||
let app = express()
|
||||
|
||||
app.use(cors())
|
||||
|
||||
@@ -34,7 +34,7 @@ app.get("*", app.oauth.authorise(), function (req, res) {
|
||||
app.use(app.oauth.errorHandler())
|
||||
|
||||
function startServer() {
|
||||
var httpServer = Http.createServer(app)
|
||||
let httpServer = Http.createServer(app)
|
||||
httpServer.listen("3231")
|
||||
|
||||
return function stopServer() {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// from https://github.com/pedroetb/node-oauth2-server-example
|
||||
|
||||
var config = {
|
||||
let config = {
|
||||
clients: [{
|
||||
clientId: "application",
|
||||
clientSecret: "secret"
|
||||
@@ -21,7 +21,7 @@ var config = {
|
||||
* Dump the memory storage content (for debug).
|
||||
*/
|
||||
|
||||
var dump = function () {
|
||||
let dump = function () {
|
||||
|
||||
console.log("clients", config.clients)
|
||||
console.log("confidentialClients", config.confidentialClients)
|
||||
@@ -33,9 +33,9 @@ var dump = function () {
|
||||
* Methods used by all grant types.
|
||||
*/
|
||||
|
||||
var getAccessToken = function (bearerToken, callback) {
|
||||
let getAccessToken = function (bearerToken, callback) {
|
||||
|
||||
var tokens = config.tokens.filter(function (token) {
|
||||
let tokens = config.tokens.filter(function (token) {
|
||||
|
||||
return token.accessToken === bearerToken
|
||||
})
|
||||
@@ -43,14 +43,14 @@ var getAccessToken = function (bearerToken, callback) {
|
||||
return callback(false, tokens[0])
|
||||
}
|
||||
|
||||
var getClient = function (clientId, clientSecret, callback) {
|
||||
let getClient = function (clientId, clientSecret, callback) {
|
||||
|
||||
var clients = config.clients.filter(function (client) {
|
||||
let clients = config.clients.filter(function (client) {
|
||||
|
||||
return client.clientId === clientId && client.clientSecret === clientSecret
|
||||
})
|
||||
|
||||
var confidentialClients = config.confidentialClients.filter(function (client) {
|
||||
let confidentialClients = config.confidentialClients.filter(function (client) {
|
||||
|
||||
return client.clientId === clientId && client.clientSecret === clientSecret
|
||||
})
|
||||
@@ -58,9 +58,9 @@ var getClient = function (clientId, clientSecret, callback) {
|
||||
callback(false, clients[0] || confidentialClients[0])
|
||||
}
|
||||
|
||||
var grantTypeAllowed = function (clientId, grantType, callback) {
|
||||
let grantTypeAllowed = function (clientId, grantType, callback) {
|
||||
|
||||
var clientsSource,
|
||||
let clientsSource,
|
||||
clients = []
|
||||
|
||||
if (grantType === "password") {
|
||||
@@ -79,7 +79,7 @@ var grantTypeAllowed = function (clientId, grantType, callback) {
|
||||
callback(false, clients.length)
|
||||
}
|
||||
|
||||
var saveAccessToken = function (accessToken, clientId, expires, user, callback) {
|
||||
let saveAccessToken = function (accessToken, clientId, expires, user, callback) {
|
||||
|
||||
config.tokens.push({
|
||||
accessToken: accessToken,
|
||||
@@ -95,9 +95,9 @@ var saveAccessToken = function (accessToken, clientId, expires, user, callback)
|
||||
* Method used only by password grant type.
|
||||
*/
|
||||
|
||||
var getUser = function (username, password, callback) {
|
||||
let getUser = function (username, password, callback) {
|
||||
|
||||
var users = config.users.filter(function (user) {
|
||||
let users = config.users.filter(function (user) {
|
||||
|
||||
return user.username === username && user.password === password
|
||||
})
|
||||
@@ -109,14 +109,14 @@ var getUser = function (username, password, callback) {
|
||||
* Method used only by client_credentials grant type.
|
||||
*/
|
||||
|
||||
var getUserFromClient = function (clientId, clientSecret, callback) {
|
||||
let getUserFromClient = function (clientId, clientSecret, callback) {
|
||||
|
||||
var clients = config.confidentialClients.filter(function (client) {
|
||||
let clients = config.confidentialClients.filter(function (client) {
|
||||
|
||||
return client.clientId === clientId && client.clientSecret === clientSecret
|
||||
})
|
||||
|
||||
var user
|
||||
let user
|
||||
|
||||
if (clients.length) {
|
||||
user = {
|
||||
|
||||
Reference in New Issue
Block a user