Vue + Vuex - User Registration and Login Tutorial & Example
To see a demo and further details go to http://jasonwatmore.com/post/2018/07/14/vue-vuex-user-registration-and-login-tutorial-example
Vue + Vuex - User Registration and Login Tutorial & Example
Home Page: http://jasonwatmore.com/post/2018/07/14/vue-vuex-user-registration-and-login-tutorial-example
License: MIT License
Vue + Vuex - User Registration and Login Tutorial & Example
To see a demo and further details go to http://jasonwatmore.com/post/2018/07/14/vue-vuex-user-registration-and-login-tutorial-example
Hi,
I follow the setup instruction in this guide:
https://jasonwatmore.com/post/2018/07/14/vue-vuex-user-registration-and-login-tutorial-example
Steps:
- Install NodeJS and NPM from https://nodejs.org/en/download/.
- Download or clone the project source code from https://github.com/cornflourblue/vue-vuex-registration-login-example
- Install all required npm packages by running npm install from the command line in the project root folder (where the package.json is located).
- Start the application by running npm start from the command line in the project root folder, this will launch a browser displaying the application.
However, it throw errors when i perform npm start.
Error Logs:
jerry [19:56:32] [~/Desktop/GitHub/vue-vuex-registration-login-example] [dev *]
-> % npm start
> [email protected] start /Users/jerry/Desktop/GitHub/vue-vuex-registration-login-example
> webpack-dev-server --open
ℹ 「wds」: Project is running at http://localhost:8080/
ℹ 「wds」: webpack output is served from /
ℹ 「wds」: Content not from webpack is served from /Users/jerry/Desktop/GitHub/vue-vuex-registration-login-example
ℹ 「wds」: 404s will fallback to /index.html
ℹ 「wdm」: wait until bundle finished: /
✖ 「wdm」: Hash: c99df25eb5d500d1418c
Version: webpack 4.41.2
Time: 1649ms
Built at: 05/11/2020 19:56:53
Asset Size Chunks Chunk Names
index.html 800 bytes [emitted]
main.js 1.1 MiB main [emitted] main
Entrypoint main = main.js
[0] multi (webpack)-dev-server/client?http://localhost:8080 ./src 40 bytes {main} [built]
[./node_modules/strip-ansi/index.js] 161 bytes {main} [built]
[./node_modules/vee-validate/dist/vee-validate.esm.js] 326 KiB {main} [built]
[./node_modules/vue/dist/vue.runtime.esm.js] 222 KiB {main} [built]
[./node_modules/webpack-dev-server/client/index.js?http://localhost:8080] (webpack)-dev-server/client?http://localhost:8080 4.29 KiB {main} [built]
[./node_modules/webpack-dev-server/client/overlay.js] (webpack)-dev-server/client/overlay.js 3.51 KiB {main} [built]
[./node_modules/webpack-dev-server/client/socket.js] (webpack)-dev-server/client/socket.js 1.53 KiB {main} [built]
[./node_modules/webpack-dev-server/client/utils/createSocketUrl.js] (webpack)-dev-server/client/utils/createSocketUrl.js 2.91 KiB {main} [built]
[./node_modules/webpack-dev-server/client/utils/log.js] (webpack)-dev-server/client/utils/log.js 964 bytes {main} [built]
[./node_modules/webpack-dev-server/client/utils/reloadApp.js] (webpack)-dev-server/client/utils/reloadApp.js 1.59 KiB {main} [built]
[./node_modules/webpack-dev-server/client/utils/sendMessage.js] (webpack)-dev-server/client/utils/sendMessage.js 402 bytes {main} [built]
[./node_modules/webpack/hot sync ^\.\/log$] (webpack)/hot sync nonrecursive ^\.\/log$ 170 bytes {main} [built]
[./src/_helpers/index.js] 88 bytes {main} [built]
[./src/_store/index.js] 298 bytes {main} [built]
[./src/index.js] 362 bytes {main} [built]
+ 48 hidden modules
ERROR in ./src/app/App.vue (./node_modules/babel-loader/lib!./node_modules/vue-loader/lib/selector.js?type=script&index=0!./src/app/App.vue)
Module build failed (from ./node_modules/babel-loader/lib/index.js):
SyntaxError: Unexpected token (20:8)
18 | name: 'app',
19 | computed: {
> 20 | ...mapState({
| ^
21 | alert: state => state.alert
22 | })
23 | },
@ ./src/app/App.vue 3:0-103 3:0-103 4:0-116 17:2-16
@ ./src/index.js
ERROR in ./src/home/HomePage.vue (./node_modules/babel-loader/lib!./node_modules/vue-loader/lib/selector.js?type=script&index=0!./src/home/HomePage.vue)
Module build failed (from ./node_modules/babel-loader/lib/index.js):
SyntaxError: Unexpected token (27:8)
25 | export default {
26 | computed: {
> 27 | ...mapState({
| ^
28 | account: state => state.account,
29 | users: state => state.users.all
30 | })
@ ./src/home/HomePage.vue 3:0-108 3:0-108 4:0-121 17:2-16
@ ./src/_helpers/router.js
@ ./src/_helpers/index.js
@ ./src/index.js
ERROR in ./src/login/LoginPage.vue (./node_modules/babel-loader/lib!./node_modules/vue-loader/lib/selector.js?type=script&index=0!./src/login/LoginPage.vue)
Module build failed (from ./node_modules/babel-loader/lib/index.js):
SyntaxError: Unexpected token (36:8)
34 | },
35 | computed: {
> 36 | ...mapState('account', ['status'])
| ^
37 | },
38 | created () {
39 | // reset login status
@ ./src/login/LoginPage.vue 3:0-109 3:0-109 4:0-122 17:2-16
@ ./src/_helpers/router.js
@ ./src/_helpers/index.js
@ ./src/index.js
ERROR in ./src/_store/users.module.js
Module build failed (from ./node_modules/babel-loader/lib/index.js):
SyntaxError: Unexpected token (43:20)
41 | state.all.items = state.all.items.map(user =>
42 | user.id === id
> 43 | ? { ...user, deleting: true }
| ^
44 | : user
45 | )
46 | },
@ ./src/_store/index.js 6:0-39 14:8-13
@ ./src/index.js
ERROR in ./src/register/RegisterPage.vue (./node_modules/babel-loader/lib!./node_modules/vue-loader/lib/selector.js?type=script&index=0!./src/register/RegisterPage.vue)
Module build failed (from ./node_modules/babel-loader/lib/index.js):
SyntaxError: Unexpected token (50:8)
48 | },
49 | computed: {
> 50 | ...mapState('account', ['status'])
| ^
51 | },
52 | methods: {
53 | ...mapActions('account', ['register']),
@ ./src/register/RegisterPage.vue 3:0-112 3:0-112 4:0-125 17:2-16
@ ./src/_helpers/router.js
@ ./src/_helpers/index.js
@ ./src/index.js
ERROR in ./src/_services/user.service.js
Module build failed (from ./node_modules/babel-loader/lib/index.js):
SyntaxError: Unexpected token (71:19)
69 | const requestOptions = {
70 | method: 'PUT',
> 71 | headers: { ...authHeader(), 'Content-Type': 'application/json' },
| ^
72 | body: JSON.stringify(user)
73 | };
74 |
@ ./src/_services/index.js 1:0-31 1:0-31
@ ./src/_store/account.module.js
@ ./src/_store/index.js
@ ./src/index.js
Child html-webpack-plugin for "index.html":
1 asset
Entrypoint undefined = index.html
[./node_modules/html-webpack-plugin/lib/loader.js!./src/index.html] 963 bytes {0} [built]
[./node_modules/lodash/lodash.js] 528 KiB {0} [built]
[./node_modules/webpack/buildin/global.js] (webpack)/buildin/global.js 472 bytes {0} [built]
[./node_modules/webpack/buildin/module.js] (webpack)/buildin/module.js 497 bytes {0} [built]
ℹ 「wdm」: Failed to compile.
Could advise on this error?
Thanks.
In the page fake-backend-js
path is return as fake-backend.ts ( a typescript file) but in actual repo, it is js file.
One import something is that, storing the user info in the localStorage will leak the user into out, you can get user info easily by web browser debug tool.
Any suggestion for this problem?
Hello!
I am trying to figure out the code.
Please tell me how can I create or call a method (if any) that determines whether the user is logged in or not?
For example IsAuth() method.
I need this for one public page, display a block that is visible only to those who are logged in.
I partially understand that this is due to VUEX, but I am still new to him.
logout action
shoudn't be auto triggered in LoginPage
,instead when the user found already logged in,the LoginPage
should redirect to the HomePage
and show a message saying "you are already logged in the site"?A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.