Skip to content

Commit

Permalink
security review, api key related data moved to backend
Browse files Browse the repository at this point in the history
  • Loading branch information
dhafer94 committed Jan 3, 2022
1 parent 4b987e0 commit b7b7c4f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
21 changes: 10 additions & 11 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ import ImageLinkForm from './Components/ImageLinkForm/ImageLinkForm';
import Rank from './Components/Rank/Rank';
import './App.css';

const app = new Clarifai.App({
apiKey: 'apiKey',
});

const initialState = {
input: '',
imageUrl: '',
Expand Down Expand Up @@ -76,12 +74,14 @@ class App extends Component {
};
onPictureSubmit = () => {
this.setState({ imageUrl: this.state.input });
app.models
.predict(
Clarifai.FACE_DETECT_MODEL,
// THE JPG
this.state.input,
)
fetch('http://localhost:3001/imageUrl', {
method: 'post',
headers: { 'content-Type': 'application/json' },
body: JSON.stringify({
input: this.state.input,
})
})
.then(response => response.json())
.then((response) => {
if (response) {
fetch('http://localhost:3001/image', {
Expand All @@ -91,7 +91,7 @@ class App extends Component {
id: this.state.user.id,
})
})
.then(res => res.json())
.then(response => response.json())
.then(count => {
this.setState(Object.assign(this.state.user, {
entries: count
Expand All @@ -100,7 +100,6 @@ class App extends Component {
.catch(console.log);

}

this.displayFaceBox(this.calculateFaceLocation(response));
})
// console.log(response);
Expand Down
4 changes: 2 additions & 2 deletions src/Components/Register/Register.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class Register extends React.Component {
})
.then(res => res.json())
.then(user => {
if (user) {
if (user.id) {
this.props.loadUser(user);
this.props.onRouteChange('home');

Expand Down Expand Up @@ -88,7 +88,7 @@ class Register extends React.Component {
<input
className='b ph3 pv2 input-reset ba b--black bg-transparent grow pointer f6 dib'
type='submit'
value='Sign in'
value='Register'
onClick={this.onRegister}
/>
</div>
Expand Down

0 comments on commit b7b7c4f

Please sign in to comment.