|
1 | 1 | import passport from 'passport'
|
2 |
| -import { API_CONFIG, SLACK_CONFIG, TWITTER_CONFIG } from '../../conf' |
| 2 | +import { API_CONFIG, SLACK_CONFIG } from '../../conf' |
| 3 | +import SegmentRepository from '../../database/repositories/segmentRepository' |
3 | 4 | import { authMiddleware } from '../../middlewares/authMiddleware'
|
4 |
| -import TenantService from '../../services/tenantService' |
5 | 5 | import { safeWrap } from '../../middlewares/errorMiddleware'
|
6 |
| -import SegmentRepository from '../../database/repositories/segmentRepository' |
| 6 | +import TenantService from '../../services/tenantService' |
7 | 7 |
|
8 | 8 | export default (app) => {
|
9 | 9 | app.post(`/tenant/:tenantId/integration/query`, safeWrap(require('./integrationQuery').default))
|
@@ -76,60 +76,60 @@ export default (app) => {
|
76 | 76 | safeWrap(require('./helpers/discourseTestWebhook').default),
|
77 | 77 | )
|
78 | 78 |
|
79 |
| - if (TWITTER_CONFIG.clientId) { |
80 |
| - /** |
81 |
| - * Using the passport.authenticate this endpoint forces a |
82 |
| - * redirect to happen to the twitter oauth2 page. |
83 |
| - * We keep a state of the important variables such as tenantId, redirectUrl, .. |
84 |
| - * so that after user logs in through the twitter page, these |
85 |
| - * variables are forwarded back to the callback as well |
86 |
| - * This state is sent using the authenticator options and |
87 |
| - * manipulated through twitterStrategy.staticPKCEStore |
88 |
| - */ |
89 |
| - app.get( |
90 |
| - '/twitter/:tenantId/connect', |
91 |
| - safeWrap(require('./helpers/twitterAuthenticate').default), |
92 |
| - () => { |
93 |
| - // The request will be redirected for authentication, so this |
94 |
| - // function will not be called. |
95 |
| - }, |
96 |
| - ) |
| 79 | + // if (TWITTER_CONFIG.clientId) { |
| 80 | + // /** |
| 81 | + // * Using the passport.authenticate this endpoint forces a |
| 82 | + // * redirect to happen to the twitter oauth2 page. |
| 83 | + // * We keep a state of the important variables such as tenantId, redirectUrl, .. |
| 84 | + // * so that after user logs in through the twitter page, these |
| 85 | + // * variables are forwarded back to the callback as well |
| 86 | + // * This state is sent using the authenticator options and |
| 87 | + // * manipulated through twitterStrategy.staticPKCEStore |
| 88 | + // */ |
| 89 | + // app.get( |
| 90 | + // '/twitter/:tenantId/connect', |
| 91 | + // safeWrap(require('./helpers/twitterAuthenticate').default), |
| 92 | + // () => { |
| 93 | + // // The request will be redirected for authentication, so this |
| 94 | + // // function will not be called. |
| 95 | + // }, |
| 96 | + // ) |
97 | 97 |
|
98 |
| - /** |
99 |
| - * OAuth2 callback endpoint. After user successfully |
100 |
| - * logs in through twitter page s/he is redirected to |
101 |
| - * this endpoint. Few middlewares first mimic a proper |
102 |
| - * api request in this order: |
103 |
| - * |
104 |
| - * Set headers-> Auth middleware (currentUser)-> Set currentTenant |
105 |
| - * -> finally we call the project service to update the |
106 |
| - * corresponding project. |
107 |
| - * |
108 |
| - * We have to call these standart middlewares explicitly because |
109 |
| - * the request method is get and tenant id does not exist in the |
110 |
| - * uri as request parameters. |
111 |
| - * |
112 |
| - */ |
113 |
| - app.get( |
114 |
| - '/twitter/callback', |
115 |
| - passport.authenticate('twitter', { |
116 |
| - session: false, |
117 |
| - failureRedirect: `${API_CONFIG.frontendUrl}/integrations?error=true`, |
118 |
| - }), |
119 |
| - (req, _res, next) => { |
120 |
| - const crowdToken = new URLSearchParams(req.query.state).get('crowdToken') |
121 |
| - req.headers.authorization = `Bearer ${crowdToken}` |
122 |
| - next() |
123 |
| - }, |
124 |
| - authMiddleware, |
125 |
| - async (req, _res, next) => { |
126 |
| - const tenantId = new URLSearchParams(req.query.state).get('tenantId') |
127 |
| - req.currentTenant = await new TenantService(req).findById(tenantId) |
128 |
| - next() |
129 |
| - }, |
130 |
| - safeWrap(require('./helpers/twitterAuthenticateCallback').default), |
131 |
| - ) |
132 |
| - } |
| 98 | + // /** |
| 99 | + // * OAuth2 callback endpoint. After user successfully |
| 100 | + // * logs in through twitter page s/he is redirected to |
| 101 | + // * this endpoint. Few middlewares first mimic a proper |
| 102 | + // * api request in this order: |
| 103 | + // * |
| 104 | + // * Set headers-> Auth middleware (currentUser)-> Set currentTenant |
| 105 | + // * -> finally we call the project service to update the |
| 106 | + // * corresponding project. |
| 107 | + // * |
| 108 | + // * We have to call these standart middlewares explicitly because |
| 109 | + // * the request method is get and tenant id does not exist in the |
| 110 | + // * uri as request parameters. |
| 111 | + // * |
| 112 | + // */ |
| 113 | + // app.get( |
| 114 | + // '/twitter/callback', |
| 115 | + // passport.authenticate('twitter', { |
| 116 | + // session: false, |
| 117 | + // failureRedirect: `${API_CONFIG.frontendUrl}/integrations?error=true`, |
| 118 | + // }), |
| 119 | + // (req, _res, next) => { |
| 120 | + // const crowdToken = new URLSearchParams(req.query.state).get('crowdToken') |
| 121 | + // req.headers.authorization = `Bearer ${crowdToken}` |
| 122 | + // next() |
| 123 | + // }, |
| 124 | + // authMiddleware, |
| 125 | + // async (req, _res, next) => { |
| 126 | + // const tenantId = new URLSearchParams(req.query.state).get('tenantId') |
| 127 | + // req.currentTenant = await new TenantService(req).findById(tenantId) |
| 128 | + // next() |
| 129 | + // }, |
| 130 | + // safeWrap(require('./helpers/twitterAuthenticateCallback').default), |
| 131 | + // ) |
| 132 | + // } |
133 | 133 |
|
134 | 134 | /**
|
135 | 135 | * Slack integration endpoints
|
|
0 commit comments