Exemple #1
0
def store_user():
    auth = firebase.auth()    
    auth.create_user_with_email_and_password(request.json['email'], request.json['password'])
    data = {
        'email': request.json['email']
        }   
    return jsonify(data), 200
Exemple #2
0
def registerByAdmin():
    form = signupForm()
    if request.method == 'POST':
        email = form.email.data
        password = form.password.data
        name = form.name.data
        last = form.last.data
        Admin = form.Admin.data
        user = auth.create_user_with_email_and_password(email, password)
        if Admin == 'true':
            data = {
                "name": name,
                "last": last,
                "email": email,
                "password": password,
                "admin": True
            }
        if Admin == 'false':
            data = {
                "name": name,
                "last": last,
                "email": email,
                "password": password,
                "admin": False
            }
        print(auth.get_account_info(user['idToken'])['users'][0]['localId'])
        info = auth.get_account_info(user['idToken'])['users'][0]['localId']
        db.collection(u'Users').document(info).set(data)
        return redirect(url_for("login"))

    return render_template('signup.html', form=form, us="Not Exist")
Exemple #3
0
def register():
    if request.method == "POST":  #Only listen to POST
        result = request.form  #Get the data submitted
        email = result["email"]
        password = result["pass"]
        name = result["name"]
        try:
            #Try creating the user account using the provided data
            print("here \n")
            auth.create_user_with_email_and_password(email, password)
            print("here1 \n")
            #Login the user
            user = auth.sign_in_with_email_and_password(email, password)
            print("here2 \n")
            #Add data to global person
            global person
            person["is_logged_in"] = True
            person["email"] = user["email"]
            person["uid"] = user["localId"]
            person["name"] = name
            #Append data to the firebase realtime database
            data = {"name": name, "email": email}
            print("here3 \n")
            db.child("users").child(person["uid"]).set(data)
            #Go to chooseGame page
            return redirect(url_for('chooseGame'))
        except:
            #If there is any error, redirect to register

            return redirect(url_for('register'))

    else:
        if person["is_logged_in"] == True:
            return redirect(url_for('chooseGame'))
        else:
            return redirect(url_for('register'))
def signUp():
    print("Signing Up...")
    email = input("Enter Email: ")
    password = getpass("Enter Password: "******"New Account Created!")
        ask = input("Do you want to Login now?[y/n]")
        if ask == 'y':
            login()
    except:
        print("Email already Exists")
        ask = input("Log in?[y/n]")
        if ask == 'y':
            login()
Exemple #5
0
def signup():
    form=signupForm()
    if request.method == 'POST':
        email=form.email.data
        password=form.password.data
        name=form.name.data
        last=form.last.data
        user=auth.create_user_with_email_and_password(email,password)
        data={"name":name,"last":last,"email":email,"password":password,"admin":False}
        #db.child("Guest").push(data)
        #data2={"name":"1","other":email,"shadowing":"123"}
        #db.child("Parks").push(data2)
        print(auth.get_account_info(user['idToken'])['users'][0]['localId'])
        info=auth.get_account_info(user['idToken'])['users'][0]['localId']
        db.collection(u'Users').document(info).set(data)
        return redirect(url_for("home"))
    return render_template('signup.html',form=form)
Exemple #6
0
def registerScrumMaster():
    form = signupForm()
    if request.method == 'POST':
        email = form.email.data
        password = form.password.data
        id = form.id.data
        firstname = form.firstname.data
        lastname = form.lastname.data
        try:
            Developertabel = auth.create_user_with_email_and_password(
                email, password)
            data = {
                "email": email,
                "password": password,
                "id": id,
                "firstname": firstname,
                "lastname": lastname
            }
            db.collection(u'ScrumMastertabel').document().set({
                "email":
                email,
                "password":
                password,
                "id":
                id,
                "firstname":
                firstname,
                "lastname":
                lastname
            })
            print(
                auth.get_account_info(userregisterScrumMaste['idToken'])
                ['ScrumMastertabel'][0]['localId'])
            info = auth.get_account_info(userregisterScrumMaste['idToken']
                                         )['ScrumMastertabell'][0]['localId']
            db.collection(u'ScrumMastertabel').document(info).set(data)
            #return redirect(url_for("scrumMasterPage"),form=form)
            return render_template('scrumMaster.html', form=form)
        except:
            print("email already exist")
    return render_template('registerScrumMaster.html', form=form)
Exemple #7
0
def create_account_in_firebase(password, emailid):
    for passs, user in zip(password, emailid):
        try:
            user = auth.create_user_with_email_and_password(user, passs)
        except:
            return ("user name is already there", user)
Exemple #8
0
def index():

    if request.method == "POST":

        if request.form['form-name'] == 'auth_form':
            email = request.form['email']
            password = request.form['password']

            if request.form['action'] == 'Login':
                #Sample account: "*****@*****.**", "samarth16"
                if email == "" or password == "":
                    return {'message': 'Error missing email or password'}, 400

                try:
                    user = auth.sign_in_with_email_and_password(
                        email, password)
                    token = user['idToken']
                except Exception as e:
                    return {'message': 'Error logging user in'}, 400

            if request.form['action'] == 'Sign Up':
                if email == "" or password == "":
                    return {'message': 'Error missing email or password'}, 400
                try:
                    user = auth.create_user_with_email_and_password(
                        email, password)
                    token = user['idToken']
                    print("Sign Up")
                except Exception as e:
                    return {'message': 'Error signing user up'}, 400

            if request.form['action'] == 'Log Out':
                try:
                    auth.current_user = None
                    return {'message': 'Successfully signed out!'}
                except Exception as e:
                    print(e)
                    return {'message': 'Error signing out'}, 400

        if request.form['form-name'] == 'create_form':

            user = getUser()
            token = getToken(user)

            #Make sure the user is authenticated
            if token is None:
                return {'message': 'User has not successfully signed in'}

            #Get the query input
            company = request.form['company']
            keyword = request.form['keyword']

            try:
                ans = getResults(company, keyword)

                for row in ans:
                    company = row[0]
                    keyword = row[1]

                    uid = user["localId"]

                    first = row[2]
                    last = row[3]
                    email = row[4]

                    link = row[9]

                    created = row[-1]

                    new_query = {
                        "uid": uid,
                        "company": company,
                        "keyword": keyword,
                        "first": first,
                        "last": last,
                        "email": email,
                        "linkedin_url": link
                    }

                    db.child("queries").push(new_query, token)

                df = pd.DataFrame(ans,
                                  columns=[
                                      "Company", "Keyword", "First", "Last",
                                      "Email", "Status", "Title", "Seniority",
                                      "Department", "LinkedIn Url", "Phone",
                                      "Pattern", "Time Created"
                                  ])
                leads_csv = df.to_csv()
                response = make_response(leads_csv)
                response.headers[
                    "Content-Disposition"] = "attachment; filename=leads.csv"
                return response
            except Exception as e:
                print(e)
                return {'message': 'Error generating leads'}

    #Display entries currently in database
    user = getUser()
    tup_output = []

    try:
        past_queries = db.child("queries").get().val().values()

        for query in past_queries:
            uid = query["uid"]
            co = query["company"]
            key = query["keyword"]

            if user['localId'] == uid:
                tup_output.append(tuple([co, key]))

        tup_output = list(set(tup_output))

    except Exception as e:
        print(e)
        past_queries = None

    return render_template('index.html', queries=tup_output)