Send credentials with API calls, to make HTTP auth work

Also serve OSM tiles with HTTPS
This commit is contained in:
Lucas Verney 2017-04-26 20:02:55 +02:00
parent f7c7459d96
commit 847a5954d5
6 changed files with 19 additions and 15 deletions

View File

@ -4,7 +4,7 @@ require('es6-promise').polyfill()
require('isomorphic-fetch')
export const getFlats = function (callback) {
fetch('/api/v1/flats')
fetch('/api/v1/flats', { credentials: 'same-origin' })
.then(function (response) {
return response.json()
}).then(function (json) {
@ -22,7 +22,10 @@ export const getFlats = function (callback) {
}
export const getFlat = function (flatId, callback) {
fetch('/api/v1/flat/' + encodeURIComponent(flatId))
fetch(
'/api/v1/flat/' + encodeURIComponent(flatId),
{ credentials: 'same-origin' }
)
.then(function (response) {
return response.json()
}).then(function (json) {
@ -40,6 +43,7 @@ export const updateFlatStatus = function (flatId, newStatus, callback) {
fetch(
'/api/v1/flat/' + encodeURIComponent(flatId) + '/status',
{
credentials: 'same-origin',
method: 'POST',
headers: {
'Content-Type': 'application/json'
@ -52,7 +56,7 @@ export const updateFlatStatus = function (flatId, newStatus, callback) {
}
export const getTimeToPlaces = function (callback) {
fetch('/api/v1/time_to/places')
fetch('/api/v1/time_to/places', { credentials: 'same-origin' })
.then(function (response) {
return response.json()
}).then(function (json) {

View File

@ -37,7 +37,7 @@ export default {
maxZoom: 17
},
tiles: {
url: 'http://{s}.tile.osm.org/{z}/{x}/{y}.png',
url: 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
attribution: '&copy; <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
},
icons: {

View File

@ -76,9 +76,9 @@
</template>
<script>
import "font-awesome-webpack"
import 'font-awesome-webpack'
import { capitalize } from "../tools"
import { capitalize } from '../tools'
export default {
data () {
@ -94,7 +94,7 @@ export default {
sortedFlats () {
return this.flats.sort(
(flat1, flat2) => {
if (this.sortOrder === "up") {
if (this.sortOrder === 'up') {
return flat1[this.sortBy] > flat2[this.sortBy]
} else {
return flat1[this.sortBy] < flat2[this.sortBy]
@ -110,13 +110,13 @@ export default {
},
updateSortBy (field) {
if (this.sortBy === field) {
if (this.sortOrder === "up") {
this.sortOrder = "down"
if (this.sortOrder === 'up') {
this.sortOrder = 'down'
} else {
this.sortOrder = "up"
this.sortOrder = 'up'
}
} else {
this.sortBy = field;
this.sortBy = field
}
},
capitalize: capitalize

View File

@ -9,8 +9,8 @@ export default {
'External_link': 'External link',
'Follow': 'Follow',
'Close': 'Close',
"sortUp": 'Sort in ascending order',
"sortDown": 'Sort in descending order'
'sortUp': 'Sort in ascending order',
'sortDown': 'Sort in descending order'
},
home: {
'new_available_flats': 'New available flats'

View File

@ -9,7 +9,7 @@ export default {
const postalCodeBuckets = {}
state.flats.forEach(flat => {
if (filter && filter(flat)) {
if (filter && filter(flat)) { // TODO
const postalCode = flat.flatisfy_postal_code.postal_code
if (!postalCodeBuckets[postalCode]) {
postalCodeBuckets[postalCode] = {

View File

@ -159,7 +159,7 @@
</template>
<script>
import "font-awesome-webpack"
import 'font-awesome-webpack'
import FlatsMap from '../components/flatsmap.vue'
import Slider from '../components/slider.vue'