Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Develop to master #1

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .example.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
NUXT_ENV_API_VAR=local

NUXT_ENV_ENCRYPT_MODE=no

NUXT_ENV_PORT_DEV=3000
NUXT_ENV_PORT_PREPROD=8000
NUXT_ENV_PORT_PROD=3000

NUXT_ENV_API_DEV=http://localhost:4000/api
NUXT_ENV_API_PREPROD=https://solidata-preprod-api.co-demos.com/api
NUXT_ENV_API_PROD=https://solidata-api.co-demos.com/api
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ npm-debug.log
# Nuxt generate
dist

# env files
.env

.DS_Store
node_modules/
Expand Down
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v13.12.0
1 change: 1 addition & 0 deletions components/Footer/Footer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,7 @@ export default {
doc_id: this.$store.state.auth.user_id,
form: [{
'field_to_update': 'profile.agreement',
'doc_type': 'usr',
'field_value': true
}]
}
Expand Down
24 changes: 17 additions & 7 deletions components/Forms/login.vue
Original file line number Diff line number Diff line change
Expand Up @@ -228,22 +228,32 @@ export default {
// - - - - - - - - - - - - - //

// use saltToken as public_key for RSA encryption
const rsaEncrypt = this.$store.state.RSA_ENCRYPT
const antispamMode = this.$store.state.ANTISPAM_MODE
var saltToken = this.$store.state.auth.salt_token

// var TEST_PLUGIN = this.$EncryptionRSA( this.password, saltToken )
// console.log("> > > TEST_PLUGIN : ", TEST_PLUGIN ) ;

var encryptedPwd = this.$EncryptionRSA(this.password, saltToken)
var encryptedPwd = this.$EncryptionRSA(this.password, saltToken, rsaEncrypt)
console.log('encryptedPwd : ', encryptedPwd)

var encryptedEmail = this.$EncryptionRSA(this.email_bis, saltToken)
var encryptedEmail = this.$EncryptionRSA(this.email_bis, saltToken, rsaEncrypt)
console.log('encryptedEmail : ', encryptedEmail)

let pseudoForm = {
// email : this.email,
email_encrypt: encryptedEmail.hashed,
// pwd : this.password,
pwd_encrypt: encryptedPwd.hashed
let pseudoForm = {}

if (rsaEncrypt) {
pseudoForm.email_encrypt = encryptedEmail.hashed
pseudoForm.pwd_encrypt = encryptedPwd.hashed
} else {
pseudoForm.email = encryptedEmail.hashed
pseudoForm.pwd = encryptedPwd.hashed
}

// TO FINISH
if (antispamMode) {
console.log('submitLogin / antispamMode :', antispamMode)
}

// dispatch action from store/auth
Expand Down
17 changes: 11 additions & 6 deletions components/Forms/register.vue
Original file line number Diff line number Diff line change
Expand Up @@ -202,20 +202,25 @@ export default {
computed: {
pseudoForm () {
if (process.client === true) {
const rsaEncrypt = this.$store.state.RSA_ENCRYPT
const saltToken = this.$store.state.auth.salt_token
var encryptedPwd = this.password !== '' ? this.$EncryptionRSA(this.password, saltToken) : ''
var encryptedEmail = this.email_bis !== '' ? this.$EncryptionRSA(this.email_bis, saltToken) : ''
var encryptedPwd = this.password !== '' ? this.$EncryptionRSA(this.password, saltToken, rsaEncrypt) : ''
var encryptedEmail = this.email_bis !== '' ? this.$EncryptionRSA(this.email_bis, saltToken, rsaEncrypt) : ''

let pseudoForm = {
// email : this.email,
email_encrypt: encryptedEmail.hashed,
pwd_encrypt: encryptedPwd.hashed,
name: this.name,
surname: this.surname,
// pwd : this.password,
lang: this.$store.state.locale,
agreement: this.agreement
}
if (rsaEncrypt) {
pseudoForm.email_encrypt = encryptedEmail.hashed
pseudoForm.pwd_encrypt = encryptedPwd.hashed
} else {
pseudoForm.email = encryptedEmail.hashed
pseudoForm.pwd = encryptedPwd.hashed
}

return pseudoForm
}
}
Expand Down
52 changes: 47 additions & 5 deletions components/UI/itemToolbar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -193,12 +193,16 @@
<!-- EXPORT BTN -->
<v-list-tile
v-if="is_export"
disabled
@click="downloadDataset()"
>
<!-- disabled -->
<v-list-tile-title
class="pa-0 ma-0"
>
<v-icon
small
left
class="pr-1 mb-1"
color=""
>
{{ $store.state.mainIcons.export.icon }}
Expand Down Expand Up @@ -584,7 +588,7 @@ export default {
return (this.isPreview) ? 'white' : 'primary'
},
docAPIurl () {
return this.$store.state.APIURL + "/" + this.coll + "/documentation"
return this.$store.state.APIURL + '/' + this.coll + '/documentation'
}
},

Expand Down Expand Up @@ -635,6 +639,44 @@ export default {
return canUpdateField
},

downloadDataset () {
this.$store.state.LOG && this.$store.state.LOG && console.log('itemToolbar - downloadDataset ...')

this.loading = true
// this.is_loading = true

let exportInput = {
coll: this.coll,
doc_id: this.itemId
}
this.$store.dispatch('downloadDataset', exportInput)

.then(response => {
this.$store.state.LOG && console.log('itemToolbar - downloadDataset / response: ', response)
this.$store.state.LOG && console.log('itemToolbar - downloadDataset / response.data: ', response.data)

this.loading = false

let fileName = this.coll + '_' + this.itemTitle + '.csv'

let blob = new Blob([response], {type: 'text/csv'})
const link = document.createElement('a')
link.href = window.URL.createObjectURL(blob)
link.setAttribute('download', fileName) // or any other extension
document.body.appendChild(link)
link.click()
})

.catch(error => {
this.$store.state.LOG && console.log('itemToolbar - downloadDataset / error... : ', error)
this.loading = false
this.is_loading = false
if (error.response && error.response.data) {
this.alert = {type: 'error', message: error.response.data.msg || error.reponse.status}
}
})
},

reloadData () {
this.$store.state.LOG && this.$store.state.LOG && console.log('itemToolbar - reloadData ...')
const reloadSpecs = this.$store.state[this.coll].reload_data
Expand Down Expand Up @@ -669,7 +711,7 @@ export default {
this.$store.state.LOG && console.log('\n itemToolbar - deleItem ... ')

this.loading = true
this.is_loading = true
// this.is_loading = true

var callInput = {
coll: this.coll,
Expand All @@ -682,7 +724,7 @@ export default {
this.$store.state.LOG && console.log('itemToolbar - deleItem / response: ', response)

this.loading = false
this.is_loading = false
// this.is_loading = false
this.alert = {type: 'success', message: response.msg}

return this.$router.push(`/${this.coll}`)
Expand All @@ -692,7 +734,7 @@ export default {
this.$store.state.LOG && console.log('itemToolbar - deleItem / error... : ', error)

this.loading = false
this.is_loading = false
// this.is_loading = false

if (error.response && error.response.data) {
this.alert = {type: 'error', message: error.response.data.msg || error.reponse.status}
Expand Down
13 changes: 4 additions & 9 deletions middleware/checkTokens.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,6 @@ export default function ({ req, store, app, redirect }) {
} catch (error) {
console.log('- - - ... fucking error in parsing cookie with process.server == true : \n', error)
}
// try {
// langCookie = parsed.lang;
// console.log("- - - checkTokens / langCookie :", langCookie) ;
// store.commit('SET_LANG', langCookie, { root: true }) ;
// }
// catch(error) {
// console.log("- - - ... fucking error in parsing cookie with process.server == true : \n", error)
// }
}
}

Expand Down Expand Up @@ -125,9 +117,12 @@ export default function ({ req, store, app, redirect }) {
// if ( accessToken == null || store.state.auth.isAnonymous ) {
if (accessToken == null) {
// if neither tokens in cookie nor store consider user as anonymous and get anonymous access_token
let promisesList = []
console.log('- - - checkTokens / no access_token detected')
const accessAnonymous = store.dispatch('auth/loginAnonymous')
return Promise.all([ accessAnonymous ])
promisesList.push(accessAnonymous)
// return Promise.all([ accessAnonymous ])
return Promise.all(promisesList)
} else {
// 2b // If the user an access_token and a test them
console.log('- - - checkTokens / access_token and refresh_token detected')
Expand Down
42 changes: 33 additions & 9 deletions nuxt.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,27 @@
import pkg from './package'
import { noConflict } from 'q'

require('dotenv').config()

console.log('\n>>> nuxt.config.js / process.env.NUXT_ENV_API_VAR : ', process.env.NUXT_ENV_API_VAR)
console.log('\n>>> nuxt.config.js / process.env.NUXT_ENV_RSA_ENCRYPT : ', process.env.NUXT_ENV_RSA_ENCRYPT)
console.log('\n>>> nuxt.config.js / process.env.NUXT_ENV_ANONYMOUS_MODE : ', process.env.NUXT_ENV_ANONYMOUS_MODE)
console.log('\n>>> nuxt.config.js / process.env.NUXT_ENV_ANTISPAM_MODE : ', process.env.NUXT_ENV_ANTISPAM_MODE)

const trueStrings = ['yes', 'Yes', 'YES', 'y', 'Y', 'true', 'True', 'TRUE', 't', 'T']
// const falseStrings = ['no', 'No', 'NO', 'n', 'N', 'false', 'False', 'FALSE', 'f', 'F']

const chooseBooleanMode = (ARG) => {
if (trueStrings.includes(ARG)) {
return true
} else {
return false
}
}
const chooseAPIbaseUrl = (ENVPROD) => {
const NUXT_ENV_API_DEV = 'http://localhost:4000/api'
const NUXT_ENV_API_PREPROD = 'https://solidata-preprod-api.co-demos.com/api'
const NUXT_ENV_API_PROD = 'https://solidata-api.co-demos.com/api'
const NUXT_ENV_API_DEV = process.env.NUXT_ENV_API_DEV || 'http://localhost:4000/api'
const NUXT_ENV_API_PREPROD = process.env.NUXT_ENV_API_PREPROD || 'https://solidata-preprod-api.co-demos.com/api'
const NUXT_ENV_API_PROD = process.env.NUXT_ENV_API_PROD || 'https://solidata-api.co-demos.com/api'
if (ENVPROD === 'local') {
return NUXT_ENV_API_DEV
} else if (ENVPROD === 'preprod') {
Expand All @@ -11,9 +31,9 @@ const chooseAPIbaseUrl = (ENVPROD) => {
}
}
const choosePort = (ENVPROD) => {
const NUXT_ENV_PORT_DEV = 3000
const NUXT_ENV_PORT_PREPROD = 8000
const NUXT_ENV_PORT_PROD = 3000
const NUXT_ENV_PORT_DEV = parseInt(process.env.NUXT_ENV_PORT_DEV) || 3000
const NUXT_ENV_PORT_PREPROD = parseInt(process.env.NUXT_ENV_PORT_PREPROD) || 8000
const NUXT_ENV_PORT_PROD = parseInt(process.env.NUXT_ENV_PORT_PROD) || 3000
if (ENVPROD === 'local') {
return NUXT_ENV_PORT_DEV
} else if (ENVPROD === 'preprod') {
Expand All @@ -25,11 +45,15 @@ const choosePort = (ENVPROD) => {
const logAllowed = ['preprod', 'local']
const configApp = {
API_URL: chooseAPIbaseUrl(process.env.NUXT_ENV_API_VAR),
ANO_MODE: chooseBooleanMode(process.env.NUXT_ENV_ANONYMOUS_MODE || 'yes'),
ANTISPAM_MODE: chooseBooleanMode(process.env.NUXT_ENV_ANTISPAM_MODE || 'no'),
RSA_ENCRYPT: chooseBooleanMode(process.env.NUXT_ENV_RSA_ENCRYPT || 'no'),
port: choosePort(process.env.NUXT_ENV_API_VAR),
mode: process.env.NUXT_ENV_API_VAR
}
console.log('process.env :', process.env)
console.log('configApp :', configApp)
console.log('\nprocess.env :', process.env)
console.log('\nconfigApp :', configApp)

module.exports = {

mode: 'universal',
Expand Down Expand Up @@ -65,7 +89,7 @@ module.exports = {
DEBUG: process.env.NODE_ENV === 'development',
MODE_APP: configApp.mode,
LOG: logAllowed.includes(configApp.mode),
CONFIG_APP: configApp,
CONFIG_APP: configApp
},

router: {
Expand Down
5 changes: 5 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 12 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@
"author": "JPy <[email protected]>",
"private": true,
"scripts": {
"dev": "NUXT_ENV_API_VAR=local nuxt",
"dev_preprod": "NUXT_ENV_API_VAR=preprod nuxt",
"build_dev": "NUXT_ENV_API_VAR=local nuxt build",
"start_dev": "NUXT_ENV_API_VAR=local nuxt start",
"generate_dev": " NUXT_ENV_API_VAR=local nuxt generate",
"build_preprod": " NUXT_ENV_API_VAR=preprod nuxt build",
"start_preprod": " NUXT_ENV_API_VAR=preprod nuxt start",
"generate_preprod": " NUXT_ENV_API_VAR=preprod nuxt generate",
"build": " NUXT_ENV_API_VAR=prod nuxt build",
"start": " NUXT_ENV_API_VAR=prod nuxt start",
"generate": " NUXT_ENV_API_VAR=prod nuxt generate"
"dev": "nuxt",
"dev_preprod": "nuxt",
"build_dev": "nuxt build",
"start_dev": "nuxt start",
"generate_dev": "nuxt generate",
"build_preprod": "nuxt build",
"start_preprod": "nuxt start",
"generate_preprod": "nuxt generate",
"build": "nuxt build",
"start": "nuxt start",
"generate": "nuxt generate"
},
"dependencies": {
"@fortawesome/fontawesome-svg-core": "^1.2.2",
Expand All @@ -31,6 +31,7 @@
"cookie": "^0.3.1",
"cookieparser": "^0.1.0",
"crypto-js": "^3.1.9-1",
"dotenv": "^8.0.0",
"epic-spinners": "^1.0.3",
"i": "^0.3.6",
"js-cookie": "^2.2.0",
Expand Down
29 changes: 15 additions & 14 deletions plugins/encrypt.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,28 @@ import JSEncrypt from 'jsencrypt'

console.log('> > > plugins/encrypt... ')

Vue.prototype.$EncryptionRSA = (stringToEncrypt, publicKey) => {
Vue.prototype.$EncryptionRSA = (stringToEncrypt, publicKey, rsaEncrypt = true) => {
// cf : https://github.com/travist/jsencrypt

// console.log('> > > plugin EncryptionRSA / stringToEncrypt : ', stringToEncrypt)
console.log('> > > plugin EncryptionRSA / stringToEncrypt : ', stringToEncrypt)
// console.log('> > > plugin EncryptionRSA / publicKey : ', publicKey)

// NODE-RSA TEST
// const key = new NodeRSA(pem_public_key);
// // string to bytes
// var buffer = new Buffer(stringToEncrypt, "utf8")
// var encrypted = key.encrypt(buffer, "hex")
console.log('> > > plugin EncryptionRSA / process.env : ', process.env)
console.log('> > > plugin EncryptionRSA / rsaEncrypt : ', rsaEncrypt)

// JSENCRYPT
// Encrypt with the public key...
var encrypt = new JSEncrypt()
// console.log('> > > plugin EncryptString / encrypt : ', encrypt)
encrypt.setPublicKey(publicKey)
var encrypted = encrypt.encrypt(stringToEncrypt)
let encrypted

// console.log('> > > plugin EncryptString / encrypted : ', encrypted)
if (rsaEncrypt) {
// JSENCRYPT - Encrypt with the public key...
var encrypt = new JSEncrypt()
// console.log('> > > plugin EncryptString / encrypt : ', encrypt)
encrypt.setPublicKey(publicKey)
encrypted = encrypt.encrypt(stringToEncrypt)
} else {
encrypted = stringToEncrypt
}

// console.log('> > > plugin EncryptString / encrypted : ', encrypted)
return {
salt: publicKey,
hashed: encrypted
Expand Down
Loading