1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
|
23,24d22
< const axios = require('axios').default
< const Path = require('path')
195c193
< logger.debug({ email }, 'too many login requests')
---
> logger.log({ email }, 'too many login requests')
227c225
< logger.debug({ email }, 'failed log in')
---
> logger.log({ email }, 'failed log in')
298,364d295
< oauth2Redirect(req, res, next) {
< res.redirect(`${process.env.OAUTH_AUTH_URL}?` +
< querystring.stringify({
< client_id: process.env.OAUTH_CLIENT_ID,
< response_type: "code",
< redirect_uri: (process.env.SHARELATEX_SITE_URL + "/oauth/callback"),
< }));
< },
<
< oauth2Callback(req, res, next) {
< const code = req.query.code;
<
< //construct axios body
< const params = new URLSearchParams()
< params.append('grant_type', "authorization_code")
< params.append('client_id', process.env.OAUTH_CLIENT_ID)
< params.append('client_secret', process.env.OAUTH_CLIENT_SECRET)
< params.append("code", code)
< params.append('redirect_uri', (process.env.SHARELATEX_SITE_URL + "/oauth/callback"))
<
<
< // json_body = {
< // "grant_type": "authorization_code",
< // client_id: process.env.OAUTH_CLIENT_ID,
< // client_secret: process.env.OAUTH_CLIENT_SECRET,
< // "code": code,
< // redirect_uri: (process.env.SHARELATEX_SITE_URL + "/oauth/callback"),
< // }
<
< axios.post(process.env.OAUTH_ACCESS_URL, params, {
< headers: {
< "Content-Type": "application/x-www-form-urlencoded",
<
< }
< }).then(access_res => {
<
< // console.log("respond is " + JSON.stringify(access_res.data))
< // console.log("authorization_bearer_is " + authorization_bearer)
< authorization_bearer = "Bearer " + access_res.data.access_token
<
< let axios_get_config = {
< headers: {
< "Content-Type": "application/x-www-form-urlencoded",
< "Authorization": authorization_bearer,
< },
< params: access_res.data
< }
<
< axios.get(process.env.OAUTH_USER_URL, axios_get_config).then(info_res => {
< // console.log("oauth_user: ", JSON.stringify(info_res.data));
< if (info_res.data.err) {
< res.json({message: info_res.data.err});
< } else {
< AuthenticationManager.createUserIfNotExist(info_res.data, (error, user) => {
< if (error) {
< res.json({message: error});
< } else {
< // console.log("real_user: ", user);
< AuthenticationController.finishLogin(user, req, res, next);
< }
< });
< }
< });
< });
< },
<
<
444c375
< logger.debug(
---
> logger.log(
477c408
< email,
---
> email: email,
547c478
< logger.debug(
---
> logger.log(
558c489
< logger.debug(
---
> logger.log(
568c499
< logger.debug(
---
> logger.log(
689c620
< logger.debug(
---
> logger.log(
|