-
Notifications
You must be signed in to change notification settings - Fork 38
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
Image in user profile #427
Comments
@xauxatz Which part / where you stuck? |
I have attached the source code of the app here, I guess that is the easiest. I am able to upload a photo which is then also shown on the screen - but it does not seem to be stored in the correct field in the collection.
|
@xauxatz oops, that is a bug. I'll give you workaround in few minutes, so you can fix at your side before I deploy new version. |
"updateUserAccount": function(userId, data) {
if(!data || !Object.keys(data).length) {
return;
}
// Only admin or owner
if(!(Users.isAdmin(this.userId) || userId == this.userId)) {
throw new Meteor.Error(403, "Access denied.");
}
// deepen: convert { "x.y": "val" } into { x: { y: "val" }}
var userData = objectUtils.deepen(data);
// non-admin user can change only .profile, .private and .public
if(!Users.isAdmin(this.userId)) {
let allowedKeys = ["profile", "private", "public"];
for(var key in userData) {
if(allowedKeys.indexOf(key) < 0) {
throw new Meteor.Error(403, "You are not allowed to modify \"" + key + "\".");
}
}
}
// flatten: convert { x: { y: "val" }} into { "x.y": "val" }
userData = objectUtils.flatten(userData);
// update
Users.update(userId, { $set: userData });
}, OR you can change kitchen's template: Find directory where meteor kitchen is installed, on Linux and Mac it is That will allow writing
|
Thanks a lot, Perak - I look forward to the last bit of code change! |
Hi Petar - do you have time to make the last code suggested by you, in order to display the image?
Best regards / Venlig hilsen
Claus Skaaning
Mobil +45 20690771
… Den 26. nov. 2018 kl. 11.34 skrev Petar Korponaić ***@***.***>:
@xauxatz
First, in your /server/server.js change updateUserAccount method to:
"updateUserAccount": function(userId, data) {
if(!data || !Object.keys(data).length) {
return;
}
// Only admin or owner
if(!(Users.isAdmin(this.userId) || userId == this.userId)) {
throw new Meteor.Error(403, "Access denied.");
}
// deepen: convert { "x.y": "val" } into { x: { y: "val" }}
var userData = objectUtils.deepen(data);
// non-admin user can change only .profile, .private and .public
if(!Users.isAdmin(this.userId)) {
let allowedKeys = ["profile", "private", "public"];
for(var key in userData) {
if(allowedKeys.indexOf(key) < 0) {
throw new Meteor.Error(403, "You are not allowed to modify \"" + key + "\".");
}
}
}
// flatten: convert { x: { y: "val" }} into { "x.y": "val" }
userData = objectUtils.flatten(userData);
// update
Users.update(userId, { $set: userData });
},
OR you can change kitchen's template:
Find directory where meteor kitchen is installed, on Linux and Mac it is ~/.meteor-kitchen/ by default, and there you will find /templates/blaze/code/server_accounts.js and change method here.
That will allow writing profile data and image ID will be saved in user's document
But you will have hard time to display image (because you have only ID, so you'll need to query "images" collection to find image URL (and that's full image, not thumbnail...). This requires change form template ("image" field). I'll try to find time later today/tonight and give you code.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
|
I have been struggling several hours now to insert a picture into a standard user profile. I just can't figure it out! I have been studying the File Upload example in detail - but cannot get it to work within my extremely simple app.
I simple want to extend the normal user profile with an extra field to hold an image for the user. Can't this be done without adding extra stuff to Meteorkitchen?
The text was updated successfully, but these errors were encountered: