def validate_owner_reviewer(owner, reviewer):
    if owner == "":
        return "Add a Owner"
    if reviewer == "":
        return "Add a Reviewer"
    if len(database.get_user_details(owner)) <= 0:
        return "Invalid Owner"
    if len(database.get_user_details(reviewer)) <= 0:
        return "Invalid Reviewer"
    return "Valid"
def validate_badge_owner(owner_email_address):
    if owner_email_address == "" or owner_email_address is None:
        # print("Empty Owner email address")
        return "Empty Owner email address"
    if len(database.get_user_details(owner_email_address)) <= 0:
        return "Invalid Email address in Owner - " + owner_email_address
    return "valid owner"
Beispiel #3
0
def get_user_details(user_id):
    conn = sqlite3.connect(db)
    result = None
    if (conn is not None):
        result = database.get_user_details(conn, user_id)
        conn.close()
        return result
Beispiel #4
0
def feedback_process(username, password, product_id):
    user_id = get_user_details(username, password)['user_id'].iloc[0]

    rating = input("Please provide rating from 1 to 5: ", )
    if rating == "signout":
        app()
    else:
        review = input("Please provide review: ", )

        if review == "signout":
            app()
        else:
            review_exists = is_feedback_exists(user_id=user_id,
                                               product_id=product_id)
            if review_exists is False:
                insert_feedback(id=str(uuid.uuid4()),
                                product_id=product_id,
                                user_id=user_id,
                                rating=int(rating),
                                review=review,
                                created_at=str(datetime.datetime.now()),
                                updated_at=str(datetime.datetime.now()))
            else:
                update_ratings(rating=rating,
                               review=review,
                               user_id=user_id,
                               product_id=product_id)
Beispiel #5
0
def m_valid_login(user, passw):
    #	if user in pluginmgr.plgmap["xmpp"].m_bot.muc_jid:
    #		print(_("Redirecting user privilege change to real JID."))
    #		user = pluginmgr.plgmap["xmpp"].m_bot.muc_jid[user]
    ud = database.get_user_details(user)
    if ud == None:
        return False
    return True
Beispiel #6
0
def get_userpriv(user):
    ud = database.get_user_details(user)
    if ud != None:
        if ("privilege" in ud):
            return _("Username: %(username)s has privilege %(pri)i.") % {
                'username': user,
                'pri': ud["privilege"]
            }
    return _("Username: %s info not exist in database.") % user
Beispiel #7
0
def wrap_get_detail_item(msg):
	try:
		user = msg["res"].group(1)
		UUID = msg["res"].group(2)
	except IndexError:
		return [(None,msg["from"])]
	ud = database.get_user_details(user)
	res = get_detail_item(ud["data"],UUID)
	if res == None:
		return [(_("UUID %s not found in user data.") % UUID,msg["from"])]
	else:
		return [(res,msg["from"])]
Beispiel #8
0
def password_reset_email(email):
    if email == "":
        return "email is empty"
    if validate_email_address(email) == INVALID:
        return "email is not correct"
    user_doc = database.get_user_details(email)
    if len(user_doc) > 0:
        password = generate_strong_password()
        email_content(email, "This is your new password: "******"Email sent successfully"
    return "user does not exist"
Beispiel #9
0
def password_reset(email_address, password):
    if email_address == "":
        return "email is empty"
    if validate_email_address(email_address) == INVALID:
        return "email is not correct"
    if password is None or password.strip() == "":
        return "password is empty"
    user_doc = database.get_user_details(email_address)
    if len(user_doc) > 0:
        hashed_password = hash_password(password)
        database.update_user_password(email_address, hashed_password)
        return "Password reset is complete"
    return "user does not exist"
Beispiel #10
0
def complete_userdata(msg):
	try:
		user = msg["res"].group(1)
	except IndexError:
		return [(None,msg["from"])]
	ud = database.get_user_details(user)
	if ("data" in ud):
		res = check_user_obj_enum(ud["data"],m_conf["def_obj_enum"])
		if refine_inventory(ud["data"]) == -1:
			return [(_("User %s data have error.") % user,msg["from"])]
		else:
			ud["data"] = res
			database.set_user_details(user,ud)
			return [(_("Updated user %s data successfully.") % user,msg["from"])]
Beispiel #11
0
def login(email, password):
    password_hash = PasswordHasher()
    if email == "" or password == "":
        return "username or password is empty"
    if validate_email_address(email) == INVALID:
        return "email is not correct"
    user_doc = database.get_user_details(email)
    if len(user_doc) > 0:
        try:
            if password_hash.verify(user_doc['password'], password):
                return str(ObjectId(user_doc['userType']))

        except (InvalidHash, HashingError, VerificationError, VerifyMismatchError):
            return "password is wrong"
    return "user does not exist"
Beispiel #12
0
def endpoint_send_removal():
    data = request.get_json()
    sender = data['name']
    company_id = data['company']
    removal_list = data['removal_list']
    login_credentials = data['account']

    userid = dummy_user

    user = db.get_user_details(userid)
    target_email = db.get_company(company_id)['email']
    body = templates.removal_template(sender, target_email, user['legal-name'],
                                      removal_list, login_credentials)

    send_email(body, sender, target_email)
    db.save_email(userid, company_id, 'data-removal', body)
Beispiel #13
0
def endpoint_send_followup():
    data = request.get_json()
    sender = data['name']
    company_id = data['company']
    login_credentials = data['account']

    userid = dummy_user

    user = db.get_user_details(userid)
    target_email = db.get_company(company_id)['email']
    previous_date = db.get_last_response(userid, company_id)['timestamp']
    previous_date = datetime.fromtimestamp(previous_date).strftime('%Y-%m-%d')
    body = templates.followup_template(sender, target_email,
                                       user['legal-name'], previous_date)

    send_email(body, sender, target_email)
    db.save_email(userid, company_id, 'followup', body)
def password_reset_email(email_address):
    if email_address == "":
        return "email is empty"
    if validate_email_address(email_address) == INVALID:
        return "email is not correct"
    user_doc = database.get_user_details(email_address)
    if len(user_doc) > 0:
        mail_from = "*****@*****.**"
        mail_to = email_address
        subject = "Industrial AI Starter - Password Reset"
        reply_to = "*****@*****.**"
        body = "Hi" + email_address + ", Please click the below URL to reset your password"
        message = Message(subject,
                          sender=mail_from,
                          recipients=[mail_to],
                          reply_to=reply_to)
        message.body = body
        with app.app_context():
            mail.send(message)
        return "Email sent successfully"
    return "user does not exist"
Beispiel #15
0
def password_reset_user(email, password, new_password):
    password_hash = PasswordHasher()
    if email == "":
        return "email is empty"
    if password is None or password.strip() == "":
        return "password is empty"
    if validate_email_address(email) == INVALID:
        return "email is not correct"
    if new_password is None or new_password.strip() == "":
        return "Confirm password is empty"
    user_doc = database.get_user_details(email)
    if len(user_doc) > 0:
        try:
            isMatch = password_hash.verify(user_doc['password'], password)
            if (isMatch):
                hashed_password = hash_password(new_password)
                database.update_user_password(email, hashed_password)
                return "Password reset is complete"
        except (InvalidHash, HashingError, VerificationError,
                VerifyMismatchError):
            return "Current passwords do not match"
    return "user does not exist"
Beispiel #16
0
def check_priv(cmd, username):
    if cmd == None:
        print("privilege.py:check_priv: command returned None. This is a bug.")
        return False
    if not (cmd in priv_map):
        return True
    else:
        priv = 100
        if not m_conf == None:
            if "trusted_jid" in m_conf:
                if username in m_conf["trusted_jid"]:
                    priv = 0
        ud = database.get_user_details(username)
        if ud != None:
            if "privilege" in ud:
                if ud["privilege"] < priv:
                    priv = ud["privilege"]
            else:
                ud["privilege"] = 60
                database.set_user_details(username, ud)
        if (priv <= priv_map[cmd]):
            return True
        else:
            return False
Beispiel #17
0
def set_userpriv(user, priv):
    #	if user in pluginmgr.plgmap["xmpp"].m_bot.muc_jid:
    #		print(_("Redirecting user privilege change to real JID."))
    #		user = pluginmgr.plgmap["xmpp"].m_bot.muc_jid[user]
    ud = database.get_user_details(user)
    cre = False
    if ud == None:
        ud = {}
        cre = True
    ud["privilege"] = int(priv)
    database.set_user_details(user, ud)
    if not cre:
        return _(
            "Set user %(username)s privilege to %(pri)i successfully.") % {
                'username': user,
                'pri': int(priv)
            }
    else:
        return _(
            "Created and set user %(username)s privilege to %(pri)i successfully."
        ) % {
            'username': user,
            'pri': int(priv)
        }
def validate_badge_reviewer(reviewer_email_address):
    if reviewer_email_address == "" or reviewer_email_address is None:
        return "Empty reviewer email address"
    if len(database.get_user_details(reviewer_email_address)) <= 0:
        return "Invalid Email address in reviewer - " + reviewer_email_address
    return "valid reviewer"
Beispiel #19
0
def start(user_input, username, password):
    persona = get_user_details(username, password)['persona'].iloc[0]
    product_id, product_search = product_details_process(persona)
    feedback_process(username, password, product_id)
    return start("signin", username, password)
def validate_email_exist(email):
    user_doc = database.get_user_details(email)
    if len(user_doc) > 0:
        return "email already exists"
    return 'email does not exist'
def check_email_address_exist(email_address):
    user_doc = database.get_user_details(email_address)
    if len(user_doc) > 0:
        return EMAIL_EXIST
    return EMAIL_NOT_EXIST
Beispiel #22
0
 def get_user_details(self, id):
     return db.get_user_details(self.db_cursor, id)