课程: React: Creating and Hosting a Full-Stack Site (2022)
今天就学习课程吧!
今天就开通帐号,24,700 门业界名师课程任您挑!
Protecting the upvote and comment endpoints
课程: React: Creating and Hosting a Full-Stack Site (2022)
Protecting the upvote and comment endpoints
- [Instructor] The next two endpoints are going to be a little bit trickier, I believe. So, first of all, let's take a look at how to refactor this up vote endpoint so that we make sure that only users who haven't up-voted the article before can do so. Well, first of all, one thing that we should notice is that the up vote endpoint and the comments endpoint are both going to have the same initial criteria. And that is, if the user isn't already logged in we don't want the user to be able to make requests to either of these endpoints. So, what we can actually do is add another piece of middleware right above these two routes that will only apply to these two routes. And that's going to look like this. We're just going to say app dot use. And then we're going to say request response and next. And for the body of this we're going to say, if request dot user, right? In other words, if the user exists and has included the…
内容
-
-
-
-
-
-
-
Why Firebase Auth?1 分钟 17 秒
-
(已锁定)
Creating a Firebase project4 分钟 16 秒
-
(已锁定)
Adding Firebase Auth to React9 分钟 27 秒
-
(已锁定)
Build a login form11 分钟 56 秒
-
(已锁定)
Creating a custom auth hook8 分钟 52 秒
-
(已锁定)
Build a create-account page7 分钟 59 秒
-
(已锁定)
Adding Firebase Auth to Node.js6 分钟 25 秒
-
(已锁定)
Protecting endpoints using auth-tokens8 分钟 44 秒
-
(已锁定)
Protecting the upvote and comment endpoints4 分钟 47 秒
-
(已锁定)
Making requests with auth tokens6 分钟 41 秒
-
(已锁定)
Making interface adjustments for authenticated users6 分钟 34 秒
-
-
-