Repository navigation
Expand file tree
/
Copy pathweb.js
More file actions
28 lines (27 loc) · 1.45 KB
/
Copy pathweb.js
File metadata and controls
28 lines (27 loc) · 1.45 KB
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
var http = require('http');
var urlparse = require('url').parse;
// simple page that acts as the OAuth endpoint
http.createServer(function(request, response) {
var url = urlparse(request.url, true);
if (url.path.startsWith('/jira') && url.query.oauth_verifier) {
response.writeHead(200, {'Content-Type': 'text/html'});
response.write('<html><head><title>Authentication successful | cabdriver</title></head>');
response.write('<body><h1>Successfully authenticated</h1>');
response.write('<p>Copy the following code back to the terminal for cabdriver: ');
response.write('<strong>' + url.query.oauth_verifier + '</strong></p>');
response.end('</body></html>');
return;
}
if (url.query.code) {
response.writeHead(200, {'Content-Type': 'text/html'});
response.write('<html><head><title>Authentication successful | cabdriver</title></head>');
response.write('<body><h1>Successfully authenticated</h1>');
response.write('<p>Copy the following code back to the terminal for cabdriver: ');
response.write('<strong>' + url.query.code + '</strong></p>');
response.end('</body></html>');
} else {
response.writeHead(401, {'Content-Type': 'text/html'});
response.write('<html><head><title>Authentication failed | cabdriver</title></head>');
response.end('<h1>401 Not Authorized</h1></body></html>');
}
}).listen(process.env.PORT || 5000);