Skip to content

Commit

Permalink
fix: add check integrity to geo data
Browse files Browse the repository at this point in the history
  • Loading branch information
raulghm committed May 29, 2019
1 parent ad5e0fb commit 239b33c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
16 changes: 16 additions & 0 deletions src/helpers/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/**
* Check json integrity
* @param {object} json
*/
const isJSON = json => {
try {
if (json && typeof json === 'object' && json !== null) {
return true
}
} catch (err) {}
return false
}

export default {
isJSON
}
5 changes: 4 additions & 1 deletion src/user.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import helpers from '@/helpers'

/**
* Get user geo from device
* @return {Promise<Object>}
Expand Down Expand Up @@ -53,7 +55,8 @@ const getUserGeoDataFromStorage = () => {
* Check if user has geo data
*/
const checkUserGeoData = () => {
return !!localStorage.getItem('userGeoData')
const data = getUserGeoDataFromStorage()
return helpers.isJSON(data) && data.lat && data.long
}

/**
Expand Down

0 comments on commit 239b33c

Please sign in to comment.