Skip to content

Commit

Permalink
Try to fix heroku
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkusPaulsen committed Nov 13, 2019
1 parent 1868960 commit 0b3c96a
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 12 deletions.
1 change: 1 addition & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
theSpoon_jwtPrivateKey=mySecureKey
1 change: 1 addition & 0 deletions Procfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
web: node server.js
2 changes: 1 addition & 1 deletion mobileApp/components/login/login.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export default class LoginScreen extends Component {
password: this.state.password,
isRestaurantOwner: false})
;
let res = await fetch('http://192.168.1.110:5000/api/user/login/', {
let res = await fetch('http://thespoon.herokuapp.com/api/user/login/', {
method: 'POST',
headers: {
Accept: 'application/json',
Expand Down
2 changes: 1 addition & 1 deletion server.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ app.get("*", (req, res) => {

//END OF THE REQUIRED CODE TO MAKE THE DEPLOY WORK

const port = process.env.PORT || 5000;
const port = process.env.PORT || 80;

app.listen(port, () => console.log('Server started on port ' + port));

30 changes: 24 additions & 6 deletions thespoon/src/components/authentification/LogIn.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { Component } from 'react';
import { ajax } from 'rxjs/ajax';
import paths from '../../constants/paths';
import { IconExit, IconEmail, IconPassword } from '../Icons';
import {Modal} from "react-bootstrap";
import {Modal, DropdownButton, Dropdown} from "react-bootstrap";
import FilterLink from "../../containers/FilterModalLink";
import {authentificationModalVisibilityFilters} from "../../constants/authentificationModalVisibiltyFilters";
import Form from 'react-validation/build/form';
Expand Down Expand Up @@ -39,6 +39,8 @@ class LogIn extends Component {

this.submitted = false;
this.handleSubmit = this.handleSubmit.bind(this);
this.activateIsRestaurantOwner = this.activateIsRestaurantOwner.bind(this);
this.deactivateIsRestaurantOwner = this.activateIsRestaurantOwner.bind(this);
}

handleSubmit = event => {
Expand All @@ -57,14 +59,15 @@ class LogIn extends Component {

if (validation.isValid) {
let thisTemp = this;
console.log(paths['restApi']['login']);
console.log(this.state);
ajax({
url: paths['restApi']['login'],
method: 'POST',
headers: {},
headers: {'Content-Type': 'application/json'},
body: {
email: this.state.email,
password:this.state.password
username: this.state.username,
password: this.state.password,
isRestaurantOwner: this.state.isRestaurantOwner,
}
}).subscribe(
function (next) {
Expand All @@ -81,7 +84,15 @@ class LogIn extends Component {
}
}
);
}
};

activateIsRestaurantOwner = () => {
this.setState({ isRestaurantOwner: true })
};

deactivateIsRestaurantOwner = () => {
this.setState({ isRestaurantOwner: false })
};

render() {
let validation = this.submitted ? // if the form has been submitted at least once
Expand All @@ -93,6 +104,13 @@ class LogIn extends Component {
<div className="sign-up">
<Form ref={ (c) => { this.form = c; }} onSubmit={this.handleSubmit}>
<h2 className="title">Log in</h2>
<div className="input-field">
<DropdownButton id="dropdown-basic-button" title="Dropdown button">
<Dropdown.Item onClick={this.activateIsRestaurantOwner}>Restaurant Owner</Dropdown.Item>
<Dropdown.Item onClick={this.deactivateIsRestaurantOwner}>Customer</Dropdown.Item>
</DropdownButton>
</div>

<div className="input-field">
<IconEmail />
<Input type="username" id="username" name="username" placeholder="Username"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class RegisterCustomer extends Component {
ajax({
url: paths['restApi']['registrationCustomer'],
method: 'POST',
headers: {},
headers: {'Content-Type': 'application/json'},
body: {
email: this.state.email,
password:this.state.password,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,12 @@ class RegisterRestaurantowner extends Component {
ajax({
url: paths['restApi']['registrationRestaurantOwner'],
method: 'POST',
headers: {},
headers: {'Content-Type': 'application/json'},
body: {
email: this.state.email,
password:this.state.password,
username: this.state.username,
firstName:this.state.firstName,
name:this.state.firstName,
surname:this.state.surname
}
}).subscribe(
Expand Down
2 changes: 1 addition & 1 deletion thespoon/src/constants/paths.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
let BACKEND = "localhost:80";
let BACKEND = "thespoon.herokuapp.com";

const paths = {
restApi: {
Expand Down

0 comments on commit 0b3c96a

Please sign in to comment.