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

View File

@ -37,7 +37,7 @@ export default {
maxZoom: 17 maxZoom: 17
}, },
tiles: { 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' attribution: '&copy; <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
}, },
icons: { icons: {

View File

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

View File

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

View File

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

View File

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