def signuppost(request): passw = request.POST.get('pass') email = request.POST.get('email') fullName = request.POST.get('name') age = request.POST.get('age') birthdate = request.POST.get('birthdate') address = request.POST.get('address') gender = request.POST.get('gender') specialization = request.POST.get('specialization') profID = request.POST.get('profID') cntact = request.POST.get('cntact') config = { 'apiKey': "AIzaSyCNm1eyfviO7lxJi2N0QBQf0JXeVOqk4m0", 'authDomain': "testapp-11158.firebaseapp.com", 'databaseURL': "https://testapp-11158.firebaseio.com", 'projectId': "testapp-11158", 'storageBucket': "testapp-11158.appspot.com", 'messagingSenderId': "714865109715" } firebase = pyrebase.initialize_app(config) auth = firebase.auth() user = auth.create_user_with_email_and_password(email, passw) print(user) auth.send_email_verification(user['idToken']) uid = user['localId'] data = { "name": fullName, "email": email, "age": age, "birthdate": birthdate, "address": address, "gender": gender, "specialization": specialization, "profID": profID, "contactNum": cntact } database.child("user").child("doctor").child(uid).child("details").set( data) #============testing code starts here==================# user = authe.sign_in_with_email_and_password(email, passw) uid = user['localId'] request.session['fav_color'] = str(uid) #all_users = database.child("Daily_Report").child(uid).child("details").get() #d = all_users.val() #print ("date here is:"+str(d)) #d = " "+str(d['name']) global name name = "<b>" + str("Hello," + str(fullName)) + "</b>" message = "Account Created Successfully" return render(request, 'home.html', {'name': name, 'message': message})
def Email(request): global user auth.send_email_verification(user['idToken']) return render(request, 'Email.html')
def signUp(request): global uid if request.method == 'POST': name = request.POST.get('name') email = request.POST.get('email') passw = request.POST.get('pass') conf_passw = request.POST.get('conf_pass') phone = request.POST.get('phone') college = request.POST.get('college') city = request.POST.get('city') print(passw) print(conf_passw) if passw != conf_passw: message = "Password does not match" return render(request, 'signUp.html', {"message": message}) elif len(passw) < 6: message = "Password Should be min 6 charachters long" return render(request, 'signUp.html', {"message": message}) else: emailDB = database.child("users").get() for i in emailDB.each(): temp2 = i.val() if email == temp2['email']: message = "Email Already Exists" return render(request, 'signUp.html', {"message": message}) if "@goa.bits-pilani.ac.in" in email: user = auth.create_user_with_email_and_password(email, passw) uid = user['localId'] data = { 'name': name, 'email': email, 'phone': phone, 'college': college, 'city': city, 'accBal': DEFAULT_BAL, 'rank': 0, 'user_verify': "Yes", 'userVal': DEFAULT_BAL } database.child("users").child(uid).set(data) auth.send_email_verification(user['idToken']) return render(request, "signIn.html") else: phnum = database.child("users").get() for i in phnum.each(): temp = i.val() if phone == temp['phone']: message = "Phone Number Already Exists" return render(request, 'signUp.html', {"message": message}) user = auth.create_user_with_email_and_password(email, passw) uid = user['localId'] data = { 'name': name, 'email': email, 'phone': phone, 'college': college, 'city': city, 'accBal': DEFAULT_BAL, 'rank': 0, 'user_verify': "No", 'userVal': DEFAULT_BAL } database.child("users").child(uid).set(data) auth.send_email_verification(user['idToken']) return render(request, "verification.html") message = "could not create account" return render(request, 'signUp.html', {"message": message}) return render(request, "signUp.html")
def Register(request): ## signuppost famName = request.POST.get('famName') firstName = request.POST.get('firstName') gender = request.POST.get("gender") birthdate = request.POST.get("birthdate") email = request.POST.get('email') passw = request.POST.get('password') conf_pass = request.POST.get('conf_password') address = request.POST.get("address") num = '+63' + str(request.POST.get("mobileNum")) MS = request.POST.getlist('MS') lNum = request.POST.get("lNum") fullname = {'lastName': famName, 'firstname': firstName} ###Firebase init ### somewhat needed kay mu email address already registered siya if wala config = { 'apiKey': "AIzaSyCwy2DSVWgniTi2PRbHlDKvF58dzE5LhmY", 'authDomain': "thesisbpms-af272.firebaseapp.com", 'databaseURL': "https://thesisbpms-af272.firebaseio.com", 'projectId': "thesisbpms-af272", 'storageBucket': "thesisbpms-af272.appspot.com", 'messagingSenderId': "789763107091" } firebase = pyrebase.initialize_app(config) auth = firebase.auth() ### validation of password if (passw != conf_pass): ErrorMsg = "Passwords do not match" return render(request, "register.html", {'m': ErrorMsg}) ### verification of licenseNum checklicnum = db.child("users").child("doctor").shallow().get().val() if checklicnum is None: try: user = auth.create_user_with_email_and_password(email, passw) except: ErrorMsg = "Email Address Already Registered" return render(request, "register.html", {'m': ErrorMsg}) print(user) uid = user['localId'] tok = user['idToken'] users_ref = db.child("users").child("doctor").child(uid) sendemail = auth.send_email_verification(tok) users_ref.set({ 'email': email, 'fullname': fullname, 'address': address, 'gender': gender, 'contactNo': num, 'birthDate': birthdate, 'medicalSpecialization': MS, 'LicenseNum': lNum, 'status': "1", }) SuccessMsg = "Account Created Successfully" HttpResponse(SuccessMsg) return render(request, "verify.html", {"e": email, 'm': SuccessMsg}) else: lis = [] for x in checklicnum: j = db.child("users").child("doctor").child(x).child( "LicenseNum").get().val() if j == lNum: ErrorMsg = "Duplicate License Number!" return render(request, "register.html", {'m': ErrorMsg}) try: user = auth.create_user_with_email_and_password(email, passw) except: ErrorMsg = "Email Address Already Registered" return render(request, "register.html", {'m': ErrorMsg}) print(user) uid = user['localId'] tok = user['idToken'] users_ref = db.child("users").child("doctor").child(uid) sendemail = auth.send_email_verification(tok) users_ref.set({ 'email': email, 'fullname': fullname, 'address': address, 'gender': gender, 'contactNo': num, 'birthDate': birthdate, 'medicalSpecialization': MS, 'LicenseNum': lNum, 'status': "1", }) SuccessMsg = "Account Created Successfully" HttpResponse(SuccessMsg) return render(request, "verify.html", {"e": email, 'm': SuccessMsg})