Ejemplo n.º 1
0
def create_password():
    if request.method == 'POST':
        password = request.form['password']
        password_second = request.form['password_repeated']
        if password == password_second:
            hashed_password = Utils.hash_password(password)
            user = Database.find_one(UserConstants.COLLECTION,
                                     {"_id": session["user_id"]})
            user["password"] = hashed_password
            # update user in db
            User.user_json_to_user_object(user).update_db()
            return render_template("FullCalendar.html")
        else:
            error_message = "passwords don't match, please re-enter them"
            return render_template('createPassword.html',
                                   error_message=error_message)
Ejemplo n.º 2
0
    def register_company(company_name, company_password, key):
        company_data = Database.find_one(COLLECTION, {"company_name": company_name, "key": key})

        # needs to catch JSON decoder error and return invalid company name and key
        account = TaskObjectBuilder.get_from_teamwork_scaled(CompanyConstants.account_action,
                                                             CompanyConstants.account_name,
                                                             company_name, key)
        people = Company.create_user_id_list(company_name, key)
        if company_data is not None:
            return "already registered"

        elif "companyid" in account.keys():
            _id = account["companyid"]
            company = Company(_id, company_name, Utils.hash_password(company_password), key, people)
            company.save_to_db()
            Company.create_users(company_name, company_data["key"], _id)
            return "company registered"
        else:
            return "invalid company name or API key"