mirror of
https://github.com/bluewave-labs/Checkmate.git
synced 2026-05-18 23:48:43 -05:00
Merge pull request #252 from bluewave-labs/fix/remove-image-from-returned-user
Fix/remove image from returned user
This commit is contained in:
@@ -67,10 +67,8 @@ const handleAuthFulfilled = (state, action) => {
|
||||
state.isLoading = false;
|
||||
state.success = action.payload.success;
|
||||
state.msg = action.payload.msg;
|
||||
state.authToken = action.payload.data;
|
||||
const decodedToken = jwtDecode(action.payload.data);
|
||||
const user = { ...decodedToken };
|
||||
state.user = user;
|
||||
state.authToken = action.payload.data.token;
|
||||
state.user = action.payload.data.user;
|
||||
};
|
||||
const handleAuthRejected = (state, action) => {
|
||||
state.isLoading = false;
|
||||
|
||||
+13
-1
@@ -2,12 +2,24 @@ import { configureStore, combineReducers } from "@reduxjs/toolkit";
|
||||
import monitorsReducer from "./Features/Monitors/monitorsSlice";
|
||||
import authReducer from "./Features/Auth/authSlice";
|
||||
import storage from "redux-persist/lib/storage";
|
||||
import { persistReducer, persistStore } from "redux-persist";
|
||||
import { persistReducer, persistStore, createTransform } from "redux-persist";
|
||||
|
||||
const authTransform = createTransform(
|
||||
(inboundState) => {
|
||||
const { profileImage, ...rest } = inboundState;
|
||||
return rest;
|
||||
},
|
||||
// No transformation on rehydration
|
||||
null,
|
||||
// Only applies to auth
|
||||
{ whitelist: ["auth"] }
|
||||
);
|
||||
|
||||
const persistConfig = {
|
||||
key: "root",
|
||||
storage,
|
||||
whitielist: ["auth", "monitors"],
|
||||
transforms: [authTransform],
|
||||
};
|
||||
|
||||
const rootReducer = combineReducers({
|
||||
|
||||
@@ -55,7 +55,11 @@ const registerController = async (req, res, next) => {
|
||||
service: SERVICE_NAME,
|
||||
userId: newUser._id,
|
||||
});
|
||||
const token = issueToken(newUser._doc);
|
||||
|
||||
const userForToken = { ...newUser._doc };
|
||||
delete userForToken.profileImage;
|
||||
|
||||
const token = issueToken(userForToken);
|
||||
|
||||
// Sending email to user with pre defined template
|
||||
const template = registerTemplate("https://www.bluewavelabs.ca");
|
||||
@@ -69,7 +73,7 @@ const registerController = async (req, res, next) => {
|
||||
return res.status(200).json({
|
||||
success: true,
|
||||
msg: successMessages.AUTH_CREATE_USER,
|
||||
data: token,
|
||||
data: { user: newUser, token: token },
|
||||
});
|
||||
} catch (error) {
|
||||
error.service = SERVICE_NAME;
|
||||
@@ -108,7 +112,7 @@ const loginController = async (req, res, next) => {
|
||||
return res.status(200).json({
|
||||
success: true,
|
||||
msg: successMessages.AUTH_LOGIN_USER,
|
||||
data: token,
|
||||
data: { user: userWithoutPassword, token: token },
|
||||
});
|
||||
} catch (error) {
|
||||
error.status = 500;
|
||||
|
||||
Reference in New Issue
Block a user