Merge pull request #118 from nickago/MM-1363
Mm 1363 Limit uploads to only JPEGs for profile pictures
Этот коммит содержится в:
@@ -809,6 +809,11 @@ var GeneralTab = React.createClass({
|
|||||||
|
|
||||||
if(!this.submitActive) return;
|
if(!this.submitActive) return;
|
||||||
|
|
||||||
|
if(this.state.picture.type !== "image/jpeg") {
|
||||||
|
this.setState({client_error: "Only JPG images may be used for profile pictures"});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
formData = new FormData();
|
formData = new FormData();
|
||||||
formData.append('image', this.state.picture, this.state.picture.name);
|
formData.append('image', this.state.picture, this.state.picture.name);
|
||||||
|
|
||||||
@@ -839,11 +844,13 @@ var GeneralTab = React.createClass({
|
|||||||
updatePicture: function(e) {
|
updatePicture: function(e) {
|
||||||
if (e.target.files && e.target.files[0]) {
|
if (e.target.files && e.target.files[0]) {
|
||||||
this.setState({ picture: e.target.files[0] });
|
this.setState({ picture: e.target.files[0] });
|
||||||
|
|
||||||
|
this.submitActive = true;
|
||||||
|
this.setState({client_error:null})
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
this.setState({ picture: null });
|
this.setState({ picture: null });
|
||||||
}
|
}
|
||||||
|
|
||||||
this.submitActive = true
|
|
||||||
},
|
},
|
||||||
updateSection: function(section) {
|
updateSection: function(section) {
|
||||||
this.setState({client_error:""})
|
this.setState({client_error:""})
|
||||||
@@ -984,7 +991,7 @@ var GeneralTab = React.createClass({
|
|||||||
submit={this.submitPicture}
|
submit={this.submitPicture}
|
||||||
src={"/api/v1/users/" + user.id + "/image"}
|
src={"/api/v1/users/" + user.id + "/image"}
|
||||||
server_error={server_error}
|
server_error={server_error}
|
||||||
client_error={email_error}
|
client_error={client_error}
|
||||||
updateSection={function(e){self.updateSection("");e.preventDefault();}}
|
updateSection={function(e){self.updateSection("");e.preventDefault();}}
|
||||||
picture={this.state.picture}
|
picture={this.state.picture}
|
||||||
pictureChange={this.updatePicture}
|
pictureChange={this.updatePicture}
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user