location update optimized with schema changes and geoJson Compatability testing endpoint with encrypted key authorization
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
import {
|
||||
createLocation,
|
||||
getLocationByQuery,
|
||||
getLocationByRadius,
|
||||
} from "../models/Location/operations";
|
||||
|
||||
export const createLocationController = async (req, res) => {
|
||||
try {
|
||||
const { user } = res.locals;
|
||||
console.log("BG LOCATIONREQUEST BODY", req.body, user);
|
||||
// const location = await createLocation({ ...req.body, user: user?.id });
|
||||
res.status(200).json({ location: "location" });
|
||||
} catch (error) {
|
||||
res.status(500).json({ error: error.message });
|
||||
}
|
||||
};
|
||||
|
||||
export const getLocationController = async (req, res) => {
|
||||
try {
|
||||
const location = await getLocationByQuery(req.query);
|
||||
res.status(200).json(location);
|
||||
} catch (error) {
|
||||
res.status(500).json({ error: error.message });
|
||||
}
|
||||
};
|
||||
@@ -4,6 +4,7 @@ import dayjs from "dayjs";
|
||||
import {
|
||||
getAccessToken,
|
||||
getRefreshToken,
|
||||
getEncryptedPayload,
|
||||
} from "../middlewares/jwt.middleware.js";
|
||||
|
||||
export const createUserController = async (req, res, next) => {
|
||||
@@ -45,14 +46,20 @@ export const loginController = async (req, res, next) => {
|
||||
}
|
||||
|
||||
const accessToken = getAccessToken({ id: userExists._id });
|
||||
const encryptedKey = getEncryptedPayload({ id: userExists._id });
|
||||
const refreshToken = getRefreshToken();
|
||||
|
||||
userExists.refreshToken = refreshToken;
|
||||
await userExists.save();
|
||||
|
||||
res
|
||||
.status(200)
|
||||
.json({ result: { accessToken, refreshToken, name: userExists?.name } });
|
||||
res.status(200).json({
|
||||
result: {
|
||||
accessToken,
|
||||
refreshToken,
|
||||
encryptedKey,
|
||||
name: userExists?.name,
|
||||
},
|
||||
});
|
||||
} catch (error) {
|
||||
console.log("loginController Error", error);
|
||||
next(error);
|
||||
@@ -73,4 +80,3 @@ export const renewAccessTokenController = async (req, res, next) => {
|
||||
next(error);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user