diff --git a/ghost/admin/app/controllers/setup.js b/ghost/admin/app/controllers/setup.js index 1e1fcf3387..34f457c943 100644 --- a/ghost/admin/app/controllers/setup.js +++ b/ghost/admin/app/controllers/setup.js @@ -3,7 +3,7 @@ import {inject as service} from '@ember/service'; /* eslint-disable camelcase, ghost/ember/alias-model-in-controller */ import Controller, {inject as controller} from '@ember/controller'; import ValidationEngine from 'ghost-admin/mixins/validation-engine'; -import {action, get} from '@ember/object'; +import {action} from '@ember/object'; import {htmlSafe} from '@ember/template'; import {isInvalidError} from 'ember-ajax/errors'; import {isVersionMismatchError} from 'ghost-admin/services/ajax'; @@ -27,7 +27,6 @@ export default class SetupController extends Controller.extend(ValidationEngine) blogTitle = null; email = ''; flowErrors = ''; - profileImage = null; name = null; password = null; @@ -44,11 +43,6 @@ export default class SetupController extends Controller.extend(ValidationEngine) } } - @action - setImage(image) { - this.set('profileImage', image); - } - @task(function* () { return yield this._passwordSetup(); }) @@ -85,38 +79,6 @@ export default class SetupController extends Controller.extend(ValidationEngine) }) authenticate; - /** - * Uploads the given data image, then sends the changed user image property to the server - * @param {Object} user User object, returned from the 'setup' api call - * @return {RSVP.Promise} A promise that takes care of both calls - */ - _sendImage(user) { - let formData = new FormData(); - let imageFile = this.profileImage; - let uploadUrl = this.get('ghostPaths.url').api('images', 'upload'); - - formData.append('file', imageFile, imageFile.name); - formData.append('purpose', 'profile_image'); - - return this.ajax.post(uploadUrl, { - data: formData, - processData: false, - contentType: false, - dataType: 'text' - }).then((response) => { - let [image] = get(JSON.parse(response), 'images'); - let imageUrl = image.url; - let usersUrl = this.get('ghostPaths.url').api('users', user.id.toString()); - user.profile_image = imageUrl; - - return this.ajax.put(usersUrl, { - data: { - users: [user] - } - }); - }); - } - _passwordSetup() { let setupProperties = ['blogTitle', 'name', 'email', 'password']; let data = this.getProperties(setupProperties); @@ -186,14 +148,6 @@ export default class SetupController extends Controller.extend(ValidationEngine) async _afterAuthentication(result) { await this.session.handleAuthentication(); - if (this.profileImage) { - return this._sendImage(result.users[0]) - .then(() => (this.router.transitionTo('setup.done'))) - .catch((resp) => { - this.notifications.showAPIError(resp, {key: 'setup.blog-details'}); - }); - } else { - return this.router.transitionTo('setup.done'); - } + return this.router.transitionTo('setup.done'); } } diff --git a/ghost/admin/app/controllers/signup.js b/ghost/admin/app/controllers/signup.js index 5e8fcb7535..32a7180eb3 100644 --- a/ghost/admin/app/controllers/signup.js +++ b/ghost/admin/app/controllers/signup.js @@ -1,6 +1,5 @@ import Controller from '@ember/controller'; import {alias} from '@ember/object/computed'; -import {get} from '@ember/object'; import {isArray as isEmberArray} from '@ember/array'; import { isVersionMismatchError @@ -17,7 +16,6 @@ export default Controller.extend({ settings: service(), flowErrors: '', - profileImage: null, signupDetails: alias('model'), @@ -26,10 +24,6 @@ export default Controller.extend({ return this.signupDetails.validate({property}); }, - setImage(image) { - this.set('profileImage', image); - }, - submit(event) { event.preventDefault(); this.signup.perform(); @@ -49,7 +43,6 @@ export default Controller.extend({ try { yield this._authenticateWithPassword(); - yield this._sendImage.perform(); } catch (error) { notifications.showAPIError(error, {key: 'signup.complete'}); } @@ -98,31 +91,5 @@ export default Controller.extend({ return this.session .authenticate('authenticator:cookie', email, password); - }, - - _sendImage: task(function* () { - let formData = new FormData(); - let imageFile = this.profileImage; - let uploadUrl = this.get('ghostPaths.url').api('images', 'upload'); - - if (imageFile) { - formData.append('file', imageFile, imageFile.name); - formData.append('purpose', 'profile_image'); - - let user = this.session.user; - let response = yield this.ajax.post(uploadUrl, { - data: formData, - processData: false, - contentType: false, - dataType: 'text' - }); - - let [image] = get(JSON.parse(response), 'images'); - let imageUrl = image.url; - - user.set('profileImage', imageUrl); - - return yield user.save(); - } - }) + } });