mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-24 23:48:13 -05:00
Updated profile image uploads in setup/signup flows for new /images/upload/ endpoint
This commit is contained in:
parent
738823d8f8
commit
43b6f7add2
2 changed files with 13 additions and 14 deletions
|
@ -86,9 +86,10 @@ export default Controller.extend(ValidationEngine, {
|
||||||
_sendImage(user) {
|
_sendImage(user) {
|
||||||
let formData = new FormData();
|
let formData = new FormData();
|
||||||
let imageFile = this.get('profileImage');
|
let imageFile = this.get('profileImage');
|
||||||
let uploadUrl = this.get('ghostPaths.url').api('images');
|
let uploadUrl = this.get('ghostPaths.url').api('images', 'upload');
|
||||||
|
|
||||||
formData.append('uploadimage', imageFile, imageFile.name);
|
formData.append('file', imageFile, imageFile.name);
|
||||||
|
formData.append('purpose', 'profile_image');
|
||||||
|
|
||||||
return this.get('ajax').post(uploadUrl, {
|
return this.get('ajax').post(uploadUrl, {
|
||||||
data: formData,
|
data: formData,
|
||||||
|
@ -96,7 +97,8 @@ export default Controller.extend(ValidationEngine, {
|
||||||
contentType: false,
|
contentType: false,
|
||||||
dataType: 'text'
|
dataType: 'text'
|
||||||
}).then((response) => {
|
}).then((response) => {
|
||||||
let imageUrl = get(JSON.parse(response), 'url');
|
let [image] = get(JSON.parse(response), 'images');
|
||||||
|
let imageUrl = image.url;
|
||||||
let usersUrl = this.get('ghostPaths.url').api('users', user.id.toString());
|
let usersUrl = this.get('ghostPaths.url').api('users', user.id.toString());
|
||||||
user.profile_image = imageUrl;
|
user.profile_image = imageUrl;
|
||||||
|
|
||||||
|
|
|
@ -49,7 +49,7 @@ export default Controller.extend({
|
||||||
|
|
||||||
try {
|
try {
|
||||||
yield this._authenticateWithPassword();
|
yield this._authenticateWithPassword();
|
||||||
yield this.get('_sendImage').perform();
|
yield this._sendImage.perform();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
notifications.showAPIError(error, {key: 'signup.complete'});
|
notifications.showAPIError(error, {key: 'signup.complete'});
|
||||||
}
|
}
|
||||||
|
@ -99,10 +99,11 @@ export default Controller.extend({
|
||||||
_sendImage: task(function* () {
|
_sendImage: task(function* () {
|
||||||
let formData = new FormData();
|
let formData = new FormData();
|
||||||
let imageFile = this.get('profileImage');
|
let imageFile = this.get('profileImage');
|
||||||
let uploadUrl = this.get('ghostPaths.url').api('images');
|
let uploadUrl = this.get('ghostPaths.url').api('images', 'upload');
|
||||||
|
|
||||||
if (imageFile) {
|
if (imageFile) {
|
||||||
formData.append('uploadimage', imageFile, imageFile.name);
|
formData.append('file', imageFile, imageFile.name);
|
||||||
|
formData.append('purpose', 'profile_image');
|
||||||
|
|
||||||
let user = yield this.get('session.user');
|
let user = yield this.get('session.user');
|
||||||
let response = yield this.get('ajax').post(uploadUrl, {
|
let response = yield this.get('ajax').post(uploadUrl, {
|
||||||
|
@ -112,16 +113,12 @@ export default Controller.extend({
|
||||||
dataType: 'text'
|
dataType: 'text'
|
||||||
});
|
});
|
||||||
|
|
||||||
let imageUrl = get(JSON.parse(response), 'url');
|
let [image] = get(JSON.parse(response), 'images');
|
||||||
let usersUrl = this.get('ghostPaths.url').api('users', user.id.toString());
|
let imageUrl = image.url;
|
||||||
|
|
||||||
user.profile_image = imageUrl;
|
user.set('profileImage', imageUrl);
|
||||||
|
|
||||||
return yield this.get('ajax').put(usersUrl, {
|
return yield user.save();
|
||||||
data: {
|
|
||||||
users: [user]
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Reference in a new issue