课程: React: Authentication

今天就学习课程吧!

今天就开通帐号,24,700 门业界名师课程任您挑!

Handling successful OAuth authentication

Handling successful OAuth authentication - React.js教程

课程: React: Authentication

Handling successful OAuth authentication

- Okay. So the last step here now is to set up the page that we're redirecting our user back to in this callback route, after we've logged them in and stored their data. So remember that what we're doing is basically redirecting them back to the login page but including a token query parameter that contains the user's info. So what we're going to do now is modify our login page so that it detects if this token query parameter has been provided. And if it has been, then basically it'll just set that in local storage and redirect the user to the user info page. So here's what that's going to look like. Let's open up our login page on our front end and we're going to just add a use effect hook up here that will basically check to see if there's a token in the query parameters and if there is do what we want it to do, right? Set that in local storage and send the user to the user info page. So here's what that's going to…

内容