我一直在试图弄清楚如何将String bookWanted和customerName转换为bookWritten和买方名称,但是我似乎无法弄清楚如何做到这一点。
我曾尝试将字符串制成后更改为一本书,但我不能这样做。
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
const jwt_verifier_1 = require("@okta/jwt-verifier");
// const OktaJwtVerifier = require('okta/jwt-verifier');
const oktaJwtVerifier = new jwt_verifier_1.OktaJwtVerifier({
clientId: '0oavj2s8pN39hTh0v356',
issuer: 'https://dev-214594.okta.com/oauth2/default'
});
function oktaAuth(req, res, next) {
return __awaiter(this, void 0, void 0, function* () {
try {
const token = req.token;
if (!token) {
return res.status(401).send('Not Authorised');
}
const jwt = yield oktaJwtVerifier.verifyAccessToken(token);
req.user = {
uid: jwt.claims.uid,
email: jwt.claims.sub
};
next();
}
catch (err) {
return res.status(401).send(err.message);
}
});
}
exports.oktaAuth = oktaAuth;
答案 0 :(得分:0)
您需要了解
if(books.get(b).equals(bookWritten)) {
和
if(people.get(b).equals(buyerName)) {
它们在Book
和Person
对象上做相等的事情,默认情况下会执行return (this == obj)
,即:仅当它们是同一个对象时,它返回true(如果您未覆盖equals
或Book
中的Person
您需要注意,您对用户输入的bookWanted
和customerName
没有做任何事情。