-
Notifications
You must be signed in to change notification settings - Fork 737
feat: 增加 egg-passport-local example #54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| 'use strict'; | ||
| module.exports = app => { | ||
| app.passport.verify(async (ctx, user) => { | ||
| user.photo = user.photo || 'https://zos.alipayobjects.com/rmsportal/JFKAMfmPehWfhBPdCjrw.svg'; | ||
| user.id = user.provider; | ||
| user.displayName = user.displayName || user.name; | ||
| return user; | ||
| }); | ||
| }; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,11 +3,14 @@ | |
| module.exports = app => { | ||
| app.router.get('/', 'home.render'); | ||
| app.router.get('/user', 'home.render'); | ||
| app.router.get('/login', 'home.local'); | ||
|
|
||
| app.passport.mount('weibo'); | ||
| app.passport.mount('github'); | ||
| app.passport.mount('bitbucket'); | ||
| app.passport.mount('twitter'); | ||
| const localStrategy = app.passport.authenticate('local'); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 想起来了,之前我
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 你的想法是不是这样:
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 嗯 |
||
| app.router.post('/passport/local', localStrategy); | ||
|
|
||
| app.router.get('/logout', 'user.logout'); | ||
| }; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| <!DOCTYPE html> | ||
| <html lang="en"> | ||
|
|
||
| <head> | ||
| <meta charset="UTF-8"> | ||
| <meta http-equiv="X-UA-Compatible" content="ie=edge"> | ||
| <title>egg-passport-local login page</title> | ||
| </head> | ||
|
|
||
| <body> | ||
| <h1>egg-passport-local login page</h1> | ||
| <form method="post" action="/passport/local"> | ||
| <div> | ||
| <label>Username:</label> | ||
| <input type="text" name="username" /> | ||
| </div> | ||
| <div> | ||
| <label>Password:</label> | ||
| <input type="password" name="password" /> | ||
| </div> | ||
| <div> | ||
| <input type="submit" value="Log In" /> | ||
| </div> | ||
| </form> | ||
| </body> | ||
|
|
||
| </html> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
不是,我的意思是,为什么你要把
user.id赋值为user.provider?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
搞错