Altra conversione in Typescript , partendo da un progetto di esempio funzionante...
This commit is contained in:
15
.babelrc
15
.babelrc
@@ -1,4 +1,17 @@
|
|||||||
{
|
{
|
||||||
|
"env": {
|
||||||
|
"test": {
|
||||||
|
"presets": [ [
|
||||||
|
"@babel/preset-env", {
|
||||||
|
"modules": "commonjs",
|
||||||
|
"targets": {
|
||||||
|
"node": "current"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
"presets": [
|
"presets": [
|
||||||
[
|
[
|
||||||
"@babel/preset-env", {
|
"@babel/preset-env", {
|
||||||
@@ -18,7 +31,7 @@
|
|||||||
],
|
],
|
||||||
"plugins": [
|
"plugins": [
|
||||||
[
|
[
|
||||||
"@babel/transform-runtime", {
|
"@babel/plugin-transform-runtime", {
|
||||||
"polyfill": false,
|
"polyfill": false,
|
||||||
"regenerator": false
|
"regenerator": false
|
||||||
}
|
}
|
||||||
|
|||||||
5
.gitignore
vendored
5
.gitignore
vendored
@@ -7,6 +7,8 @@ node_modules
|
|||||||
/src-cordova/platforms
|
/src-cordova/platforms
|
||||||
/src-cordova/plugins
|
/src-cordova/plugins
|
||||||
/src-cordova/www
|
/src-cordova/www
|
||||||
|
/src-pwa
|
||||||
|
/src-ssr
|
||||||
npm-debug.log*
|
npm-debug.log*
|
||||||
yarn-debug.log*
|
yarn-debug.log*
|
||||||
yarn-error.log*
|
yarn-error.log*
|
||||||
@@ -18,3 +20,6 @@ yarn-error.log*
|
|||||||
*.ntvs*
|
*.ntvs*
|
||||||
*.njsproj
|
*.njsproj
|
||||||
*.sln
|
*.sln
|
||||||
|
|
||||||
|
# Coverage
|
||||||
|
coverage
|
||||||
35
.stylintrc
Normal file
35
.stylintrc
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
{
|
||||||
|
"blocks": "never",
|
||||||
|
"brackets": "never",
|
||||||
|
"colons": "never",
|
||||||
|
"colors": "always",
|
||||||
|
"commaSpace": "always",
|
||||||
|
"commentSpace": "always",
|
||||||
|
"cssLiteral": "never",
|
||||||
|
"depthLimit": false,
|
||||||
|
"duplicates": true,
|
||||||
|
"efficient": "always",
|
||||||
|
"extendPref": false,
|
||||||
|
"globalDupe": true,
|
||||||
|
"indentPref": 2,
|
||||||
|
"leadingZero": "never",
|
||||||
|
"maxErrors": false,
|
||||||
|
"maxWarnings": false,
|
||||||
|
"mixed": false,
|
||||||
|
"namingConvention": false,
|
||||||
|
"namingConventionStrict": false,
|
||||||
|
"none": "never",
|
||||||
|
"noImportant": false,
|
||||||
|
"parenSpace": "never",
|
||||||
|
"placeholder": false,
|
||||||
|
"prefixVarsWithDollar": "always",
|
||||||
|
"quotePref": "single",
|
||||||
|
"semicolons": "never",
|
||||||
|
"sortOrder": false,
|
||||||
|
"stackedProperties": "never",
|
||||||
|
"trailingWhitespace": "never",
|
||||||
|
"universal": "never",
|
||||||
|
"valid": true,
|
||||||
|
"zeroUnits": "never",
|
||||||
|
"zIndexNormalize": false
|
||||||
|
}
|
||||||
119
README.md
119
README.md
@@ -1,3 +1,118 @@
|
|||||||
# Quasar App
|
<div align="center">
|
||||||
|
|
||||||
> WIP
|
# Quasar TypeScript
|
||||||
|
|
||||||
|
A starter kit to build powerful and amazing native-looking apps, thanks to the Quasar Framework and TypeScript
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div align="center">
|
||||||
|
|
||||||
|
[](https://github.com/quasarframework/quasar)
|
||||||
|
[](https://github.com/Microsoft/TypeScript)
|
||||||
|
|
||||||
|
[](https://opensource.org/licenses/MIT)
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div align="center">
|
||||||
|
|
||||||
|
[](https://github.com/standard/standard)
|
||||||
|
|
||||||
|
[](https://circleci.com/gh/kevinmarrec/quasar-typescript/tree/master)
|
||||||
|
[](https://codecov.io/gh/kevinmarrec/quasar-typescript/branch/master)
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
## Features ⚡️(WIP)
|
||||||
|
|
||||||
|
- [TypeScript](https://github.com/Microsoft/TypeScript) ✔
|
||||||
|
- [Pug](https://github.com/pugjs/pug) Template Engine ✔
|
||||||
|
- Internationalization (I18n) ✔
|
||||||
|
- SSR compliant using Quasar SSR ✔
|
||||||
|
- ...
|
||||||
|
|
||||||
|
## Built-in Tools 🔨
|
||||||
|
|
||||||
|
- [TSlint](https://github.com/palantir/tslint) TypeScript Linter configured with the [Standard](https://github.com/standard/standard) JavaScript Code Style
|
||||||
|
- Testing Suite using [Jest](https://github.com/facebook/jest) (See `Testing` section)
|
||||||
|
- Configurable CI Pipeline using [CircleCI](https://circleci.com/) & [Codecov](https://codecov.io) (See `CI Pipeline` section)
|
||||||
|
|
||||||
|
## Installation 🔧
|
||||||
|
|
||||||
|
**System prerequisites :**
|
||||||
|
- Pretested on Windows, Mac & Linux
|
||||||
|
- Node.js 8 LTS or 10 latest
|
||||||
|
- yarn > 1.9 (no guarantees if you prefer to use npm)
|
||||||
|
|
||||||
|
Clone this repository :
|
||||||
|
```bash
|
||||||
|
$ git clone git@github.com:kevinmarrec/quasar-typescript example
|
||||||
|
$ cd example
|
||||||
|
$ yarn
|
||||||
|
```
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ yarn dev # Start a SPA server
|
||||||
|
$ yarn dev:ssr # Start a SSR + PWA server
|
||||||
|
```
|
||||||
|
|
||||||
|
## Testing (WIP)
|
||||||
|
|
||||||
|
## CI Pipeline (WIP)
|
||||||
|
|
||||||
|
## Building
|
||||||
|
|
||||||
|
You can build your application for production using :
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ yarn build # Build your SPA (it places the artifacts at /dist/spa-mat)
|
||||||
|
$ yarn build:ssr # Build your SSR + PWA (it places the artifacts at /dist/ssr-mat)
|
||||||
|
```
|
||||||
|
|
||||||
|
If you want then to clean build artifacts, just do :
|
||||||
|
```bash
|
||||||
|
$ yarn build:clean
|
||||||
|
```
|
||||||
|
|
||||||
|
## Serving
|
||||||
|
|
||||||
|
You can serve your production ready application locally using :
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ yarn serve # Serve your SPA
|
||||||
|
$ yarn serve:ssr # Serve your SSR + PWA
|
||||||
|
```
|
||||||
|
|
||||||
|
By default, SPA and SSR apps are respectively served on ports `4000` and `3000`
|
||||||
|
|
||||||
|
You can override the port using an environment variable :
|
||||||
|
```bash
|
||||||
|
$ PORT=3210 yarn serve # Serve your SPA on port 3210
|
||||||
|
$ PORT=3210 yarn serve:ssr # Serve your SSR + PWA on port 3210
|
||||||
|
```
|
||||||
|
|
||||||
|
## Deploy with Now.sh
|
||||||
|
|
||||||
|
Deploying with [Now](https://zeit.co/now) is a breeze. The Now CLI is already shipped in the starter kit development dependencies so all you need to do is :
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ yarn deploy # Deploy your SPA on Now.sh
|
||||||
|
$ yarn deploy:ssr # Deploy your SSR + PWA on Now.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
> You might want to use a "now alias" or connect your domain to Now - or even look into automatic deployment with [their Github integration](https://zeit.co/blog/now-for-github).
|
||||||
|
|
||||||
|
`Now.sh` will install the dependencies automatically then run `$ yarn start`. Your website will be up and running on an HTTPS connection in a matter of seconds !
|
||||||
|
|
||||||
|
## References
|
||||||
|
* **Quasar 0.17.15** : [Website](https://quasar-framework.org) | [Documentation](https://quasar-framework.org/guide) | [Github](https://github.com/quasarframework/quasar)
|
||||||
|
* **Vue I18n 8.1.0** : [Website](https://kazupon.github.io/vue-i18n) | [Documentation](https://kazupon.github.io/vue-i18n/guide/started.html) | [Github](https://github.com/kazupon/vue-i18n)
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
[MIT](https://opensource.org/licenses/MIT)
|
||||||
|
|
||||||
|
Copyright (c) 2018-present, Kevin Marrec
|
||||||
|
|||||||
@@ -1,12 +0,0 @@
|
|||||||
const DotEnv = require('dotenv')
|
|
||||||
const parsedEnv = DotEnv.config().parsed
|
|
||||||
|
|
||||||
module.exports = function () {
|
|
||||||
// Let's stringify our variables
|
|
||||||
for (key in parsedEnv) {
|
|
||||||
if (typeof parsedEnv[key] === 'string') {
|
|
||||||
parsedEnv[key] = JSON.stringify(parsedEnv[key])
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return parsedEnv
|
|
||||||
}
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
module.exports = function (key, fallback) {
|
|
||||||
return process.env[key] || fallback
|
|
||||||
}
|
|
||||||
47
jest.config.js
Normal file
47
jest.config.js
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
module.exports = {
|
||||||
|
globals: {
|
||||||
|
__DEV__: true
|
||||||
|
},
|
||||||
|
verbose: true,
|
||||||
|
testURL: 'http://localhost/',
|
||||||
|
collectCoverage: false,
|
||||||
|
coverageDirectory: '<rootDir>/test/coverage',
|
||||||
|
collectCoverageFrom: [
|
||||||
|
'<rootDir>/src/components/**/*.vue',
|
||||||
|
'<rootDir>/src/layouts/**/*.vue',
|
||||||
|
'<rootDir>/src/pages/**/*.vue',
|
||||||
|
'<rootDir>/src/plugins/**/*.ts',
|
||||||
|
'<rootDir>/src/mixins/**/*.ts',
|
||||||
|
'<rootDir>/src/directives/**/*.ts'
|
||||||
|
],
|
||||||
|
coverageThreshold: {
|
||||||
|
global: {
|
||||||
|
branches: 50,
|
||||||
|
functions: 50,
|
||||||
|
lines: 50,
|
||||||
|
statements: 50
|
||||||
|
}
|
||||||
|
},
|
||||||
|
testMatch: [
|
||||||
|
'<rootDir>/**/__tests__/**/*.spec.ts'
|
||||||
|
],
|
||||||
|
moduleFileExtensions: [
|
||||||
|
'ts',
|
||||||
|
'js',
|
||||||
|
'json',
|
||||||
|
'vue'
|
||||||
|
],
|
||||||
|
moduleNameMapper: {
|
||||||
|
'^vue$': '<rootDir>/node_modules/vue/dist/vue.common.js',
|
||||||
|
'^quasar$': '<rootDir>/tmp/quasar.common.js',
|
||||||
|
'^~/(.*)$': '<rootDir>/$1',
|
||||||
|
'^@/(.*)$': '<rootDir>/src/$1'
|
||||||
|
},
|
||||||
|
transform: {
|
||||||
|
'.*\\.vue$': '<rootDir>/node_modules/vue-jest',
|
||||||
|
'.*\\.ts$': '<rootDir>/node_modules/ts-jest'
|
||||||
|
},
|
||||||
|
snapshotSerializers: [
|
||||||
|
'<rootDir>/node_modules/jest-serializer-vue'
|
||||||
|
]
|
||||||
|
}
|
||||||
11128
package-lock.json
generated
11128
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
83
package.json
83
package.json
@@ -1,55 +1,56 @@
|
|||||||
{
|
{
|
||||||
"name": "myapp",
|
"name": "quasar-typescript",
|
||||||
"version": "1.0.0",
|
"version": "0.1.0",
|
||||||
"description": "MyApp Pao descrizione",
|
"description": "",
|
||||||
"productName": "MyApp Pao",
|
"productName": "Quasar TypeScript",
|
||||||
"cordovaId": "",
|
"cordovaId": "org.cordova.quasar.app",
|
||||||
"author": "paolo <paolo.arena77@gmail.com>",
|
"author": "Kevin Marrec",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "quasar dev -m pwa",
|
"lint": "tslint --project tsconfig.json",
|
||||||
"build": "quasar build -m pwa",
|
"lint:fix": "tslint --project tsconfig.json --fix",
|
||||||
"test": "quasar dev"
|
"dev": "NODE_OPTIONS=--max_old_space_size=4096 DEBUG=v8:* quasar dev",
|
||||||
|
"dev:ssr": "NODE_OPTIONS=--max_old_space_size=4096 DEBUG=v8:* quasar dev -m ssr",
|
||||||
|
"dev:pwa": "NODE_OPTIONS=--max_old_space_size=4096 DEBUG=v8:* quasar dev -m pwa",
|
||||||
|
"test:unit": "jest",
|
||||||
|
"test:cover": "jest --coverage",
|
||||||
|
"build": "quasar build",
|
||||||
|
"build:ssr": "quasar build -m ssr",
|
||||||
|
"build:clean": "quasar clean",
|
||||||
|
"serve": "quasar serve ./dist/spa-mat",
|
||||||
|
"serve:ssr": "quasar serve ./dist/ssr-mat",
|
||||||
|
"serve:coverage": "quasar serve test/coverage/lcov-report/ --cache 0 --port 8788",
|
||||||
|
"deploy": "now dist/spa-mat",
|
||||||
|
"deploy:ssr": "now dist/ssr-mat"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@types/bcrypt": "^3.0.0",
|
|
||||||
"axios": "^0.18.0",
|
"axios": "^0.18.0",
|
||||||
"bcryptjs": "^2.4.3",
|
"bcryptjs": "^2.4.3",
|
||||||
"chart": "^0.1.2",
|
"vue-i18n": "^8.1.0",
|
||||||
"chart.js": "^2.7.3",
|
|
||||||
"countup.js": "^1.9.3",
|
|
||||||
"js-cookie": "^2.2.0",
|
|
||||||
"js-md5": "^0.7.3",
|
|
||||||
"lodash": "^4.17.11",
|
|
||||||
"quasar-extras": "^2.0.8",
|
|
||||||
"roboto-font": "^0.1.0",
|
|
||||||
"tslib": "^1.9.3",
|
|
||||||
"vivus": "^0.4.4",
|
|
||||||
"vue-i18n": "^8.2.1",
|
|
||||||
"vue-i18n-loader": "^1.0.0",
|
|
||||||
"vue-property-decorator": "^7.2.0",
|
"vue-property-decorator": "^7.2.0",
|
||||||
"vue-template-loader": "^1.0.0",
|
|
||||||
"vuelidate": "^0.7.4",
|
"vuelidate": "^0.7.4",
|
||||||
"webpack-stream": "^5.1.1"
|
"vuex-class": "^0.3.1",
|
||||||
|
"vuex-module-decorators": "^0.9.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/express": "^4.16.0",
|
"@types/jest": "^23.3.4",
|
||||||
"@types/extract-text-webpack-plugin": "^3.0.3",
|
"@types/node": "^10.11.5",
|
||||||
"@types/html-webpack-plugin": "^3.2.0",
|
"@vue/test-utils": "^1.0.0-beta.25",
|
||||||
"@types/node": "^10.12.0",
|
"babel-core": "^7.0.0-bridge.0",
|
||||||
"@types/webpack": "^4.4.17",
|
"codecov": "^3.1.0",
|
||||||
"@types/webpack-merge": "^4.1.3",
|
"jest": "^23.6.0",
|
||||||
"dotenv": "^6.1.0",
|
"jest-serializer-vue": "^2.0.2",
|
||||||
"json-loader": "^0.5.7",
|
"now": "^11.4.6",
|
||||||
"karma-sourcemap-loader": "^0.3.7",
|
"pug": "^2.0.3",
|
||||||
"mocha-webpack": "^1.1.0",
|
"pug-plain-loader": "^1.0.0",
|
||||||
"quasar-cli": "^0.17.0",
|
"quasar-cli": "^0.17.20",
|
||||||
"strip-ansi": "^3.0.1",
|
"strip-ansi": "=3.0.1",
|
||||||
"ts-loader": "^5.2.2",
|
"ts-jest": "^23.10.4",
|
||||||
"typescript": "^3.1.3",
|
"ts-loader": "^5.2.1",
|
||||||
"vue-class-component": "^6.3.2",
|
"tslint": "^5.11.0",
|
||||||
"vue-cli-plugin-quasar": "^0.17.1",
|
"tslint-config-standard": "^8.0.1",
|
||||||
"vuex-module-decorators": "^0.9.0"
|
"typescript": "^3.1.1",
|
||||||
|
"vue-jest": "^2.6.0"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">= 8.9.0",
|
"node": ">= 8.9.0",
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
// Configuration for your app
|
// Configuration for your app
|
||||||
const path = require('path');
|
|
||||||
|
|
||||||
// Get our env variables
|
const path = require('path');
|
||||||
const envparser = require('./config/envparser');
|
|
||||||
|
|
||||||
const extendTypescriptToWebpack = (config) => {
|
const extendTypescriptToWebpack = (config) => {
|
||||||
config.resolve
|
config.resolve
|
||||||
@@ -25,6 +23,7 @@ module.exports = function (ctx) {
|
|||||||
router: 'src/router/index.ts',
|
router: 'src/router/index.ts',
|
||||||
store: 'src/store/index.ts'
|
store: 'src/store/index.ts'
|
||||||
},
|
},
|
||||||
|
// app plugins (/src/plugins)
|
||||||
plugins: ['i18n', 'axios', 'vuelidate'],
|
plugins: ['i18n', 'axios', 'vuelidate'],
|
||||||
css: [
|
css: [
|
||||||
'app.styl'
|
'app.styl'
|
||||||
@@ -59,11 +58,11 @@ module.exports = function (ctx) {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
devServer: {
|
devServer: {
|
||||||
// https: true,
|
https: false,
|
||||||
port: 8080,
|
port: 8080,
|
||||||
host: 'localhost',
|
open: true // opens browser window automatically
|
||||||
open: false // opens browser window automatically
|
|
||||||
},
|
},
|
||||||
|
// framework: 'all' --- includes everything; for dev only!
|
||||||
framework: {
|
framework: {
|
||||||
components: [
|
components: [
|
||||||
'QLayout',
|
'QLayout',
|
||||||
@@ -101,30 +100,31 @@ module.exports = function (ctx) {
|
|||||||
'QInnerLoading',
|
'QInnerLoading',
|
||||||
'QSpinnerGears',
|
'QSpinnerGears',
|
||||||
'QDatetime',
|
'QDatetime',
|
||||||
|
|
||||||
],
|
],
|
||||||
directives: [
|
directives: [
|
||||||
'Ripple'
|
'Ripple',
|
||||||
|
'CloseOverlay'
|
||||||
],
|
],
|
||||||
// Quasar plugins
|
// Quasar plugins
|
||||||
plugins: [
|
plugins: [
|
||||||
'Notify', 'ActionSheet', 'Loading'
|
'Notify',
|
||||||
|
'Meta',
|
||||||
|
'Cookies',
|
||||||
|
'ActionSheet', 'Loading'
|
||||||
],
|
],
|
||||||
config: {
|
|
||||||
// optional (v0.17+)
|
|
||||||
loading: {
|
|
||||||
// Loading defaults
|
|
||||||
}
|
|
||||||
},
|
|
||||||
//iconSet: ctx.theme.mat ? 'material-icons' : 'ionicons',
|
|
||||||
iconSet: 'fontawesome',
|
iconSet: 'fontawesome',
|
||||||
//iconSet: 'roboto-font',
|
i18n: 'it', // Quasar language
|
||||||
i18n: 'it' // Quasar language
|
|
||||||
},
|
},
|
||||||
// animations: 'all' --- includes all animations
|
|
||||||
animations: [],
|
animations: [],
|
||||||
ssr: {
|
ssr: {
|
||||||
pwa: false
|
pwa: {
|
||||||
|
runtimeCaching: [
|
||||||
|
{
|
||||||
|
urlPattern: '/statics',
|
||||||
|
handler: 'networkFirst'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
},
|
},
|
||||||
pwa: {
|
pwa: {
|
||||||
workboxPluginMode: 'InjectManifest',
|
workboxPluginMode: 'InjectManifest',
|
||||||
@@ -166,31 +166,5 @@ module.exports = function (ctx) {
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
cordova: {
|
|
||||||
// id: 'org.cordova.quasar.app'
|
|
||||||
},
|
|
||||||
electron: {
|
|
||||||
// bundler: 'builder', // or 'packager'
|
|
||||||
extendWebpack(cfg) {
|
|
||||||
// do something with Electron process Webpack cfg
|
|
||||||
},
|
|
||||||
packager: {
|
|
||||||
// https://github.com/electron-userland/electron-packager/blob/master/docs/api.md#options
|
|
||||||
|
|
||||||
// OS X / Mac App Store
|
|
||||||
// appBundleId: '',
|
|
||||||
// appCategoryType: '',
|
|
||||||
// osxSign: '',
|
|
||||||
// protocol: 'myapp://path',
|
|
||||||
|
|
||||||
// Window only
|
|
||||||
// win32metadata: { ... }
|
|
||||||
},
|
|
||||||
builder: {
|
|
||||||
// https://www.electron.build/configuration/configuration
|
|
||||||
|
|
||||||
// appId: 'quasar-app'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -54,8 +54,8 @@
|
|||||||
|
|
||||||
import {Quasar} from 'quasar';
|
import {Quasar} from 'quasar';
|
||||||
|
|
||||||
import drawer from '../components/layout/drawer/drawer.vue'
|
import drawer from '../layouts/drawer/drawer.vue'
|
||||||
import messagePopover from '../components/layout/toolbar/messagePopover.vue'
|
import messagePopover from '../layouts/toolbar/messagePopover.vue'
|
||||||
|
|
||||||
import user from '../store/modules/user';
|
import user from '../store/modules/user';
|
||||||
|
|
||||||
|
|||||||
@@ -1,13 +1,6 @@
|
|||||||
import { Component, Vue } from 'vue-property-decorator';
|
import { Component, Vue } from 'vue-property-decorator';
|
||||||
import WithRender from './hello-world.html';
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
@WithRender
|
|
||||||
@Component
|
@Component
|
||||||
export default class HelloWorld extends Vue {
|
export default class HelloWorld extends Vue {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|||||||
@@ -92,7 +92,10 @@
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script lang="ts">
|
||||||
|
import Vue from 'vue'
|
||||||
|
import { Component, Prop, Watch } from 'vue-property-decorator'
|
||||||
|
|
||||||
import {
|
import {
|
||||||
required,
|
required,
|
||||||
email,
|
email,
|
||||||
@@ -104,17 +107,20 @@
|
|||||||
requiredUnless
|
requiredUnless
|
||||||
} from 'vuelidate/lib/validators'
|
} from 'vuelidate/lib/validators'
|
||||||
|
|
||||||
import {mapGetters, mapActions} from 'vuex'
|
import { validationMixin } from 'vuelidate';
|
||||||
|
|
||||||
|
import { mapGetters, mapActions } from 'vuex'
|
||||||
import * as types from '../../../store/mutation-types'
|
import * as types from '../../../store/mutation-types'
|
||||||
|
|
||||||
import {Errori_MongoDb} from '../../../store/modules/user'
|
import { Errori_MongoDb } from '../../../store/modules/user'
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
|
|
||||||
import {Loading, QSpinnerFacebook, QSpinnerGears} from 'quasar'
|
import { Loading, QSpinnerFacebook, QSpinnerGears } from 'quasar'
|
||||||
|
|
||||||
|
|
||||||
export default {
|
@Component({
|
||||||
data() {
|
mixins: [validationMixin],
|
||||||
|
data () {
|
||||||
return {
|
return {
|
||||||
url: process.env.VUE_APP_URL,
|
url: process.env.VUE_APP_URL,
|
||||||
form: {
|
form: {
|
||||||
@@ -140,7 +146,7 @@
|
|||||||
'getUserServer',
|
'getUserServer',
|
||||||
'getServerCode',
|
'getServerCode',
|
||||||
]),
|
]),
|
||||||
env() {
|
env () {
|
||||||
return env
|
return env
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -159,7 +165,7 @@
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
password: {required, minLength: minLength(8), maxLength: maxLength(20)},
|
password: { required, minLength: minLength(8), maxLength: maxLength(20) },
|
||||||
username: {
|
username: {
|
||||||
required, minLength: minLength(6), maxLength: maxLength(20),
|
required, minLength: minLength(6), maxLength: maxLength(20),
|
||||||
isUnique: value => {
|
isUnique: value => {
|
||||||
@@ -175,7 +181,7 @@
|
|||||||
repeatPassword: {
|
repeatPassword: {
|
||||||
sameAsPassword: sameAs('password')
|
sameAsPassword: sameAs('password')
|
||||||
},
|
},
|
||||||
terms: {required},
|
terms: { required },
|
||||||
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -183,10 +189,10 @@
|
|||||||
...mapActions("user", {
|
...mapActions("user", {
|
||||||
signup: types.USER_SIGNUP,
|
signup: types.USER_SIGNUP,
|
||||||
}),
|
}),
|
||||||
showNotif(msg) {
|
showNotif (msg) {
|
||||||
this.$q.notify(msg)
|
this.$q.notify(msg)
|
||||||
},
|
},
|
||||||
errorMsg(cosa, item) {
|
errorMsg (cosa, item) {
|
||||||
try {
|
try {
|
||||||
if (!item.$error) return '';
|
if (!item.$error) return '';
|
||||||
if (item.$params.email && !item.email) return this.$t('reg.err.email');
|
if (item.$params.email && !item.email) return this.$t('reg.err.email');
|
||||||
@@ -214,7 +220,7 @@
|
|||||||
//console.log("ERR : " + error);
|
//console.log("ERR : " + error);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
checkErrors(riscode) {
|
checkErrors (riscode) {
|
||||||
//console.log("RIS = " + riscode);
|
//console.log("RIS = " + riscode);
|
||||||
if (riscode === Errori_MongoDb.DUPLICATE_EMAIL_ID) {
|
if (riscode === Errori_MongoDb.DUPLICATE_EMAIL_ID) {
|
||||||
this.showNotif(this.$t('reg.err.duplicate_email'));
|
this.showNotif(this.$t('reg.err.duplicate_email'));
|
||||||
@@ -227,7 +233,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
submit() {
|
submit () {
|
||||||
this.$v.form.$touch();
|
this.$v.form.$touch();
|
||||||
|
|
||||||
this.duplicate_email = false;
|
this.duplicate_email = false;
|
||||||
@@ -243,14 +249,14 @@
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
this.$q.loading.show({message: this.$t('reg.incorso')});
|
this.$q.loading.show({ message: this.$t('reg.incorso') });
|
||||||
|
|
||||||
console.log(this.form);
|
console.log(this.form);
|
||||||
this.signup(this.form)
|
this.signup(this.form)
|
||||||
.then((riscode) => {
|
.then((riscode) => {
|
||||||
this.checkErrors(riscode);
|
this.checkErrors(riscode);
|
||||||
this.$q.loading.hide();
|
this.$q.loading.hide();
|
||||||
}).catch(error => {
|
}).catch((error: string) => {
|
||||||
console.log("ERROR = " + error);
|
console.log("ERROR = " + error);
|
||||||
this.$q.loading.hide();
|
this.$q.loading.hide();
|
||||||
});
|
});
|
||||||
@@ -259,7 +265,11 @@
|
|||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
export default class Signup extends Vue {
|
||||||
}
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
@@ -269,3 +279,5 @@
|
|||||||
max-width: 450px;
|
max-width: 450px;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,46 +1 @@
|
|||||||
// This file is included in the build if src/main.js imports
|
// app global css
|
||||||
// either app.mat.styl or app.ios.styl.
|
|
||||||
// Check "DEFAULT / CUSTOM STYLE" in src/main.js
|
|
||||||
|
|
||||||
// App Shared Variables
|
|
||||||
// --------------------------------------------------
|
|
||||||
// To customize the look and feel of this app, you can override
|
|
||||||
// the Stylus variables found in Quasar's source Stylus files. Setting
|
|
||||||
// variables before Quasar's Stylus will use these variables rather than
|
|
||||||
// Quasar's default Stylus variable values. Stylus variables specific
|
|
||||||
// to the themes belong in either the app.ios.styl or app.mat.styl files.
|
|
||||||
|
|
||||||
|
|
||||||
// App Shared Color Variables
|
|
||||||
// --------------------------------------------------
|
|
||||||
// It's highly recommended to change the default colors
|
|
||||||
// to match your app's branding.
|
|
||||||
|
|
||||||
$primary = #027be3
|
|
||||||
$secondary = #26A69A
|
|
||||||
$tertiary = #555
|
|
||||||
|
|
||||||
$neutral = #E0E1E2
|
|
||||||
$positive = #21BA45
|
|
||||||
$negative = #DB2828
|
|
||||||
$info = #31CCEC
|
|
||||||
$warning = #F2C037
|
|
||||||
|
|
||||||
$light = #f4f4f4
|
|
||||||
$dark = #333
|
|
||||||
$faded = #777
|
|
||||||
|
|
||||||
$text-color = lighten(black, 17%)
|
|
||||||
$background-color = white
|
|
||||||
|
|
||||||
$link-color = lighten($primary, 25%)
|
|
||||||
$link-color-active = $primary
|
|
||||||
|
|
||||||
|
|
||||||
$typography-font-family ?= 'Roboto'
|
|
||||||
|
|
||||||
$toolbar-color ?= white
|
|
||||||
$toolbar-background ?= $primary
|
|
||||||
$toolbar-active-color ?= $primary
|
|
||||||
$toolbar-faded-color ?= composite-color($primary)
|
|
||||||
|
|
||||||
|
|||||||
@@ -28,7 +28,7 @@
|
|||||||
</template>
|
</template>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
import { mapActions, mapGetters } from 'vuex'
|
import { mapActions, mapGetters } from 'vuex'
|
||||||
import * as types from '../../store/mutation-types'
|
import * as types from '../store/mutation-types'
|
||||||
export default {
|
export default {
|
||||||
computed: {
|
computed: {
|
||||||
...mapGetters("glob", ['getLayoutNeeded', 'getIsLoginPage']),
|
...mapGetters("glob", ['getLayoutNeeded', 'getIsLoginPage']),
|
||||||
@@ -30,7 +30,7 @@
|
|||||||
import menuOne from './menuOne.vue'
|
import menuOne from './menuOne.vue'
|
||||||
import menuTwo from './menuTwo.vue'
|
import menuTwo from './menuTwo.vue'
|
||||||
|
|
||||||
import * as types from '../../../store/mutation-types'
|
import * as types from '../../store/mutation-types'
|
||||||
|
|
||||||
import {mapGetters, mapActions} from 'vuex'
|
import {mapGetters, mapActions} from 'vuex'
|
||||||
|
|
||||||
|
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 16 KiB |
|
Before Width: | Height: | Size: 62 KiB After Width: | Height: | Size: 62 KiB |
|
Before Width: | Height: | Size: 6.5 KiB After Width: | Height: | Size: 6.5 KiB |
@@ -23,7 +23,7 @@
|
|||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
import { mapGetters, mapActions } from 'vuex'
|
import { mapGetters, mapActions } from 'vuex'
|
||||||
import * as types from '../../../store/mutation-types'
|
import * as types from '../../store/mutation-types'
|
||||||
export default {
|
export default {
|
||||||
mounted () {
|
mounted () {
|
||||||
if (this.getPosts.length < 1) {
|
if (this.getPosts.length < 1) {
|
||||||
@@ -1,27 +1,18 @@
|
|||||||
<template>
|
<template lang="pug">
|
||||||
<q-page-container>
|
.fixed-center.text-center
|
||||||
<q-page class="flex flex-center">
|
img(src="~assets/sad.svg", style="width:30vw;max-width:150px;")
|
||||||
<div class="fixed-center text-center">
|
p.q-mt-sm.text-faded
|
||||||
<p>
|
| {{ $t('pages.errors.e404.message') }} #[strong (404)]
|
||||||
<img
|
q-btn(
|
||||||
src="~assets/sad.svg"
|
color="secondary"
|
||||||
style="width:30vw;max-width:150px;"
|
style="width:200px;"
|
||||||
>
|
@click="$router.push('/')"
|
||||||
</p>
|
) {{ $t('pages.errors.e404.back') }}
|
||||||
<p class="text-faded">Sorry, nothing here...<strong>(404)</strong></p>
|
|
||||||
<q-btn
|
|
||||||
color="secondary"
|
|
||||||
style="width:200px;"
|
|
||||||
@click="$router.push('/')"
|
|
||||||
>Go back
|
|
||||||
</q-btn>
|
|
||||||
</div>
|
|
||||||
</q-page>
|
|
||||||
</q-page-container>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script lang="ts">
|
||||||
export default {
|
import { Vue, Component } from 'vue-property-decorator'
|
||||||
name: 'Error404'
|
|
||||||
}
|
@Component
|
||||||
|
export default class Error404 extends Vue {}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
7
src/quasar.d.ts
vendored
7
src/quasar.d.ts
vendored
@@ -1,7 +0,0 @@
|
|||||||
declare module "*.vue" {
|
|
||||||
import * as Vue from 'vue';
|
|
||||||
export default typeof Vue
|
|
||||||
}
|
|
||||||
|
|
||||||
declare module "quasar"
|
|
||||||
declare const __THEME
|
|
||||||
@@ -4,23 +4,22 @@ import { PositionResult } from 'vue-router/types/router'
|
|||||||
|
|
||||||
import routes from '@/router/routes'
|
import routes from '@/router/routes'
|
||||||
|
|
||||||
Vue.use(VueRouter);
|
Vue.use(VueRouter)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If not building with SSR mode, you can
|
* If not building with SSR mode, you can
|
||||||
* directly export the Router instantiation
|
* directly export the Router instantiation
|
||||||
*/
|
*/
|
||||||
|
|
||||||
export default function (/* { store, ssrContext } */) {
|
export default function (/* { store, ssrContext } */) {
|
||||||
const Router = new VueRouter({
|
const Router = new VueRouter({
|
||||||
scrollBehavior: () => ({y: 0} as PositionResult),
|
scrollBehavior: () => ({ y: 0 } as PositionResult),
|
||||||
routes,
|
routes,
|
||||||
|
|
||||||
// Leave these as is and change from quasar.conf.js instead!
|
// Leave these as is and change from quasar.conf.js instead!
|
||||||
// quasar.conf.js -> build -> vueRouterMode
|
// quasar.conf.js -> build -> vueRouterMode
|
||||||
mode: process.env.VUE_ROUTER_MODE as RouterMode,
|
mode: process.env.VUE_ROUTER_MODE as RouterMode,
|
||||||
base: process.env.VUE_ROUTER_BASE
|
base: process.env.VUE_ROUTER_BASE
|
||||||
});
|
})
|
||||||
|
|
||||||
return Router
|
return Router
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,32 +1,39 @@
|
|||||||
import { RouteConfig } from 'vue-router'
|
import { RouteConfig } from 'vue-router';
|
||||||
|
|
||||||
import VueI18n from 'vue-i18n';
|
|
||||||
import Vue from 'vue'
|
|
||||||
Vue.use(VueI18n);
|
|
||||||
|
|
||||||
function load (component) {
|
|
||||||
return () => import(`@/components/${component}.vue`)
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
const routes: [RouteConfig] = [
|
|
||||||
{ path: '/', component: () => import('@/pages/Index.vue') },
|
|
||||||
{ path: '/signup', component: load('views/login/signup'), meta: { name: 'Registration' } },
|
|
||||||
{ path: '/signin', component: load('views/login/signin'), meta: { name: 'Login' } },
|
|
||||||
{ path: '/vreg', component: load('views/login/vreg'), meta: { name: 'Verify Reg' } },
|
|
||||||
{ path: '/requestresetpwd', component: load('views/login/requestresetpwd'), meta: { name: 'Reset your Password' } },
|
|
||||||
{ path: '/updatepwd', component: load('views/login/updatepassword'), meta: { name: 'Update your Password' } },
|
|
||||||
{ path: '/simpleform', component: load('views/form/simpleForm/simpleForm'), meta: { name: 'SimpleForm' } },
|
|
||||||
{ path: '/embeeded', component: load('views/form/embeeded/embeeded'), meta: { name: 'Embeeded' } },
|
|
||||||
|
|
||||||
|
const routes: RouteConfig[] = [
|
||||||
|
{ path: '/', component: () => import('@/pages/Index.vue'), meta: { name: 'Home' } },
|
||||||
|
{ path: '/signup', component: () => import('@/components/views/login/signup.vue'), meta: { name: 'Registration' } },
|
||||||
|
{ path: '/signin', component: () => import('@/components/views/login/signin.vue'), meta: { name: 'Login' } },
|
||||||
|
{ path: '/vreg', component: () => import('@/components/views/login/vreg.vue'), meta: { name: 'Verify Reg' } },
|
||||||
|
{
|
||||||
|
path: '/requestresetpwd',
|
||||||
|
component: () => import('@/components/views/login/requestresetpwd.vue'),
|
||||||
|
meta: { name: 'Reset your Password' }
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: '/updatepwd',
|
||||||
|
component: () => import('@/components/views/login/updatepassword.vue'),
|
||||||
|
meta: { name: 'Update your Password' }
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: '/simpleform',
|
||||||
|
component: () => import('@/components/views/form/simpleForm/simpleForm.vue'),
|
||||||
|
meta: { name: 'SimpleForm' }
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: '/embeeded',
|
||||||
|
component: () => import('@/components/views/form/embeeded/embeeded.vue'),
|
||||||
|
meta: { name: 'Embeeded' }
|
||||||
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
// Always leave this as last one
|
// Always leave this as last one
|
||||||
if (process.env.MODE !== 'ssr') {
|
if (process.env.MODE !== 'ssr') {
|
||||||
routes.push({
|
routes.push({
|
||||||
|
name: 'pages.errors.e404',
|
||||||
path: '*',
|
path: '*',
|
||||||
component: () => import('pages/Error404.vue')
|
component: () => import('@/pages/Error404.vue')
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export default routes
|
export default routes;
|
||||||
|
|||||||
9
src/shims-html.d.ts
vendored
9
src/shims-html.d.ts
vendored
@@ -1,9 +0,0 @@
|
|||||||
declare module '*.html' {
|
|
||||||
import Vue, { ComponentOptions, FunctionalComponentOptions } from 'vue'
|
|
||||||
interface WithRender {
|
|
||||||
<V extends Vue, U extends ComponentOptions<V> | FunctionalComponentOptions>(options: U): U
|
|
||||||
<V extends typeof Vue>(component: V): V
|
|
||||||
}
|
|
||||||
const withRender: WithRender
|
|
||||||
export default withRender
|
|
||||||
}
|
|
||||||
@@ -1,41 +1,13 @@
|
|||||||
import Vue from 'vue'
|
import Vue from 'vue';
|
||||||
import Vuex from 'vuex'
|
import Vuex from 'vuex';
|
||||||
|
|
||||||
//import glob from './modules/glob';
|
import { IUserState } from '@/types';
|
||||||
|
|
||||||
import {IUserState} from './types'
|
|
||||||
|
|
||||||
Vue.use(Vuex);
|
Vue.use(Vuex);
|
||||||
|
|
||||||
export interface IRootState {
|
export interface IRootState {
|
||||||
//app: IAppState;
|
user: IUserState;
|
||||||
user: IUserState;
|
role: IRootState;
|
||||||
//tagsView: ITagsViewState;
|
|
||||||
role: IRootState;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//const debug = process.env.NODE_ENV !== 'production';
|
export default new Vuex.Store<IRootState>({});
|
||||||
|
|
||||||
export default new Vuex.Store<IRootState>({
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
Vue.filter('time', timestamp => {
|
|
||||||
return new Date(timestamp).toLocaleTimeString()
|
|
||||||
});
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
export default new Vuex.Store({
|
|
||||||
state: {
|
|
||||||
version: '1.0.0',
|
|
||||||
},
|
|
||||||
modules: {
|
|
||||||
glob,
|
|
||||||
user,
|
|
||||||
},
|
|
||||||
|
|
||||||
//strict: debug,
|
|
||||||
//plugins: debug ? [createLogger()] : []
|
|
||||||
});
|
|
||||||
*/
|
|
||||||
|
|||||||
@@ -1,503 +1,505 @@
|
|||||||
import Vue from 'vue'
|
import Vue from 'vue';
|
||||||
import Vuex from 'vuex'
|
import Vuex from 'vuex';
|
||||||
|
|
||||||
import {Module, VuexModule, Mutation, MutationAction, Action} from 'vuex-module-decorators'
|
import { Module, VuexModule, Mutation, MutationAction, Action } from 'vuex-module-decorators';
|
||||||
|
|
||||||
var bcrypt = require('bcryptjs');
|
let bcrypt = require('bcryptjs');
|
||||||
|
|
||||||
import * as types from '@/store/mutation-types'
|
import * as types from '@/store/mutation-types';
|
||||||
import {serv_constants} from "@/store/modules/serv_constants";
|
import { serv_constants } from '@/store/modules/serv_constants';
|
||||||
|
|
||||||
import {IUserState, ILinkReg, IResult, IIdToken} from '../types'
|
import { IUserState, ILinkReg, IResult, IIdToken } from '@/types';
|
||||||
|
|
||||||
export const Errori_MongoDb = {
|
export const Errori_MongoDb = {
|
||||||
CALLING: 10,
|
CALLING: 10,
|
||||||
OK: 20,
|
OK: 20,
|
||||||
ERR_GENERICO: -1,
|
ERR_GENERICO: -1,
|
||||||
DUPLICATE_EMAIL_ID: 11000,
|
DUPLICATE_EMAIL_ID: 11000,
|
||||||
DUPLICATE_USERNAME_ID: 11100
|
DUPLICATE_USERNAME_ID: 11100
|
||||||
};
|
};
|
||||||
|
|
||||||
Vue.use(Vuex);
|
Vue.use(Vuex);
|
||||||
|
|
||||||
|
@Module({ dynamic: true, name: 'user' })
|
||||||
@Module({dynamic: true, name: 'user'})
|
|
||||||
export default class User extends VuexModule {
|
export default class User extends VuexModule {
|
||||||
// Non occorrono i getters, basta questi qui:
|
// Non occorrono i getters, basta questi qui:
|
||||||
_id: IUserState['_id'] = '';
|
_id: IUserState['_id'] = '';
|
||||||
email: IUserState['email'] = '';
|
email: IUserState['email'] = '';
|
||||||
username: IUserState['username'] = '';
|
username: IUserState['username'] = '';
|
||||||
idapp: IUserState['idapp'] = process.env.APP_ID;
|
idapp: IUserState['idapp'] = process.env.APP_ID;
|
||||||
password: IUserState['password'] = '';
|
password: IUserState['password'] = '';
|
||||||
lang: IUserState['lang'] = '';
|
lang: IUserState['lang'] = '';
|
||||||
ripetipassword: IUserState['ripetipassword'] = '';
|
ripetipassword: IUserState['ripetipassword'] = '';
|
||||||
idToken: IUserState['idToken'] = '';
|
idToken: IUserState['idToken'] = '';
|
||||||
userId: IUserState['userId'] = 0;
|
userId: IUserState['userId'] = 0;
|
||||||
tokens: IUserState['tokens'] = [];
|
tokens: IUserState['tokens'] = [];
|
||||||
verified_email: IUserState['verified_email'] = false;
|
verifiedEmail: IUserState['verifiedEmail'] = false;
|
||||||
|
|
||||||
servercode = 0;
|
servercode = 0;
|
||||||
|
|
||||||
getlang(): any {
|
getlang (): any {
|
||||||
if (this.lang !== "")
|
if (this.lang !== '') {
|
||||||
return this.lang;
|
return this.lang;
|
||||||
else
|
} else {
|
||||||
return process.env.LANG_DEFAULT;
|
return process.env.LANG_DEFAULT;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
sendRequest(url: string, method: string, mydata: any) {
|
sendRequest (url: string, method: string, mydata: any) {
|
||||||
console.log("LANG " + this.getlang());
|
console.log('LANG ' + this.getlang());
|
||||||
let mytok: string = this.getTok();
|
let mytok: string = this.getTok();
|
||||||
|
|
||||||
const authHeader = new Headers();
|
const authHeader = new Headers();
|
||||||
authHeader.append('content-type', 'application/json');
|
authHeader.append('content-type', 'application/json');
|
||||||
authHeader.append('x-auth', mytok);
|
authHeader.append('x-auth', mytok);
|
||||||
authHeader.append('accept-language', this.getlang());
|
authHeader.append('accept-language', this.getlang());
|
||||||
const configInit: RequestInit = {
|
const configInit: RequestInit = {
|
||||||
method: method,
|
method: method,
|
||||||
cache: "no-cache",
|
cache: 'no-cache',
|
||||||
body: JSON.stringify(mydata),
|
body: JSON.stringify(mydata),
|
||||||
headers: authHeader,
|
headers: authHeader
|
||||||
|
};
|
||||||
|
|
||||||
|
const request: Promise<Response> = fetch(url, configInit);
|
||||||
|
return request;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
getTok () {
|
||||||
|
if (this.tokens) {
|
||||||
|
if (typeof this.tokens[0] !== 'undefined') {
|
||||||
|
return this.tokens[0].token;
|
||||||
|
} else {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@MutationAction({ mutate: ['user'] })
|
||||||
|
async setpassword (newstr: string) {
|
||||||
|
return { password: newstr };
|
||||||
|
}
|
||||||
|
|
||||||
|
@MutationAction({ mutate: [types.USER_EMAIL] })
|
||||||
|
async setemail (newstr: string) {
|
||||||
|
return { email: newstr };
|
||||||
|
}
|
||||||
|
|
||||||
|
@MutationAction({ mutate: [types.USER_LANG] })
|
||||||
|
async setlang (newstr: string) {
|
||||||
|
return { lang: newstr };
|
||||||
|
}
|
||||||
|
|
||||||
|
@Mutation
|
||||||
|
authUser (data: IUserState) {
|
||||||
|
this.username = data.username;
|
||||||
|
this.userId = data.userId;
|
||||||
|
this.idToken = data.idToken;
|
||||||
|
this.verifiedEmail = data.verifiedEmail;
|
||||||
|
this.tokens = [
|
||||||
|
{ access: 'auth', token: data.idToken }
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
@Mutation
|
||||||
|
UpdatePwd (data: IIdToken) {
|
||||||
|
this.idToken = data.idToken;
|
||||||
|
if (!this.tokens) {
|
||||||
|
this.tokens = [];
|
||||||
|
}
|
||||||
|
this.tokens.push({ access: 'auth', token: data.idToken });
|
||||||
|
}
|
||||||
|
|
||||||
|
@Mutation
|
||||||
|
setServerCode (servercode: number) {
|
||||||
|
this.servercode = servercode;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Mutation
|
||||||
|
clearAuthData (): void {
|
||||||
|
this.username = '';
|
||||||
|
this.tokens = [];
|
||||||
|
this.idToken = '';
|
||||||
|
this.userId = 0;
|
||||||
|
this.verifiedEmail = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Action({ commit: types.USER_UPDATEPWD })
|
||||||
|
resetpwd (paramquery: IUserState) {
|
||||||
|
let call = process.env.MONGODB_HOST + '/updatepwd';
|
||||||
|
console.log('CALL ' + call);
|
||||||
|
|
||||||
|
let usertosend = {
|
||||||
|
keyappid: process.env.PAO_APP_ID,
|
||||||
|
idapp: process.env.APP_ID,
|
||||||
|
email: paramquery.email,
|
||||||
|
password: paramquery.password,
|
||||||
|
tokenforgot: paramquery.tokenforgot
|
||||||
|
};
|
||||||
|
console.log(usertosend);
|
||||||
|
|
||||||
|
this.setServerCode(Errori_MongoDb.CALLING);
|
||||||
|
|
||||||
|
let myres;
|
||||||
|
|
||||||
|
let x_auth_token: string = '';
|
||||||
|
|
||||||
|
return this.sendRequest(call, 'POST', usertosend)
|
||||||
|
.then((res) => {
|
||||||
|
console.log(res);
|
||||||
|
myres = res;
|
||||||
|
x_auth_token = String(res.headers.get('x-auth'));
|
||||||
|
if (myres.status === 200) {
|
||||||
|
return myres.json();
|
||||||
|
}
|
||||||
|
this.setServerCode(Errori_MongoDb.ERR_GENERICO);
|
||||||
|
return { code: Errori_MongoDb.ERR_GENERICO, msg: 'Errore: ' + myres.status, resetpwd: true };
|
||||||
|
|
||||||
|
})
|
||||||
|
.then((body) => {
|
||||||
|
this.UpdatePwd({ idToken: x_auth_token });
|
||||||
|
localStorage.setItem('token', x_auth_token);
|
||||||
|
|
||||||
|
return { code: body.code, msg: body.msg };
|
||||||
|
}).catch((err) => {
|
||||||
|
console.log('ERROR: ' + err);
|
||||||
|
this.setServerCode(Errori_MongoDb.ERR_GENERICO);
|
||||||
|
return { code: Errori_MongoDb.ERR_GENERICO, msg: 'Errore' };
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Action({ commit: types.USER_REQUESTRESETPWD })
|
||||||
|
requestpwd (paramquery: IUserState) {
|
||||||
|
|
||||||
|
let call = process.env.MONGODB_HOST + '/requestnewpwd';
|
||||||
|
console.log('CALL ' + call);
|
||||||
|
|
||||||
|
let usertosend = {
|
||||||
|
keyappid: process.env.PAO_APP_ID,
|
||||||
|
idapp: process.env.APP_ID,
|
||||||
|
email: paramquery.email
|
||||||
|
};
|
||||||
|
console.log(usertosend);
|
||||||
|
|
||||||
|
this.setServerCode(Errori_MongoDb.CALLING);
|
||||||
|
|
||||||
|
let myres;
|
||||||
|
|
||||||
|
return this.sendRequest(call, 'POST', usertosend)
|
||||||
|
.then((res) => {
|
||||||
|
console.log(res);
|
||||||
|
myres = res;
|
||||||
|
if (myres.status === 200) {
|
||||||
|
return myres.json();
|
||||||
|
}
|
||||||
|
this.setServerCode(Errori_MongoDb.ERR_GENERICO);
|
||||||
|
return { code: Errori_MongoDb.ERR_GENERICO, msg: 'Errore: ' + myres.status, resetpwd: true };
|
||||||
|
|
||||||
|
})
|
||||||
|
.then((body) => {
|
||||||
|
return { code: body.code, msg: body.msg };
|
||||||
|
}).catch((err) => {
|
||||||
|
console.log('ERROR: ' + err);
|
||||||
|
this.setServerCode(Errori_MongoDb.ERR_GENERICO);
|
||||||
|
return { code: Errori_MongoDb.ERR_GENERICO, msg: 'Errore' };
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Action({ commit: types.USER_VREG })
|
||||||
|
vreg (paramquery: ILinkReg) {
|
||||||
|
let call = process.env.MONGODB_HOST + '/vreg';
|
||||||
|
console.log('CALL ' + call);
|
||||||
|
|
||||||
|
let usertosend = {
|
||||||
|
keyappid: process.env.PAO_APP_ID,
|
||||||
|
idapp: process.env.APP_ID,
|
||||||
|
idLink: paramquery.idLink
|
||||||
|
};
|
||||||
|
console.log(usertosend);
|
||||||
|
|
||||||
|
this.setServerCode(Errori_MongoDb.CALLING);
|
||||||
|
|
||||||
|
let myres;
|
||||||
|
|
||||||
|
return this.sendRequest(call, 'POST', usertosend)
|
||||||
|
.then((res) => {
|
||||||
|
console.log(res);
|
||||||
|
myres = res;
|
||||||
|
if (myres.status === 200) {
|
||||||
|
return myres.json();
|
||||||
|
}
|
||||||
|
this.setServerCode(Errori_MongoDb.ERR_GENERICO);
|
||||||
|
return { code: Errori_MongoDb.ERR_GENERICO, msg: 'Errore: ' + myres.status };
|
||||||
|
|
||||||
|
})
|
||||||
|
.then((body) => {
|
||||||
|
// console.log("RITORNO 2 ");
|
||||||
|
// this.setServerCode(myres);
|
||||||
|
if (body.code === serv_constants.RIS_CODE_EMAIL_VERIFIED) {
|
||||||
|
localStorage.setItem('verificato', '1');
|
||||||
|
}
|
||||||
|
return { code: body.code, msg: body.msg };
|
||||||
|
}).catch((err) => {
|
||||||
|
console.log('ERROR: ' + err);
|
||||||
|
this.setServerCode(Errori_MongoDb.ERR_GENERICO);
|
||||||
|
return { code: Errori_MongoDb.ERR_GENERICO, msg: 'Errore' };
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Action({ commit: types.USER_VREG })
|
||||||
|
signup (authData: IUserState) {
|
||||||
|
let call = process.env.MONGODB_HOST + '/users';
|
||||||
|
console.log('CALL ' + call);
|
||||||
|
|
||||||
|
// console.log("PASSW: " + authData.password);
|
||||||
|
|
||||||
|
return bcrypt.hash(authData.password, bcrypt.genSaltSync(12))
|
||||||
|
.then((hashedPassword: string) => {
|
||||||
|
let usertosend = {
|
||||||
|
keyappid: process.env.PAO_APP_ID,
|
||||||
|
lang: this.getlang(),
|
||||||
|
email: authData.email,
|
||||||
|
password: String(hashedPassword),
|
||||||
|
username: authData.username,
|
||||||
|
idapp: process.env.APP_ID
|
||||||
};
|
};
|
||||||
|
|
||||||
const request: Promise<Response> = fetch(url, configInit);
|
console.log(usertosend);
|
||||||
return request;
|
|
||||||
|
|
||||||
}
|
let myres: IResult;
|
||||||
|
|
||||||
getTok() {
|
this.setServerCode(Errori_MongoDb.CALLING);
|
||||||
if (this.tokens) {
|
|
||||||
if (typeof this.tokens[0] !== 'undefined')
|
let x_auth_token: string = '';
|
||||||
return this.tokens[0].token;
|
|
||||||
else
|
return this.sendRequest(call, 'POST', usertosend)
|
||||||
return '';
|
.then((res) => {
|
||||||
|
myres = res;
|
||||||
|
x_auth_token = String(res.headers.get('x-auth'));
|
||||||
|
if (x_auth_token) {
|
||||||
|
return res.json();
|
||||||
|
} else {
|
||||||
|
return { status: 400, code: Errori_MongoDb.ERR_GENERICO };
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.then((body) => {
|
||||||
|
if (process.env.DEV) {
|
||||||
|
console.log('RISULTATO ');
|
||||||
|
console.log('STATUS ' + myres.status + ' ' + (myres.statusText));
|
||||||
|
console.log('BODY:');
|
||||||
|
console.log(body);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.setServerCode(myres.status);
|
||||||
|
|
||||||
|
if (myres.status === 200) {
|
||||||
|
let iduser = body._id;
|
||||||
|
let username = authData.username;
|
||||||
|
if (process.env.DEV) {
|
||||||
|
console.log('USERNAME = ' + username);
|
||||||
|
console.log('IDUSER= ' + iduser);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.authUser({
|
||||||
|
username: username,
|
||||||
|
userId: iduser,
|
||||||
|
idToken: x_auth_token,
|
||||||
|
verifiedEmail: false
|
||||||
|
});
|
||||||
|
|
||||||
|
const now = new Date();
|
||||||
|
// const expirationDate = new Date(now.getTime() + myres.data.expiresIn * 1000);
|
||||||
|
const expirationDate = new Date(now.getTime() + 1000);
|
||||||
|
localStorage.setItem('username', username);
|
||||||
|
localStorage.setItem('token', x_auth_token);
|
||||||
|
localStorage.setItem('userId', iduser);
|
||||||
|
localStorage.setItem('expirationDate', expirationDate.toString());
|
||||||
|
localStorage.setItem('verificato', '0');
|
||||||
|
// dispatch('storeUser', authData);
|
||||||
|
// dispatch('setLogoutTimer', myres.data.expiresIn);
|
||||||
|
|
||||||
|
return Errori_MongoDb.OK;
|
||||||
|
} else if (myres.status === 404) {
|
||||||
|
if (process.env.DEV) {
|
||||||
|
console.log('CODE = ' + body.code);
|
||||||
|
}
|
||||||
|
return body.code;
|
||||||
|
} else {
|
||||||
|
if (process.env.DEV) {
|
||||||
|
console.log('CODE = ' + body.code);
|
||||||
|
}
|
||||||
|
return body.code;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
if (process.env.DEV) {
|
||||||
|
console.log('ERROREEEEEEEEE');
|
||||||
|
console.log(error);
|
||||||
|
}
|
||||||
|
this.setServerCode(Errori_MongoDb.ERR_GENERICO);
|
||||||
|
return Errori_MongoDb.ERR_GENERICO;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Action({ commit: types.USER_SIGNIN })
|
||||||
|
signin (authData: IUserState) {
|
||||||
|
let call = process.env.MONGODB_HOST + '/users/login';
|
||||||
|
console.log('LOGIN ' + call);
|
||||||
|
|
||||||
|
console.log('MYLANG = ' + this.getlang());
|
||||||
|
|
||||||
|
const usertosend = {
|
||||||
|
username: authData.username,
|
||||||
|
password: authData.password,
|
||||||
|
idapp: process.env.APP_ID,
|
||||||
|
keyappid: process.env.PAO_APP_ID,
|
||||||
|
lang: this.getlang()
|
||||||
|
};
|
||||||
|
|
||||||
|
console.log(usertosend);
|
||||||
|
|
||||||
|
let myres: IResult;
|
||||||
|
|
||||||
|
this.setServerCode(Errori_MongoDb.CALLING);
|
||||||
|
|
||||||
|
let x_auth_token: string = '';
|
||||||
|
|
||||||
|
return this.sendRequest(call, 'POST', usertosend)
|
||||||
|
.then((res) => {
|
||||||
|
myres = res;
|
||||||
|
x_auth_token = String(res.headers.get('x-auth'));
|
||||||
|
let injson = res.json();
|
||||||
|
|
||||||
|
if (x_auth_token || injson) {
|
||||||
|
return injson;
|
||||||
} else {
|
} else {
|
||||||
return '';
|
return { status: 400, code: Errori_MongoDb.ERR_GENERICO };
|
||||||
}
|
}
|
||||||
|
})
|
||||||
|
.then((body) => {
|
||||||
|
if (process.env.DEV) {
|
||||||
|
console.log('RISULTATO ');
|
||||||
|
console.log('STATUS ' + myres.status + ' ' + (myres.statusText));
|
||||||
|
console.log('BODY:');
|
||||||
|
console.log(body);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (body.code === serv_constants.RIS_CODE_LOGIN_ERR) {
|
||||||
|
this.setServerCode(body.code);
|
||||||
|
return body.code;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.setServerCode(myres.status);
|
||||||
|
|
||||||
|
if (myres.status === 200) {
|
||||||
|
let iduser = body._id;
|
||||||
|
let username = authData.username;
|
||||||
|
let verifiedEmail = body.verifiedEmail === 'true' || body.verifiedEmail === true;
|
||||||
|
if (process.env.DEV) {
|
||||||
|
console.log('USERNAME = ' + username);
|
||||||
|
console.log('IDUSER= ' + iduser);
|
||||||
|
this.authUser({
|
||||||
|
username: username,
|
||||||
|
userId: iduser,
|
||||||
|
idToken: x_auth_token,
|
||||||
|
verifiedEmail: verifiedEmail
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
const now = new Date();
|
||||||
|
// const expirationDate = new Date(now.getTime() + myres.data.expiresIn * 1000);
|
||||||
|
const expirationDate = new Date(now.getTime() + 1000);
|
||||||
|
localStorage.setItem('username', username);
|
||||||
|
localStorage.setItem('token', x_auth_token);
|
||||||
|
localStorage.setItem('userId', iduser);
|
||||||
|
localStorage.setItem('expirationDate', expirationDate.toString());
|
||||||
|
localStorage.setItem('isLoggedin', String(true));
|
||||||
|
localStorage.setItem('verificato', String(verifiedEmail));
|
||||||
|
|
||||||
|
// dispatch('storeUser', authData);
|
||||||
|
// dispatch('setLogoutTimer', myres.data.expiresIn);
|
||||||
|
return Errori_MongoDb.OK;
|
||||||
|
} else if (myres.status === 404) {
|
||||||
|
if (process.env.DEV) {
|
||||||
|
console.log('CODE = ' + body.code);
|
||||||
|
}
|
||||||
|
return body.code;
|
||||||
|
} else {
|
||||||
|
if (process.env.DEV) {
|
||||||
|
console.log('CODE = ' + body.code);
|
||||||
|
}
|
||||||
|
return body.code;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
if (process.env.DEV) {
|
||||||
|
console.log('ERROREEEEEEEEE');
|
||||||
|
console.log(error);
|
||||||
|
}
|
||||||
|
this.setServerCode(Errori_MongoDb.ERR_GENERICO);
|
||||||
|
return Errori_MongoDb.ERR_GENERICO;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Action({ commit: types.USER_AUTOLOGIN })
|
||||||
|
autologin () {
|
||||||
|
const token = localStorage.getItem('token');
|
||||||
|
if (!token) {
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
const expirationDateStr = localStorage.getItem('expirationDate');
|
||||||
|
let expirationDate = new Date(String(expirationDateStr));
|
||||||
@MutationAction({mutate: ['user']})
|
const now = new Date();
|
||||||
async setpassword(newstr: string) {
|
if (now >= expirationDate) {
|
||||||
return {password: newstr}
|
return;
|
||||||
}
|
}
|
||||||
|
const userId = Number(localStorage.getItem('userId'));
|
||||||
|
const username = String(localStorage.getItem('username'));
|
||||||
|
const verifiedEmail = localStorage.getItem('verificato') === '1';
|
||||||
|
this.authUser({
|
||||||
|
username: username,
|
||||||
|
userId: userId,
|
||||||
|
idToken: token,
|
||||||
|
verifiedEmail: verifiedEmail
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
@MutationAction({mutate: [types.USER_EMAIL]})
|
@Action({ commit: types.USER_LOGOUT })
|
||||||
async setemail(newstr: string) {
|
logout () {
|
||||||
return {email: newstr}
|
|
||||||
}
|
|
||||||
|
|
||||||
@MutationAction({mutate: [types.USER_LANG]})
|
let call = process.env.MONGODB_HOST + '/users/me/token';
|
||||||
async setlang(newstr: string) {
|
console.log('CALL ' + call);
|
||||||
return {lang: newstr}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Mutation
|
let usertosend = {
|
||||||
authUser(data: IUserState) {
|
keyappid: process.env.PAO_APP_ID,
|
||||||
this.username = data.username;
|
idapp: process.env.APP_ID
|
||||||
this.userId = data.userId;
|
|
||||||
this.idToken = data.idToken;
|
|
||||||
this.verified_email = data.verified_email;
|
|
||||||
this.tokens = [
|
|
||||||
{access: "auth", token: data.idToken},
|
|
||||||
];
|
|
||||||
};
|
};
|
||||||
|
|
||||||
@Mutation
|
console.log(usertosend);
|
||||||
UpdatePwd(data: IIdToken) {
|
this.sendRequest(call, 'DELETE', usertosend)
|
||||||
this.idToken = data.idToken;
|
.then(
|
||||||
if (!this.tokens)
|
(res) => {
|
||||||
this.tokens = [];
|
console.log(res);
|
||||||
this.tokens.push({access: "auth", token: data.idToken});
|
|
||||||
};
|
|
||||||
|
|
||||||
@Mutation
|
|
||||||
setServerCode(servercode: number) {
|
|
||||||
this.servercode = servercode;
|
|
||||||
};
|
|
||||||
|
|
||||||
@Mutation
|
|
||||||
clearAuthData(): void {
|
|
||||||
this.username = '';
|
|
||||||
this.tokens = [];
|
|
||||||
this.idToken = '';
|
|
||||||
this.userId = 0;
|
|
||||||
this.verified_email = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Action({commit: types.USER_UPDATEPWD})
|
|
||||||
resetpwd(paramquery: IUserState) {
|
|
||||||
var call = process.env.MONGODB_HOST + '/updatepwd';
|
|
||||||
console.log("CALL " + call);
|
|
||||||
|
|
||||||
let usertosend = {
|
|
||||||
keyappid: process.env.PAO_APP_ID,
|
|
||||||
idapp: process.env.APP_ID,
|
|
||||||
email: paramquery.email,
|
|
||||||
password: paramquery.password,
|
|
||||||
tokenforgot: paramquery.tokenforgot,
|
|
||||||
};
|
|
||||||
console.log(usertosend);
|
|
||||||
|
|
||||||
this.setServerCode(Errori_MongoDb.CALLING);
|
|
||||||
|
|
||||||
var myres;
|
|
||||||
|
|
||||||
var x_auth_token: string = "";
|
|
||||||
|
|
||||||
return this.sendRequest(call, "POST", usertosend)
|
|
||||||
.then((res) => {
|
|
||||||
console.log(res);
|
|
||||||
myres = res;
|
|
||||||
x_auth_token = String(res.headers.get('x-auth'));
|
|
||||||
if (myres.status === 200) {
|
|
||||||
return myres.json();
|
|
||||||
}
|
|
||||||
this.setServerCode(Errori_MongoDb.ERR_GENERICO);
|
|
||||||
return {code: Errori_MongoDb.ERR_GENERICO, msg: 'Errore: ' + myres.status, resetpwd: true};
|
|
||||||
|
|
||||||
})
|
|
||||||
.then((body) => {
|
|
||||||
this.UpdatePwd({idToken: x_auth_token});
|
|
||||||
localStorage.setItem('token', x_auth_token);
|
|
||||||
|
|
||||||
return {code: body.code, msg: body.msg};
|
|
||||||
}).catch((err) => {
|
|
||||||
console.log("ERROR: " + err);
|
|
||||||
this.setServerCode(Errori_MongoDb.ERR_GENERICO);
|
|
||||||
return {code: Errori_MongoDb.ERR_GENERICO, msg: 'Errore'};
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Action({commit: types.USER_REQUESTRESETPWD})
|
|
||||||
requestpwd(paramquery: IUserState) {
|
|
||||||
|
|
||||||
var call = process.env.MONGODB_HOST + '/requestnewpwd';
|
|
||||||
console.log("CALL " + call);
|
|
||||||
|
|
||||||
let usertosend = {
|
|
||||||
keyappid: process.env.PAO_APP_ID,
|
|
||||||
idapp: process.env.APP_ID,
|
|
||||||
email: paramquery.email,
|
|
||||||
};
|
|
||||||
console.log(usertosend);
|
|
||||||
|
|
||||||
this.setServerCode(Errori_MongoDb.CALLING);
|
|
||||||
|
|
||||||
var myres;
|
|
||||||
|
|
||||||
return this.sendRequest(call, "POST", usertosend)
|
|
||||||
.then((res) => {
|
|
||||||
console.log(res);
|
|
||||||
myres = res;
|
|
||||||
if (myres.status === 200) {
|
|
||||||
return myres.json();
|
|
||||||
}
|
|
||||||
this.setServerCode(Errori_MongoDb.ERR_GENERICO);
|
|
||||||
return {code: Errori_MongoDb.ERR_GENERICO, msg: 'Errore: ' + myres.status, resetpwd: true};
|
|
||||||
|
|
||||||
})
|
|
||||||
.then((body) => {
|
|
||||||
return {code: body.code, msg: body.msg};
|
|
||||||
}).catch((err) => {
|
|
||||||
console.log("ERROR: " + err);
|
|
||||||
this.setServerCode(Errori_MongoDb.ERR_GENERICO);
|
|
||||||
return {code: Errori_MongoDb.ERR_GENERICO, msg: 'Errore'};
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Action({commit: types.USER_VREG})
|
|
||||||
vreg(paramquery: ILinkReg) {
|
|
||||||
var call = process.env.MONGODB_HOST + '/vreg';
|
|
||||||
console.log("CALL " + call);
|
|
||||||
|
|
||||||
let usertosend = {
|
|
||||||
keyappid: process.env.PAO_APP_ID,
|
|
||||||
idapp: process.env.APP_ID,
|
|
||||||
idLink: paramquery.idLink,
|
|
||||||
};
|
|
||||||
console.log(usertosend);
|
|
||||||
|
|
||||||
this.setServerCode(Errori_MongoDb.CALLING);
|
|
||||||
|
|
||||||
var myres;
|
|
||||||
|
|
||||||
return this.sendRequest(call, "POST", usertosend)
|
|
||||||
.then((res) => {
|
|
||||||
console.log(res);
|
|
||||||
myres = res;
|
|
||||||
if (myres.status === 200) {
|
|
||||||
return myres.json();
|
|
||||||
}
|
|
||||||
this.setServerCode(Errori_MongoDb.ERR_GENERICO);
|
|
||||||
return {code: Errori_MongoDb.ERR_GENERICO, msg: 'Errore: ' + myres.status};
|
|
||||||
|
|
||||||
})
|
|
||||||
.then((body) => {
|
|
||||||
//console.log("RITORNO 2 ");
|
|
||||||
//this.setServerCode(myres);
|
|
||||||
if (body.code === serv_constants.RIS_CODE_EMAIL_VERIFIED)
|
|
||||||
localStorage.setItem('verificato', "1");
|
|
||||||
return {code: body.code, msg: body.msg};
|
|
||||||
}).catch((err) => {
|
|
||||||
console.log("ERROR: " + err);
|
|
||||||
this.setServerCode(Errori_MongoDb.ERR_GENERICO);
|
|
||||||
return {code: Errori_MongoDb.ERR_GENERICO, msg: 'Errore'};
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Action({commit: types.USER_VREG})
|
|
||||||
signup(authData: IUserState) {
|
|
||||||
var call = process.env.MONGODB_HOST + '/users';
|
|
||||||
console.log("CALL " + call);
|
|
||||||
|
|
||||||
//console.log("PASSW: " + authData.password);
|
|
||||||
|
|
||||||
return bcrypt.hash(authData.password, bcrypt.genSaltSync(12))
|
|
||||||
.then((hashedPassword:string) => {
|
|
||||||
let usertosend = {
|
|
||||||
keyappid: process.env.PAO_APP_ID,
|
|
||||||
lang: this.getlang(),
|
|
||||||
email: authData.email,
|
|
||||||
password: String(hashedPassword),
|
|
||||||
username: authData.username,
|
|
||||||
idapp: process.env.APP_ID,
|
|
||||||
};
|
|
||||||
|
|
||||||
console.log(usertosend);
|
|
||||||
|
|
||||||
var myres: IResult;
|
|
||||||
|
|
||||||
this.setServerCode(Errori_MongoDb.CALLING);
|
|
||||||
|
|
||||||
var x_auth_token: string = '';
|
|
||||||
|
|
||||||
return this.sendRequest(call, "POST", usertosend)
|
|
||||||
.then((res) => {
|
|
||||||
myres = res;
|
|
||||||
x_auth_token = String(res.headers.get('x-auth'));
|
|
||||||
if (x_auth_token) {
|
|
||||||
return res.json();
|
|
||||||
} else {
|
|
||||||
return {status: 400, code: Errori_MongoDb.ERR_GENERICO}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.then((body) => {
|
|
||||||
if (process.env.DEV) {
|
|
||||||
console.log("RISULTATO ");
|
|
||||||
console.log("STATUS " + myres.status + " " + (myres.statusText));
|
|
||||||
console.log("BODY:");
|
|
||||||
console.log(body);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.setServerCode(myres.status);
|
|
||||||
|
|
||||||
if (myres.status === 200) {
|
|
||||||
var iduser = body._id;
|
|
||||||
var username = authData.username;
|
|
||||||
if (process.env.DEV) {
|
|
||||||
console.log("USERNAME = " + username);
|
|
||||||
console.log("IDUSER= " + iduser);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.authUser({
|
|
||||||
username: username,
|
|
||||||
userId: iduser,
|
|
||||||
idToken: x_auth_token,
|
|
||||||
verified_email: false
|
|
||||||
});
|
|
||||||
|
|
||||||
const now = new Date();
|
|
||||||
//const expirationDate = new Date(now.getTime() + myres.data.expiresIn * 1000);
|
|
||||||
const expirationDate = new Date(now.getTime() + 1000);
|
|
||||||
localStorage.setItem('username', username);
|
|
||||||
localStorage.setItem('token', x_auth_token);
|
|
||||||
localStorage.setItem('userId', iduser);
|
|
||||||
localStorage.setItem('expirationDate', expirationDate.toString());
|
|
||||||
localStorage.setItem('verificato', "0");
|
|
||||||
//dispatch('storeUser', authData);
|
|
||||||
//dispatch('setLogoutTimer', myres.data.expiresIn);
|
|
||||||
|
|
||||||
return Errori_MongoDb.OK;
|
|
||||||
} else if (myres.status === 404) {
|
|
||||||
if (process.env.DEV) {
|
|
||||||
console.log("CODE = " + body.code);
|
|
||||||
}
|
|
||||||
return body.code;
|
|
||||||
} else {
|
|
||||||
if (process.env.DEV) {
|
|
||||||
console.log("CODE = " + body.code);
|
|
||||||
}
|
|
||||||
return body.code;
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.catch((error) => {
|
|
||||||
if (process.env.DEV) {
|
|
||||||
console.log("ERROREEEEEEEEE");
|
|
||||||
console.log(error);
|
|
||||||
}
|
|
||||||
this.setServerCode(Errori_MongoDb.ERR_GENERICO);
|
|
||||||
return Errori_MongoDb.ERR_GENERICO;
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Action({commit: types.USER_SIGNIN})
|
|
||||||
signin(authData: IUserState) {
|
|
||||||
var call = process.env.MONGODB_HOST + '/users/login';
|
|
||||||
console.log("LOGIN " + call);
|
|
||||||
|
|
||||||
console.log("MYLANG = " + this.getlang());
|
|
||||||
|
|
||||||
const usertosend = {
|
|
||||||
username: authData.username,
|
|
||||||
password: authData.password,
|
|
||||||
idapp: process.env.APP_ID,
|
|
||||||
keyappid: process.env.PAO_APP_ID,
|
|
||||||
lang: this.getlang(),
|
|
||||||
};
|
|
||||||
|
|
||||||
console.log(usertosend);
|
|
||||||
|
|
||||||
var myres: IResult;
|
|
||||||
|
|
||||||
this.setServerCode(Errori_MongoDb.CALLING);
|
|
||||||
|
|
||||||
var x_auth_token: string = "";
|
|
||||||
|
|
||||||
return this.sendRequest(call, "POST", usertosend)
|
|
||||||
.then((res) => {
|
|
||||||
myres = res;
|
|
||||||
x_auth_token = String(res.headers.get('x-auth'));
|
|
||||||
var injson = res.json();
|
|
||||||
|
|
||||||
if (x_auth_token || injson) {
|
|
||||||
return injson;
|
|
||||||
} else {
|
|
||||||
return {status: 400, code: Errori_MongoDb.ERR_GENERICO}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.then((body) => {
|
|
||||||
if (process.env.DEV) {
|
|
||||||
console.log("RISULTATO ");
|
|
||||||
console.log("STATUS " + myres.status + " " + (myres.statusText));
|
|
||||||
console.log("BODY:");
|
|
||||||
console.log(body);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (body.code === serv_constants.RIS_CODE_LOGIN_ERR) {
|
|
||||||
this.setServerCode(body.code);
|
|
||||||
return body.code;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.setServerCode(myres.status);
|
|
||||||
|
|
||||||
if (myres.status === 200) {
|
|
||||||
var iduser = body._id;
|
|
||||||
var username = authData.username;
|
|
||||||
var verified_email = body.verified_email === "true" || body.verified_email === true;
|
|
||||||
if (process.env.DEV) {
|
|
||||||
console.log("USERNAME = " + username);
|
|
||||||
console.log("IDUSER= " + iduser);
|
|
||||||
this.authUser({
|
|
||||||
username: username,
|
|
||||||
userId: iduser,
|
|
||||||
idToken: x_auth_token,
|
|
||||||
verified_email: verified_email
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
const now = new Date();
|
|
||||||
//const expirationDate = new Date(now.getTime() + myres.data.expiresIn * 1000);
|
|
||||||
const expirationDate = new Date(now.getTime() + 1000);
|
|
||||||
localStorage.setItem('username', username);
|
|
||||||
localStorage.setItem('token', x_auth_token);
|
|
||||||
localStorage.setItem('userId', iduser);
|
|
||||||
localStorage.setItem('expirationDate', expirationDate.toString());
|
|
||||||
localStorage.setItem('isLoggedin', String(true));
|
|
||||||
localStorage.setItem('verificato', String(verified_email));
|
|
||||||
|
|
||||||
//dispatch('storeUser', authData);
|
|
||||||
//dispatch('setLogoutTimer', myres.data.expiresIn);
|
|
||||||
return Errori_MongoDb.OK;
|
|
||||||
} else if (myres.status === 404) {
|
|
||||||
if (process.env.DEV) {
|
|
||||||
console.log("CODE = " + body.code);
|
|
||||||
}
|
|
||||||
return body.code;
|
|
||||||
} else {
|
|
||||||
if (process.env.DEV) {
|
|
||||||
console.log("CODE = " + body.code);
|
|
||||||
}
|
|
||||||
return body.code;
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.catch((error) => {
|
|
||||||
if (process.env.DEV) {
|
|
||||||
console.log("ERROREEEEEEEEE");
|
|
||||||
console.log(error);
|
|
||||||
}
|
|
||||||
this.setServerCode(Errori_MongoDb.ERR_GENERICO);
|
|
||||||
return Errori_MongoDb.ERR_GENERICO;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Action({commit: types.USER_AUTOLOGIN})
|
|
||||||
autologin() {
|
|
||||||
const token = localStorage.getItem('token');
|
|
||||||
if (!token) {
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
const expirationDateStr = localStorage.getItem('expirationDate');
|
).catch((err) => {
|
||||||
let expirationDate = new Date(String(expirationDateStr));
|
console.log('ERROR: ' + err);
|
||||||
const now = new Date();
|
}).then(() => {
|
||||||
if (now >= expirationDate) {
|
this.clearAuthData();
|
||||||
return
|
});
|
||||||
}
|
|
||||||
const userId = Number(localStorage.getItem('userId'));
|
|
||||||
const username = String(localStorage.getItem('username'));
|
|
||||||
const verified_email = localStorage.getItem('verificato') === "1";
|
|
||||||
this.authUser({
|
|
||||||
username: username,
|
|
||||||
userId: userId,
|
|
||||||
idToken: token,
|
|
||||||
verified_email: verified_email
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Action({commit: types.USER_LOGOUT})
|
localStorage.removeItem('expirationDate');
|
||||||
logout() {
|
localStorage.removeItem('token');
|
||||||
|
localStorage.removeItem('userId');
|
||||||
|
localStorage.removeItem('username');
|
||||||
|
localStorage.removeItem('isLoggedin');
|
||||||
|
localStorage.removeItem('verifiedEmail');
|
||||||
|
|
||||||
var call = process.env.MONGODB_HOST + '/users/me/token';
|
// router.replace('/signin')
|
||||||
console.log("CALL " + call);
|
}
|
||||||
|
|
||||||
let usertosend = {
|
|
||||||
keyappid: process.env.PAO_APP_ID,
|
|
||||||
idapp: process.env.APP_ID,
|
|
||||||
};
|
|
||||||
|
|
||||||
console.log(usertosend);
|
|
||||||
this.sendRequest(call, "DELETE", usertosend)
|
|
||||||
.then(
|
|
||||||
(res) => {
|
|
||||||
console.log(res);
|
|
||||||
}
|
|
||||||
).catch((err) => {
|
|
||||||
console.log("ERROR: " + err);
|
|
||||||
}).then(() => {
|
|
||||||
this.clearAuthData();
|
|
||||||
});
|
|
||||||
|
|
||||||
localStorage.removeItem('expirationDate');
|
|
||||||
localStorage.removeItem('token');
|
|
||||||
localStorage.removeItem('userId');
|
|
||||||
localStorage.removeItem('username');
|
|
||||||
localStorage.removeItem('isLoggedin');
|
|
||||||
localStorage.removeItem('verified_email');
|
|
||||||
|
|
||||||
//router.replace('/signin')
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
export const SET_VALUE = 'SET_VALUE';
|
export const SET_VALUE = 'SET_VALUE';
|
||||||
export const SET_DEFFERED_PROMPT = 'defprompt';
|
export const SET_DEFFERED_PROMPT = 'defprompt';
|
||||||
export const SET_LOGIN_PAGE = 'setloginpage';
|
export const SET_LOGIN_PAGE = 'setloginpage';
|
||||||
@@ -23,5 +22,3 @@ export const USER_LOGOUT = 'logout';
|
|||||||
export const USER_VREG = 'vreg';
|
export const USER_VREG = 'vreg';
|
||||||
export const USER_REQUESTRESETPWD = 'requestpwd';
|
export const USER_REQUESTRESETPWD = 'requestpwd';
|
||||||
export const USER_UPDATEPWD = 'resetpwd';
|
export const USER_UPDATEPWD = 'resetpwd';
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,37 +0,0 @@
|
|||||||
|
|
||||||
export interface IToken {
|
|
||||||
access: string;
|
|
||||||
token: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface IUserState {
|
|
||||||
_id? : string;
|
|
||||||
email? : string;
|
|
||||||
username : string;
|
|
||||||
idapp? : any;
|
|
||||||
password? : string;
|
|
||||||
lang? : string;
|
|
||||||
ripetipassword?: string;
|
|
||||||
|
|
||||||
idToken : string;
|
|
||||||
userId : number;
|
|
||||||
|
|
||||||
tokens? : IToken[];
|
|
||||||
|
|
||||||
verified_email: boolean;
|
|
||||||
|
|
||||||
tokenforgot? : string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface ILinkReg {
|
|
||||||
idLink : string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface IIdToken {
|
|
||||||
idToken : string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface IResult {
|
|
||||||
status : number;
|
|
||||||
statusText : string;
|
|
||||||
}
|
|
||||||
16
src/vue.d.ts
vendored
16
src/vue.d.ts
vendored
@@ -1,16 +0,0 @@
|
|||||||
declare module "*.vue" {
|
|
||||||
import Vue from "vue"
|
|
||||||
export default Vue
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Now when you're importing components from a page, for example:
|
|
||||||
<script lang="ts">
|
|
||||||
import Vue from 'vue'
|
|
||||||
import TestComponent from '../components/test-component.vue'
|
|
||||||
export default Vue.extend({
|
|
||||||
components: {
|
|
||||||
'test-component': TestComponent
|
|
||||||
}
|
|
||||||
})
|
|
||||||
</script>
|
|
||||||
*/
|
|
||||||
@@ -1,37 +1,35 @@
|
|||||||
{
|
{
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"target": "es5",
|
"target": "es5",
|
||||||
"module": "esnext",
|
"module": "esnext",
|
||||||
"strict": true,
|
"strict": true,
|
||||||
"esModuleInterop": true,
|
"esModuleInterop": true,
|
||||||
"sourceMap": true,
|
"sourceMap": true,
|
||||||
"experimentalDecorators": true,
|
"experimentalDecorators": true,
|
||||||
"noImplicitAny": true,
|
"noImplicitAny": true,
|
||||||
"emitHelpers": true,
|
"moduleResolution": "node",
|
||||||
"importHelpers": true,
|
"lib": [
|
||||||
"moduleResolution": "node",
|
"es2015",
|
||||||
"lib": [
|
"dom"
|
||||||
"es2015",
|
],
|
||||||
"dom"
|
"baseUrl": ".",
|
||||||
],
|
"paths": {
|
||||||
"baseUrl": ".",
|
"~/*": ["./*"],
|
||||||
"paths": {
|
"@/*": ["src/*"]
|
||||||
"~/*": ["./*"],
|
},
|
||||||
"@/*": ["src/*"]
|
"types": [
|
||||||
},
|
"node",
|
||||||
"types": [
|
"jest"
|
||||||
"node",
|
]
|
||||||
"jest"
|
},
|
||||||
]
|
"include": [
|
||||||
},
|
"src/**/*.ts",
|
||||||
"include": [
|
"src/**/*.vue",
|
||||||
"src/**/*.ts",
|
"test/**/*.ts"
|
||||||
"src/**/*.vue",
|
],
|
||||||
"test/**/*.ts"
|
"exclude": [
|
||||||
],
|
".quasar",
|
||||||
"exclude": [
|
"dist",
|
||||||
".quasar",
|
"node_modules"
|
||||||
"dist",
|
]
|
||||||
"node_modules"
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
|
|||||||
13
tslint.json
Normal file
13
tslint.json
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
{
|
||||||
|
"defaultSeverity": "warning",
|
||||||
|
"extends": [
|
||||||
|
"tslint-config-standard"
|
||||||
|
],
|
||||||
|
"rules": {
|
||||||
|
"semicolon": [
|
||||||
|
true,
|
||||||
|
"always",
|
||||||
|
"ignore-bound-class-methods"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user