我想在验证用户时使用以下用例。
如果用户位于路径/个人资料中并且未经过身份验证,那么他必须登录并且一旦登录,他将被重定向回/ profile。
如果用户位于路径/ home并且未经过身份验证,那么他必须签名并进行身份验证后,重新定向回/ home
到目前为止,我已成功完成这些步骤:
1. user authenticates through linkedin
2. user receives authorization code which is then sent to the node server
3. the node server exchanges the auth code for access token and
makes linkedin api calls on behalf of the user
4. the node server retrieves user information, creates a json
web token and then sends it back to the user
我的问题是,我不确定如何处理角度的动态重定位网址。因为我们失去了国家。而且我不想要弹出式身份验证。 当我将redirect_uri设置为" http://localhost:3000"时,它会将授权代码附加到网址,然后服务器获取此信息并发回访问令牌。
我的想法
我将设置一个特定的重定向uri,并将以角度为该URL创建一个控制器。在该控制器中,我将发送一个http请求来交换授权代码和访问令牌。服务器将发回访问令牌和linkedin用户信息,我将存储在localStorage中。经过身份验证后,我会对正确的重定向网址执行$ state.go。我怎么知道在哪里发送用户?我的想法是存储用户在本地存储中访问的初始URL。因此,如果用户访问/配置文件并且未经过身份验证,那么我将在本地存储中存储/配置文件,然后当我点击回调URL时,我将检查localstorage以获取另一个重定向URL并将用户发送到那里。
如果不清楚,请告诉我,我很乐意解释。我想知道这是否有任何缺陷。