私信 访问主页
weixin_39959369 2021-01-08 17:17 首页 开源项目 docs: migrate loopback-example-passport repo as lb4 examplesatisfies: https://github.com/strongloop/loopback-next/issues/2624
Test steps** This example repo would need manual test
preconditions: create a test app and test user in facebook, and make sure to give email permission to test user. (emonddr : visit https://developers.facebook.com to do this.)preconditions: Copy test app s client id and secret and update those in the examples/passport-poauth2-login/authentication-strategies/oauth2-strategy.ts
Run npm i from loopback-next root folder, to create symlinks with master packages
cd examples/passport-oauth2-login npm startopen browser - http://localhost:3000 (emonddr : Open a new window in Incognito mode, otherwise may not work)click login - login with facebook page redirects to facebook, enter test user credentialsif authentication was successful, page redirects to login profiles page and shows linked facebook account details along with access tokenChecklistRead and sign the CLA (Contributor License Agreement)
[x] npm test passes on your machine[x] New tests added or existing tests modified to cover all changes[x] Code conforms with the style guide[ ] API Documentation in code was updated[ ] Documentation in /docs/site was updated[ ] Affected artifact templates in packages/cli were updated[ ] Affected example projects in examples/* were updatedCheck out how to submit a PR
该提问来源于开源项目 strongloop/loopback-next
点赞 写回答 收藏 复制链接分享 删除 再等等 结题 再想想 19条回答私信 访问主页
weixin_39959369 2月前Great effort!!! a few questions suggestions(commented with details):
the method in the ping controller looks good in general, but it s better to have it in the existing user controller and transfer the method to /whoAmI or /merenaming UserIdentity?maybe more explanation about the the app/server structuredata in db.jsonI need more time to review each file in details but other than questions above I don t see obvious problem.
Hey thanks for the review,
I have added endpoint /whoAmI to print the current user , as per your suggestionUserIdentity is a term borrowed from the original loopback-component-passport , since this is a migration story, may be better to have it for now.The server structure is Express Composition , we already have examples in detail for itThe user credentials are created only for locally signed up users. This is also borrowed from the loopback-component-passport. We can change that after completing this migration story. 点赞 评论 复制链接分享私信 访问主页
weixin_39753616 2月前, I don t see belongsTo decorator in UserIdentity or UserCredential but User has and respectively. Also in latest commit, if you are using rest-crud to create user endpoints, I don t think it handles relations at the moment. , I saw this in your blog. Can you confirm? thx. , can you chime in on this as well? In a hasMany or hasOne, there must be a belongsTo on the other side of the relation right? is not optional, correct?
Also, perhaps rename : examples/passport-login/src/controllers/user.controller.ts to user-signup-login.controller.ts since user.controller.ts is usually created for a user model for all its endpoints.
Hi , so I spoke with . So it turns out you were correct. You don t need the belongsTo in UserCredential and UserIdentity if you don t plan on navigating from any of these back to the original User. If you only need to navigate from User to UserIdentity or User to UserCredentials, then you only need the hasMany and hasOne. If you need to navigate from parent to child and child to parent, then you need to use hasMany and belongsTo, or hasOne and belongsTo.
If you define this bi-directional navigation, even if you don t use it, it is fine, it doesn t break anything. And for me, personally, it gives me a nice fuzzy feeling to define both to help clearly define their relationship.
私信 访问主页
weixin_39753616 2月前, thanks for addressing my comments yesterday. We re almost there.
点赞 评论 复制链接分享私信 访问主页
weixin_39753616 2月前, I don t see belongsTo decorator in UserIdentity or UserCredential but User has and respectively. Also in latest commit, if you are using rest-crud to create user endpoints, I don t think it handles relations at the moment. , I saw this in your blog. Can you confirm? thx. , can you chime in on this as well? In a hasMany or hasOne, there must be a belongsTo on the other side of the relation right? is not optional, correct?
Also, perhaps rename : examples/passport-login/src/controllers/user.controller.ts to user-signup-login.controller.ts since user.controller.ts is usually created for a user model for all its endpoints.
点赞 评论 复制链接分享私信 访问主页
weixin_39959369 2月前Regarding
preconditions: create a test app and test user in facebook, and make sure to give email permission to test user
This is actually quite confusing for someone who has never gone here. I have, but never set up a user. So a detailed step by step description of what to do including links would be helpful.
I have added details on facebook login in the README.md now.
点赞 评论 复制链接分享私信 访问主页
weixin_39959369 2月前Clicking on the [Server Status] link on the website,
I get an error
Clicking Logout I get this:
The Server status was a OOTB functionality in lb3. I have removed that link now. Logout had an error, I have fixed that now.
点赞 评论 复制链接分享私信 访问主页
weixin_39959369 2月前If I click on Sign Up,and specify my data (not associated with social media)dom emonddom.cometc
I get redirected to /loginand I am able to login
Like above [View Account] has no info about me.
When I try to Log out
I get an error
the logout function is fixed now . I have also added acceptance test cases for these scenarios.
点赞 评论 复制链接分享私信 访问主页
weixin_39959369 2月前I like the UI, by the way
I was thinking we should only show certain menu options when they are applicable.e.g. Let s not show Logout until someone is actually logged inLet s not show Sign Up, Sign Up Options, Login when someone is logged in
agree that the menu is very naive, but I just copied most of the UI templates from https://github.com/strongloop/loopback-example-passport
点赞 评论 复制链接分享私信 访问主页
weixin_39959369 2月前And for some reason, my db.json ends up with many test users
models : { User : { 3 : {\\ name\\ :\\ Test User\\ ,\\ username\\ :\\ test.com\\ ,\\ email\\ :\\ test.com\\ ,\\ id\\ :3} , 4 : {\\ name\\ :\\ Test User\\ ,\\ username\\ :\\ test.com\\ ,\\ email\\ :\\ test.com\\ ,\\ id\\ :4} , 5 : {\\ name\\ :\\ Test User\\ ,\\ username\\ :\\ test.com\\ ,\\ email\\ :\\ test.com\\ ,\\ id\\ :5} , 6 : {\\ name\\ :\\ Test User\\ ,\\ username\\ :\\ test.com\\ ,\\ email\\ :\\ test.com\\ ,\\ id\\ :6} , 7 : {\\ name\\ :\\ Test User\\ ,\\ username\\ :\\ test.com\\ ,\\ email\\ :\\ test.com\\ ,\\ id\\ :7} ,
I have restarted several times. I this done on startup?I ve never used this user.
thanks for testing this. I have fixed this now.
点赞 评论 复制链接分享私信 访问主页
weixin_39753616 2月前, please see my comments from 4 to 5 days ago. Thanks.
点赞 评论 复制链接分享私信 访问主页
weixin_39753616 2月前And for some reason, my db.json ends up with many test users
models : { User : { 3 : {\\ name\\ :\\ Test User\\ ,\\ username\\ :\\ test.com\\ ,\\ email\\ :\\ test.com\\ ,\\ id\\ :3} , 4 : {\\ name\\ :\\ Test User\\ ,\\ username\\ :\\ test.com\\ ,\\ email\\ :\\ test.com\\ ,\\ id\\ :4} , 5 : {\\ name\\ :\\ Test User\\ ,\\ username\\ :\\ test.com\\ ,\\ email\\ :\\ test.com\\ ,\\ id\\ :5} , 6 : {\\ name\\ :\\ Test User\\ ,\\ username\\ :\\ test.com\\ ,\\ email\\ :\\ test.com\\ ,\\ id\\ :6} , 7 : {\\ name\\ :\\ Test User\\ ,\\ username\\ :\\ test.com\\ ,\\ email\\ :\\ test.com\\ ,\\ id\\ :7} ,
I have restarted several times. I this done on startup?I ve never used this user.
点赞 评论 复制链接分享私信 访问主页
weixin_39753616 2月前I like the UI, by the way
I was thinking we should only show certain menu options when they are applicable.e.g. Let s not show Logout until someone is actually logged in Let s not show Sign Up, Sign Up Options, Login when someone is logged in
点赞 评论 复制链接分享私信 访问主页
weixin_39753616 2月前If I click on Sign Up,and specify my data (not associated with social media)dom emonddom.cometc
I get redirected to /loginand I am able to login
Like above [View Account] has no info about me.
When I try to Log out
I get an error
点赞 评论 复制链接分享私信 访问主页
weixin_39753616 2月前Clicking on the [Server Status] link on the website,
I get an error
Clicking Logout I get this:
点赞 评论 复制链接分享私信 访问主页
weixin_39753616 2月前I signed up by going to Sign Up Options Facebook, and was able to see data on View Account.Then I logged out.Then I went to Log In and logged in successfully .The browser goes to View Account and I don t see any profile or user info:
If I got to Sign up, I am shown that I am indeedlogged in
Same thing if I click on Login .It shows that I am currently logged in.
点赞 评论 复制链接分享私信 访问主页
weixin_39753616 2月前open browser - http://localhost:3000
Didn t work for me. I got
I had to open a new window in Incognito mode for Chrome.
点赞 评论 复制链接分享私信 访问主页
weixin_39753616 2月前Regarding
preconditions: create a test app and test user in facebook, and make sure to give email permission to test user
This is actually quite confusing for someone who has never gone here. I have, but never set up a user. So a detailed step by step description of what to do including links would be helpful.
点赞 评论 复制链接分享私信 访问主页
weixin_39753616 2月前, please provide a readme.md file with instructions on how to run this example.I automatically ran npm start and the server says it is running on 3000 but I couldn t visit the url.Also npm run test fails to run
․․․!!!! 3 passing (436ms) 4 failing 1) example-passport-login acceptance test login options sign up via social app call to authorization url is redirected to oauth providers login page: Error: ECONNREFUSED: Connection refused at Test.assert (/Users/dremond/Documents/PRs_LoopBack/deepak_oauth2/loopback-next/packages/testlab/node_modules/supertest/lib/test.js:165:15) at localAssert (/Users/dremond/Documents/PRs_LoopBack/deepak_oauth2/loopback-next/packages/testlab/node_modules/supertest/lib/test.js:131:12) at /Users/dremond/Documents/PRs_LoopBack/deepak_oauth2/loopback-next/packages/testlab/node_modules/supertest/lib/test.js:128:5 at Test.Request.callback (/Users/dremond/Documents/PRs_LoopBack/deepak_oauth2/loopback-next/packages/testlab/node_modules/superagent/lib/node/index.js:728:3) at ClientRequest. anonymous (/Users/dremond/Documents/PRs_LoopBack/deepak_oauth2/loopback-next/packages/testlab/node_modules/superagent/lib/node/index.js:647:10) at Socket.socketErrorListener (_http_client.js:415:9) at emitErrorNT (internal/streams/destroy.js:92:8) at emitErrorAndCloseNT (internal/streams/destroy.js:60:3) at processTicksAndRejections (internal/process/task_queues.js:81:21) 2) example-passport-login acceptance test login options sign up via social app login page redirects to authorization app callback endpoint: Error: ECONNREFUSED: Connection refused at Test.assert (/Users/dremond/Documents/PRs_LoopBack/deepak_oauth2/loopback-next/packages/testlab/node_modules/supertest/lib/test.js:165:15) at localAssert (/Users/dremond/Documents/PRs_LoopBack/deepak_oauth2/loopback-next/packages/testlab/node_modules/supertest/lib/test.js:131:12) at /Users/dremond/Documents/PRs_LoopBack/deepak_oauth2/loopback-next/packages/testlab/node_modules/supertest/lib/test.js:128:5 at Test.Request.callback (/Users/dremond/Documents/PRs_LoopBack/deepak_oauth2/loopback-next/packages/testlab/node_modules/superagent/lib/node/index.js:728:3) at ClientRequest. anonymous (/Users/dremond/Documents/PRs_LoopBack/deepak_oauth2/loopback-next/packages/testlab/node_modules/superagent/lib/node/index.js:647:10) at Socket.socketErrorListener (_http_client.js:415:9) at emitErrorNT (internal/streams/destroy.js:92:8) at emitErrorAndCloseNT (internal/streams/destroy.js:60:3) at processTicksAndRejections (internal/process/task_queues.js:81:21) 3) example-passport-login acceptance test login options sign up via social app callback url contains access code: TypeError [ERR_INVALID_ARG_TYPE]: The url argument must be of type string. Received type undefined at validateString (internal/validators.js:112:11) at Url.parse (url.js:155:3) at Object.urlParse [as parse] (url.js:150:13) at Context. anonymous (src/__tests__/acceptance/passport-login.acceptance.ts:108:20) at processImmediate (internal/timers.js:439:21) 4) example-passport-login acceptance test login options sign up via social app access code can be exchanged for token: TypeError [ERR_INVALID_ARG_TYPE]: The url argument must be of type string. Received type undefined at validateString (internal/validators.js:112:11) at Url.parse (url.js:155:3) at Object.urlParse [as parse] (url.js:150:13) at Context. anonymous (src/__tests__/acceptance/passport-login.acceptance.ts:112:34) at processImmediate (internal/timers.js:439:21)
本文链接: http://dremond.immuno-online.com/view-748052.html