mysql身份验证设置_如何设置身份验证

mysql身份验证设置

After struggling to get the concept of authentication, I thought it would be nice to share the process with others who are having the same issue.

在努力理解身份验证的概念之后,我认为最好与遇到相同问题的其他人共享该过程。

As a junior developer, the word “authentication” has always scared the heck out of me. Thankfully, I came across Redux and React with JWT and bcrypt.js for authentication.

作为一名初级开发人员,“身份验证”一词总是让我感到恐惧。 幸运的是,我遇到了Redux和带有JWT和bcrypt.js的 React进行身份验证。

In this tutorial, you will learn how to create user authentication from scratch on both the back end and front end.

在本教程中,您将学习如何在后端和前端上从头开始创建用户身份验证。

We are going to divide this tutorial into seven steps:

我们将本教程分为七个步骤:

  1. Installation and setup

    安装与设定
  2. Write our app logic

    编写我们的应用逻辑
  3. Test app with Postman

    使用邮递员测试应用
  4. Installation and setup on the front end

    前端安装和设置
  5. Handle Redux logic

    处理Redux逻辑
  6. Optional components

    可选组件
  7. Pages

    页数

Let’s get into it!

让我们开始吧!

Prerequisite: This article is meant for those with basic knowledge of Express and Mongo DB (with the help of Mongoose).

先决条件:本文适用于具有Express和Mongo DB(在Mongoose的帮助下)的基础知识的人。

步骤1:安装与设定 (Step 1: Installation and Setup)

I am assuming you already have an environment for development.

我假设您已经有一个开发环境。

First of all, we need to install some packages that we are going to use in our app. In this article, I will use the npm package manager, but feel free to use any package manager of your choice:

首先,我们需要安装一些将在我们的应用程序中使用的软件包。 在本文中,我将使用npm软件包管理器,但可以随意使用您选择的任何软件包管理器:

npm init -y

Let’s install all packages for the back end:

让我们为后端安装所有软件包:

npm install express mongoose bcryptjs jsonwebtoken

I will briefly go over the packages we installed:

我将简要介绍一下我们安装的软件包:

  • Jsonwebtoken allows you to transmit information securely between two parties as a JSON object.

    Jsonwebtoken允许您作为JSON对象在两方之间安全地传输信息。

  • Mongoose is an Object Data Modelling (ODM) library for Node.js and MongoDB.

    Mongoose是用于Node.js和MongoDB的对象数据建模(ODM)库。

  • Bcrpytjs is a password hashing function.

    Bcrpytjs是密码哈希函数。

  • Express is a Node.js framework with a slightly simpler interface for building back ends.

    Express是一个Node.js框架,具有用于构建后端的稍微简单的界面。

If everything goes well, you should see this in your package.js:

如果一切顺利,您应该在package.js看到:

Image for post
package.js file in the root directory
根目录中的package.js文件

Now let’s set up our folder structure as follows:

现在,让我们如下设置文件夹结构:

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值