Skip to content

Commit ad140f2

Browse files
authored
Merge pull request #7 from BUCOMPAdvancedDevelopment/master
Master Merging
2 parents e95247c + 40d3f84 commit ad140f2

File tree

5 files changed

+28
-102
lines changed

5 files changed

+28
-102
lines changed

main.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99

1010
#Enable running on local dev environment
1111
#Always comment lines 12 and 13 before running on the cloud, otherwise the app will NOT work
12-
os.environ.setdefault("GCLOUD_PROJECT", "ad-364515")
13-
os.environ["GOOGLE_APPLICATION_CREDENTIALS"] = (r"C:\Users\matth\Desktop\AdLocalCoursework\venv\application_default_credentials.json")
12+
# os.environ.setdefault("GCLOUD_PROJECT", "ad-364515")
13+
# os.environ["GOOGLE_APPLICATION_CREDENTIALS"] = (r"C:\Users\matth\Desktop\AdLocalCoursework\venv\application_default_credentials.json")
1414

1515
firebase_request_adapter = requests.Request()
1616

requirements.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Flask==2.0.1
1+
Flask==2.1.0
22
google-cloud-datastore==2.7.1
3-
google-auth==1.31.0
4-
requests==2.26.0
3+
google-auth==2.6.2
4+
requests==2.27.1

static/script.js

Lines changed: 0 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -1,72 +0,0 @@
1-
/**
2-
* Copyright 2018, Google LLC
3-
* Licensed under the Apache License, Version 2.0 (the `License`);
4-
* you may not use this file except in compliance with the License.
5-
* You may obtain a copy of the License at
6-
*
7-
* http://www.apache.org/licenses/LICENSE-2.0
8-
*
9-
* Unless required by applicable law or agreed to in writing, software
10-
* distributed under the License is distributed on an `AS IS` BASIS,
11-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12-
* See the License for the specific language governing permissions and
13-
* limitations under the License.
14-
*/
15-
16-
// [START gae_python38_log]
17-
'use strict';
18-
19-
window.addEventListener('load', function () {
20-
document.getElementById('sign-out').onclick = function () {
21-
firebase.auth().signOut();
22-
};
23-
24-
// FirebaseUI config.
25-
var uiConfig = {
26-
signInSuccessUrl: '/',
27-
signInOptions: [
28-
// Comment out any lines corresponding to providers you did not check in
29-
// the Firebase console.
30-
firebase.auth.GoogleAuthProvider.PROVIDER_ID,
31-
firebase.auth.EmailAuthProvider.PROVIDER_ID,
32-
//firebase.auth.FacebookAuthProvider.PROVIDER_ID,
33-
//firebase.auth.TwitterAuthProvider.PROVIDER_ID,
34-
//firebase.auth.GithubAuthProvider.PROVIDER_ID,
35-
//firebase.auth.PhoneAuthProvider.PROVIDER_ID
36-
37-
],
38-
// Terms of service url.
39-
tosUrl: '<your-tos-url>'
40-
};
41-
42-
firebase.auth().onAuthStateChanged(function (user) {
43-
if (user) {
44-
// User is signed in, so display the "sign out" button and login info.
45-
document.getElementById('sign-out').hidden = false;
46-
document.getElementById('login-info').hidden = false;
47-
console.log(`Signed in as ${user.displayName} (${user.email})`);
48-
user.getIdToken().then(function (token) {
49-
// Add the token to the browser's cookies. The server will then be
50-
// able to verify the token against the API.
51-
// SECURITY NOTE: As cookies can easily be modified, only put the
52-
// token (which is verified server-side) in a cookie; do not add other
53-
// user information.
54-
document.cookie = "token=" + token;
55-
});
56-
} else {
57-
// User is signed out.
58-
// Initialize the FirebaseUI Widget using Firebase.
59-
var ui = new firebaseui.auth.AuthUI(firebase.auth());
60-
// Show the Firebase login button.
61-
ui.start('#firebaseui-auth-container', uiConfig);
62-
// Update the login state indicators.
63-
document.getElementById('sign-out').hidden = true;
64-
document.getElementById('login-info').hidden = true;
65-
// Clear the token cookie.
66-
document.cookie = "token=";
67-
}
68-
}, function (error) {
69-
console.log(error);
70-
alert('Unable to log in: ' + error)
71-
});
72-
});

templates/base.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@
8181
if (user) {
8282
document.getElementById("sign-out").style.display="block";
8383
console.log(`Signed in as ${user.displayName} (${user.email})`);
84-
document.getElementById("account-name").innerHTML = user.displayName;
84+
document.getElementById("account-name").innerHTML = user.displayName
8585
user.getIdToken().then(function (token) {
8686
// Add the token to the browser's cookies. The server will then be
8787
// able to verify the token against the API.

templates/index.html

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
<!-- [END gae_python3_auth_include_firebaseui] -->
3333
<!-- [END gae_python38_auth_include_firebaseui] -->
3434
<link type="text/css" rel="stylesheet" href="{{ url_for('static', filename='index.css') }}">
35+
<!-- <link type="text/css" rel="stylesheet" href="{{ url_for('static', filename='script.js') }}"> -->
3536

3637
</head>
3738
<body>
@@ -84,39 +85,36 @@ <h2>Login info:</h2>
8485
// Initialize Firebase
8586
firebase.initializeApp(firebaseConfig);
8687

87-
// Initialize the FirebaseUI Widget using Firebase.
88-
var ui = new firebaseui.auth.AuthUI(firebase.auth());
89-
9088
var uiConfig = {
9189
signInSuccessUrl: '/home',
9290
signInOptions: [
9391
firebase.auth.EmailAuthProvider.PROVIDER_ID,
9492
firebase.auth.GoogleAuthProvider.PROVIDER_ID,
9593
firebase.auth.GithubAuthProvider.PROVIDER_ID,
96-
],
94+
],
9795
};
98-
9996
firebase.auth().onAuthStateChanged(function(user) {
10097
if (user) {
101-
// Show user signed in screen. Reset if user just signed in. (Single page app)
102-
ui.reset();
103-
document.getElementById('login-info').style.display = 'block';
104-
document.getElementById('sign-out').style.display = 'block';
105-
console.log(`Signed in as ${user.displayName} (${user.email})`);
106-
user.getIdToken().then(function (token) {
107-
// Add the token to the browser's cookies. The server will then be
108-
// able to verify the token against the API.
109-
// SECURITY NOTE: As cookies can easily be modified, only put the
110-
// token (which is verified server-side) in a cookie; do not add other
111-
// user information.
112-
document.cookie = "token=" + token;
113-
});
98+
// Show user signed in screen. Reset if user just signed in. (Single page app)
99+
document.getElementById('login-info').style.display = 'block';
100+
document.getElementById('sign-out').style.display = 'block';
101+
console.log(`Signed in as ${user.displayName} (${user.email})`);
102+
user.getIdToken().then(function (token) {
103+
// Add the token to the browser's cookies. The server will then be
104+
// able to verify the token against the API.
105+
// SECURITY NOTE: As cookies can easily be modified, only put the
106+
// token (which is verified server-side) in a cookie; do not add other
107+
// user information.
108+
document.cookie = "token=" + token;
109+
});
114110
} else {
115-
// No user signed in, render sign-in UI.
116-
ui.start('#firebaseui-auth-container', uiConfig);
117-
document.getElementById('login-info').style.display = 'none';
118-
document.getElementById('sign-out').style.display = 'none';
119-
}
120-
});
111+
// Initialize the FirebaseUI Widget using Firebase.
112+
var ui = new firebaseui.auth.AuthUI(firebase.auth());
113+
// No user signed in, render sign-in UI.
114+
ui.start('#firebaseui-auth-container', uiConfig);
115+
document.getElementById('login-info').style.display = 'none';
116+
document.getElementById('sign-out').style.display = 'none';
117+
}
118+
});
121119
</script>
122120
</html>

0 commit comments

Comments
 (0)