forked from FalakChhikara/IITG-EduPortal
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunctions.py
35 lines (30 loc) · 993 Bytes
/
functions.py
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
import pyrebase
config = {
"apiKey": "AIzaSyAEue4ktaLv-1wqKQgtgkfWJ1Oj6NNW-8U",
"authDomain": "e-learning-ccbd8.firebaseapp.com",
"databaseURL": "https://e-learning-ccbd8.firebaseio.com",
"projectId": "e-learning-ccbd8",
"storageBucket": "e-learning-ccbd8.appspot.com",
"messagingSenderId": "1053587965345",
"appId": "1:1053587965345:web:b97bb311c911183b0d77e0",
"measurementId": "G-K1YGG2H5VQ"
}
firebase = pyrebase.initialize_app(config)
authe = firebase.auth()
database = firebase.database()
def currentUser(request):
try:
idtoken = request.session['uid']
info = authe.get_account_info(idtoken)
users = info['users']
user = users[0]
localid = user['localId']
user1 = database.child("users").child(localid).get().val()
return user1
except:
return None
def user_authenticated(request):
if(currentUser(request) is None):
return False
else:
return True