-
Notifications
You must be signed in to change notification settings - Fork 2k
fix(users) MIME-type checking fixed on both client and server-side #1465
Changes from all commits
ad71421
b508661
4bd849d
fbd8781
9d91cb6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,7 +13,7 @@ | |
"angular-ui-router": "~0.2.18", | ||
"bootstrap": "~3.3.6", | ||
"ng-file-upload": "^12.1.0", | ||
"ng-img-crop": "ngImgCrop#^0.3.2", | ||
"ng-img-crop-full-extended": "ngImgCropFullExtended#~6.0.1", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bower does this automatically, I think because the package is named For that reason it won't work if we do: But we could do this: |
||
"owasp-password-strength-test": "~1.3.0" | ||
}, | ||
"overrides": { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,7 @@ module.exports = { | |
// bower:css | ||
'public/lib/bootstrap/dist/css/bootstrap.css', | ||
'public/lib/bootstrap/dist/css/bootstrap-theme.css', | ||
'public/lib/ng-img-crop/compile/unminified/ng-img-crop.css' | ||
'public/lib/ng-img-crop-full-extended/compile/minified/ng-img-crop.css' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @hyperreality FYI |
||
// endbower | ||
], | ||
js: [ | ||
|
@@ -18,7 +18,7 @@ module.exports = { | |
'public/lib/angular-animate/angular-animate.js', | ||
'public/lib/angular-bootstrap/ui-bootstrap-tpls.js', | ||
'public/lib/ng-file-upload/ng-file-upload.js', | ||
'public/lib/ng-img-crop/compile/unminified/ng-img-crop.js', | ||
'public/lib/ng-img-crop-full-extended/compile/minified/ng-img-crop.js', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Better include unminified version, easier for debugging and our build process should do the minification instead. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @hyperreality FYI |
||
'public/lib/angular-messages/angular-messages.js', | ||
'public/lib/angular-mocks/angular-mocks.js', | ||
'public/lib/angular-resource/angular-resource.js', | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,6 +28,14 @@ module.exports = { | |
app: { | ||
title: defaultEnvConfig.app.title + ' - Test Environment' | ||
}, | ||
uploads: { | ||
profileUpload: { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could be called just —
— for simplicity? I take it's like this so that it would be easier to add other upload settings here. Otherwise it could be just one level deep. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good point. I see that in Trustroots you simplified function names like profileUploadFileFilter too, because that function really works on any image, not just the profile uploader. |
||
dest: './modules/users/client/img/profile/uploads/', // Profile upload destination path | ||
limits: { | ||
fileSize: 100000 // Limit filesize (100kb) for testing purposes | ||
} | ||
} | ||
}, | ||
facebook: { | ||
clientID: process.env.FACEBOOK_ID || 'APP_ID', | ||
clientSecret: process.env.FACEBOOK_SECRET || 'APP_SECRET', | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,10 @@ | ||
'use strict'; | ||
|
||
module.exports.profileUploadFileFilter = function (req, file, cb) { | ||
module.exports.profileUploadFileFilter = function (req, file, callback) { | ||
if (file.mimetype !== 'image/png' && file.mimetype !== 'image/jpg' && file.mimetype !== 'image/jpeg' && file.mimetype !== 'image/gif') { | ||
return cb(new Error('Only image files are allowed!'), false); | ||
var err = new Error(); | ||
err.code = 'UNSUPPORTED_MEDIA_TYPE'; | ||
return callback(err, false); | ||
} | ||
cb(null, true); | ||
callback(null, true); | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,8 +45,11 @@ exports.getErrorMessage = function (err) { | |
case 11001: | ||
message = getUniqueErrorMessage(err); | ||
break; | ||
case 'UNSUPPORTED_MEDIA_TYPE': | ||
message = 'Unsupported filetype'; | ||
break; | ||
case 'LIMIT_FILE_SIZE': | ||
message = 'Image too big. Please maximum ' + (config.uploads.profileUpload.limits.fileSize / (1024 * 1024)).toFixed(2) + ' Mb files.'; | ||
message = 'Image too big. The maximum size allowed is ' + (config.uploads.profileUpload.limits.fileSize / (1024 * 1024)).toFixed(2) + ' Mb'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There could be a test for this, too. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
break; | ||
case 'LIMIT_UNEXPECTED_FILE': | ||
message = 'Missing `newProfilePicture` field'; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,6 +38,7 @@ | |
background: #E4E4E4; | ||
width: 300px; | ||
height: 300px; | ||
margin: 0 auto; | ||
} | ||
|
||
.social { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Should not be able to upload this as a profile picture! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While at it, this could be changed to
~
.