Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Profile upload #974

Merged
merged 2 commits into from
Feb 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions backend/src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ app.use(express.urlencoded({ extended: true }));

app.use(compression());

// default options
app.use(fileUpload());
// // default options
// app.use(fileUpload());

// Here our API Routes

Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,10 @@
const mongoose = require('mongoose');

const updateProfile = async (userModel, req, res) => {
if (req.body.email === '[email protected]') {
return res.status(404).json({
success: false,
result: null,
message: 'you cant update this demo profile',
});
}
const User = mongoose.model(userModel);

const reqUserName = userModel.toLowerCase();
const userProfile = req[reqUserName];

let updates = req.body.photo
? {
email: req.body.email,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,6 @@ const bcrypt = require('bcryptjs');
const { generate: uniqueId } = require('shortid');

const updateProfilePassword = async (userModel, req, res) => {
if (req.admin.email === '[email protected]') {
return res.status(404).json({
success: false,
result: null,
message: 'you cant update this demo profile',
});
}
const UserPassword = mongoose.model(userModel + 'Password');

const reqUserName = userModel.toLowerCase();
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 1 addition & 3 deletions backend/src/routes/coreRoutes/coreApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,7 @@ router
.route('/admin/profile/update')
.patch(
hasPermission('update'),
catchErrors(
catchErrors(singleStorageUpload({ entity: 'admin', fieldName: 'photo', fileType: 'image' }))
),
singleStorageUpload({ entity: 'admin', fieldName: 'photo', fileType: 'image' }),
catchErrors(adminController.updateProfile)
);

Expand Down
7 changes: 4 additions & 3 deletions frontend/.env
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# ----> Remove # comment

#VITE_BACKEND_SERVER="http://your_backend_url_server.com/"
#PROD = false
# ----> Remove # comment
VITE_FILE_BASE_URL = 'http://localhost:8888/'
VITE_BACKEND_SERVER="http://your_backend_url_server.com/"
PROD = false
Loading