Skip to content

Commit c9a7e03

Browse files
author
Nicolas Garnier
committed
Some code style polish
Change-Id: Id5615237bb3809d33145eaf0bbc8a1674dbe60a3
1 parent ed2d93a commit c9a7e03

File tree

3 files changed

+10
-14
lines changed

3 files changed

+10
-14
lines changed

url-shortener/functions/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ function createShortenerRequest(sourceUrl) {
3939
},
4040
json: true,
4141
resolveWithFullResponse: true
42-
}
42+
};
4343
}
4444

4545
function createShortenerPromise(snapshot) {

username-password-auth/functions/index.js

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,12 @@ const basicAuthRequest = require('request');
4343
* If an error occurs log the details and return a 500 response.
4444
*/
4545
exports.auth = functions.https.onRequest((req, res) => {
46-
4746
const handleError = (username, error) => {
4847
console.error({
4948
User: username
5049
}, error);
5150
return res.sendStatus(500);
52-
}
51+
};
5352

5453
const handleResponse = (username, status, body) => {
5554
console.log({
@@ -64,8 +63,7 @@ exports.auth = functions.https.onRequest((req, res) => {
6463
return res.status(200).json(body);
6564
}
6665
return res.sendStatus(status);
67-
}
68-
66+
};
6967

7068
let username = '';
7169
try {
@@ -115,15 +113,15 @@ function authenticate(username, password) {
115113
// (Only a password of `Testing123` will succeed)
116114
const authEndpoint = `https://httpbin.org/basic-auth/${username}/Testing123`;
117115
const creds = {
118-
'auth': {
119-
'user': username,
120-
'pass': password
116+
auth: {
117+
user: username,
118+
pass: password
121119
}
122-
}
120+
};
123121
return new Promise((resolve, reject) => {
124122
basicAuthRequest(authEndpoint, creds, (error, response, body) => {
125123
if (error) {
126-
return reject(error)
124+
return reject(error);
127125
}
128126
const statusCode = response ? response.statusCode : 0;
129127
if (statusCode === 401) { // Invalid username/password

username-password-auth/public/main.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,20 +66,18 @@ Demo.prototype.signIn = function() {
6666
req.onload = function() {
6767
if (req.status === 400 || req.status === 401) {
6868
err.innerText = 'Invalid username or password';
69-
return
69+
return;
7070
}
7171
if (req.status !== 200) {
7272
err.innerText = 'Invalid response from Firebase Cloud Function ' + req.status;
73-
return
73+
return;
7474
}
7575
var data = JSON.parse(req.responseText);
7676
if (data.token) {
7777
firebase.auth().signInWithCustomToken(data.token);
78-
return;
7978
} else {
8079
console.log('ERROR RESPONSE: ' + req.responseText);
8180
err.innerText = 'Invalid response from Firebase Cloud Function see developer console for details';
82-
return;
8381
}
8482
};
8583
req.onerror = function() {

0 commit comments

Comments
 (0)