Full-Stack Web Development with Vue.js and Node
Building Authentication with passport.js Chapter 6 To start using this package, let's define it in server.js as well: const morg ...
Building Authentication with passport.js Chapter 6 app.use(morgan('combined')); app.use(bodyParser.json()); app.use(cors()); app ...
Building Authentication with passport.js Chapter 6 const jwt = require('jsonwebtoken'); const passport = require('passport'); co ...
Building Authentication with passport.js Chapter 6 Creating a User model We don't have a collection yet to manage the users. We ...
Building Authentication with passport.js Chapter 6 Now, when we save a user, we should create our own method to add users to the ...
Building Authentication with passport.js Chapter 6 name, email, password, }); User.createUser(newUser, (error, user) => { if ...
Building Authentication with passport.js Chapter 6 Creating a register view page Let's add a view page for the users to sign up. ...
Building Authentication with passport.js Chapter 6 In src/router/index.js, add the following lines of code: import Vue from 'vue ...
Building Authentication with passport.js Chapter 6 That's it! Now, let's navigate to http://localhost.com:8080/users/register: A ...
Building Authentication with passport.js Chapter 6 v => !!v || 'E-mail is required', v => /\S+@\S+\.\S+/.test(v) || 'E-mai ...
Building Authentication with passport.js Chapter 6 </template> <script> import axios from 'axios'; export default { ...
Building Authentication with passport.js Chapter 6 }, }, }; </script> If you are familiar with ajax, you should be able to ...
Building Authentication with passport.js Chapter 6 As you can see in the preceding code, if there is a failure in the request, w ...
Building Authentication with passport.js Chapter 6 As I mentioned, another thing that we will need to check is the password. Let ...
Building Authentication with passport.js Chapter 6 const password = req.body.password; const newUser = new User({ name, email, p ...
Building Authentication with passport.js Chapter 6 Since the JWT strategy is a part of passport.js, we will need to initialize t ...
Building Authentication with passport.js Chapter 6 In the preceding screenshot, note that JWT takes the payload, signs it, and g ...
Building Authentication with passport.js Chapter 6 Vue.use(Router); export default new Router({ mode: 'history', routes: [ { pat ...
Building Authentication with passport.js Chapter 6 That's it. Now, let's navigate to http://localhost.com:8080/users/login: Addi ...
Building Authentication with passport.js Chapter 6 email: '', password: '', emailRules: [ v => !!v || 'E-mail is required', v ...
«
5
6
7
8
9
10
11
12
13
14
»
Free download pdf