mirror of
https://github.com/ditkrg/AuthorizationServerDemos.git
synced 2026-01-22 23:46:54 +00:00
real estate API now gets citizen_upn from the jwt token
This commit is contained in:
parent
404e67df29
commit
38339dbeb1
@ -8,7 +8,10 @@ const pool = new Pool({
|
|||||||
});
|
});
|
||||||
|
|
||||||
const getAllRealEstate = (request, response) => {
|
const getAllRealEstate = (request, response) => {
|
||||||
pool.query("SELECT * FROM real_estate ORDER BY id DESC", (error, results) => {
|
// The express-jwt middleware decodes the jwt token and store all claims on request.user
|
||||||
|
// https://github.com/auth0/express-jwt/issues/153#issuecomment-269498310
|
||||||
|
citizen_upn = request.user.sub;
|
||||||
|
pool.query(`SELECT * FROM real_estate WHERE citizen_upn = '${citizen_upn}' ORDER BY id DESC`, (error, results) => {
|
||||||
if (error) {
|
if (error) {
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
@ -16,10 +19,10 @@ const getAllRealEstate = (request, response) => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
// We don't need the citizen_upn here? ** Temporary **
|
|
||||||
const insertRealEstate = (request, response) => {
|
const insertRealEstate = (request, response) => {
|
||||||
const { address, area, citizen_upn } = request.body;
|
const { address, area } = request.body;
|
||||||
|
citizen_upn = request.user.sub;
|
||||||
|
console.log(citizen_upn)
|
||||||
pool.query(
|
pool.query(
|
||||||
"INSERT INTO real_estate (address, area, citizen_upn) VALUES ($1, $2, $3)",
|
"INSERT INTO real_estate (address, area, citizen_upn) VALUES ($1, $2, $3)",
|
||||||
[address, area, citizen_upn],
|
[address, area, citizen_upn],
|
||||||
|
|||||||
@ -21,7 +21,7 @@ const VehicleRegisterForm = () => {
|
|||||||
|
|
||||||
async function registerVehicle() {
|
async function registerVehicle() {
|
||||||
await apiService.registerVehicle(
|
await apiService.registerVehicle(
|
||||||
{ address, area, citizen_upn: user.profile.sub },
|
{ address, area },
|
||||||
user.access_token
|
user.access_token
|
||||||
);
|
);
|
||||||
history.push("/");
|
history.push("/");
|
||||||
|
|||||||
@ -11,7 +11,6 @@ const Table = ({ vehicleData }) => {
|
|||||||
<tr>
|
<tr>
|
||||||
<ColumnName text={"Address"} />
|
<ColumnName text={"Address"} />
|
||||||
<ColumnName text={"Area"} />
|
<ColumnName text={"Area"} />
|
||||||
<ColumnName text={"Citizen UPN"} />
|
|
||||||
<th scope="col" className="relative px-6 py-3">
|
<th scope="col" className="relative px-6 py-3">
|
||||||
<span className="sr-only">Actions</span>
|
<span className="sr-only">Actions</span>
|
||||||
</th>
|
</th>
|
||||||
@ -22,7 +21,6 @@ const Table = ({ vehicleData }) => {
|
|||||||
<tr key={vehicle.id} className="bg-gray-50">
|
<tr key={vehicle.id} className="bg-gray-50">
|
||||||
<TableData text={vehicle.address} />
|
<TableData text={vehicle.address} />
|
||||||
<TableData text={vehicle.area} />
|
<TableData text={vehicle.area} />
|
||||||
<TableData text={vehicle.citizen_upn} />
|
|
||||||
<TableData Component={EditBtns} />
|
<TableData Component={EditBtns} />
|
||||||
</tr>
|
</tr>
|
||||||
))}
|
))}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user