Guest User

Untitled

a guest
Sep 13th, 2018
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.64 KB | None | 0 0
  1. passport.use(
  2. new Strategy(
  3. {
  4. clientID: '<clientID>',
  5. clientSecret: '<ClientSecret>',
  6. callbackURL: 'http://myapp/authenticated'
  7. },
  8. (accessToken, refreshToken, profile, cb) => {
  9. return cb(null, profile);
  10. }
  11. )
  12. );
  13.  
  14. this.config.app.get(
  15. '/login',
  16. passport.authenticate('github', {
  17. scope: [
  18. 'user',
  19. 'notifications',
  20. 'gist',
  21. 'repo',
  22. 'admin:org',
  23. 'admin:public_key',
  24. 'admin:repo_hook',
  25. 'admin:org_hook'
  26. ]
  27. })
  28. );
  29.  
  30. this.config.app.get(
  31. '/authenticated',
  32. passport.authenticate('github', {
  33. successRedirect: '/home',
  34. failureRedirect: '/signin',
  35.  
  36. session: false
  37. }),
  38. (req, res) => {
  39. res.redirect('/home');
  40. }
  41. );
  42. }
  43.  
  44. public async login(username: string, password: string) {
  45. const httpOptions = {
  46. headers: new HttpHeaders({
  47. 'Content-Type': 'application/json'
  48. })
  49. };
  50.  
  51. const result = await this.http
  52. .get<any>('/login', httpOptions)
  53. .toPromise();
  54.  
  55. 404 https://github.com/login/oauth/authorize?response_type=code&redirect....
  56.  
  57. Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://myapp' is therefore not allowed access.
  58.  
  59. public async login(username: string, password: string) {
  60. window.open('/login', '_self');
Add Comment
Please, Sign In to add comment