Пример #1
0
 def login_valid(email, password):
     data = Database.find_one("users", {"email": email})
     if data is None:
         raise UserError.UserNotExistsError("User not exist")
     elif Utils.check_hashed_password(password, data['password']) is False:
         raise UserError.IncorrectPasswordError("Password is wrong")
     return True
Пример #2
0
 def is_login_valid(email, password):
     user_data = Database.find_one(UserConstants.COLLECTION, {"email": email})
     if user_data is None:
         raise UserErrors.UserNotExistsError("Your user does not exist.")
     if not Utils.check_hashed_password(password, user_data["password"]):
         raise UserErrors.IncorrectPasswordError("Your password was wrong.")
     return True
Пример #3
0
    def is_login_valid(email, password):
        """
        This method verifies that an e-mail/password combo (as sent by the site forms) is valid or not.
        Checks that the e-mail exists, and that the password associated to that e-mail is correct.
        :param email: The user's email
        :param password: A sha512 hashed password
        :return: True if valid, False otherwise
        """
        user_data = Database.find_one(UserConstants.COLLECTION,
                                      {"email": email})
        admin_created_user = Database.find_one(UserConstants.COLLECTION, {
            "email": email,
            "admin_created": "Yes"
        })
        if user_data is None:
            # Tell the user that their e-mail doesn't exist
            raise UserErrors.UserNotExistsError(
                "Email is not recognized.  Please use link below to sign-up if you have not created an account."
            )
        if admin_created_user is not None:
            # Tell the user to sign up
            raise UserErrors.AdminCreatedUserError(
                "Your account was created by an admin.  Please register with HHT to enjoy the full functionality of the site."
            )
        if not sha512_crypt.verify(password, user_data['password']):
            # Tell the user that their password is wrong
            raise UserErrors.IncorrectPasswordError(
                "Password does not match the one registered.")

        return True
Пример #4
0
    def new_channel(user_id, cname, cdescript, ctype, wid):
        if not User.exist_user(user_id):
            raise UserError.UserNotExistsError("The admin_id doesn't exist")
        if not Workspace.exist_workspace(wid):
            raise WorkspaceError.WorkspaceNotExistsError(
                "The workspace you want to created channel in doesn't exist")
        if ctype < 0 or ctype > 2:
            raise ChannelError.ChannelTypeError(
                "The Channel Type from your input is invalid")
        if len(cname) > 50:
            raise ChannelError.InputTooLongError(
                "The input of channel name is too long")
        if len(cdescript) > 100:
            raise ChannelError.InputTooLongError(
                "The input of channel description is too long")

        sql = "select * from {} where cname='{}' and wid='{}'".format(
            ChannelConstants.COLLECTION, cname, wid)
        channel_data = Database.fetchone(sql)

        if channel_data is not None:
            raise ChannelError.ChannelAlreadyExist("The channel exists.")
        sql = "insert into {}(cname, cdescript, wid, ctype, creatorid, stamp)values('{}', '{}', '{}', '{}', '{}', now())".format(
            ChannelConstants.COLLECTION, cname, cdescript, wid, ctype, user_id)
        Database.execute(sql)

        # add creator into channel
        sql = "select * from {} where cname='{}' and wid='{}'".format(
            ChannelConstants.COLLECTION, cname, wid)
        tup = Database.fetchone(sql)
        cid = tup[0]
        sql = "insert into {}(cid, uid)values({}, {})".format(
            ChannelConstants.INCLUDE, cid, user_id)
        Database.execute(sql)
        return True
Пример #5
0
 def is_login_valid(email, password):
     user_data = Database.find_one("users", {"email": email})
     if user_data is None:
         raise UserErrors.UserNotExistsError("User does not exist.")
     if not Utils.check_hashed_password(password, user_data['password']):
         raise UserErrors.IncorrectPasswordError(
             "The password is incorrect.")
     return True
Пример #6
0
 def is_login_valid(email, password):
     user_data = Database.find_one(collection=UserConstants.COLLECTION,  query={'email': email})
     if user_data is None:
         raise UserErrors.UserNotExistsError("Your user name does not exists.")
     if not Utils.check_hashed_password(password,  user_data['password']):
         raise UserErrors.IncorrectPasswordError("Incorrect password")
     else:
         return True
Пример #7
0
    def is_login_valid(email, password):
        user = db.find_one(UserConstraints.Collection, {'email': email})
        if user is None:
            raise exc.UserNotExistsError("Your user does not exist")
        if not Utils.check_hashed_password(password, user['password']):
            raise exc.IncorrectPasswordError("Your password is wrong")

        return True
Пример #8
0
 def login_valid(email, password):
     user_data = User.get_by_email(email)
     if user_data is None:
         # Tell the user their email does not exist
         raise UserErrors.UserNotExistsError("This account does not exist!")
     if not Utils.check_hashed_password(password, user_data['password']):
         # Tell the user their password is wrong
         raise UserErrors.IncorrectPasswordError("Your password was wrong!")
     return True
    def is_login_valid(email, password):

        user_data = Database.find_one(
            'users', {'email': email})  #password in sha512 -> pbkdf2
        if user_data is None:
            raise UserErrors.UserNotExistsError('Your user does not exists.')
        if Utils.check_hashed_password(password, user_data['password']):
            raise UserErrors.IncorrectPasswordError("Your password is wrong.")
        return True
Пример #10
0
    def is_login_valid(email, password):
        user_data = Database.find_one("users", {"email": email}) # Password is in sha512 -> pbdkf2_sha512
        if user_data is None:
            raise UserErrors.UserNotExistsError("Your user does not exist.")

        if not Utils.check_hashed_password(password,user_data['password']):
            raise UserErrors.IncorrectPasswordError("Your password was wrong.")

        return True
Пример #11
0
    def is_login_valid(username, password):
        user_data = Database.find_one(UserConstants.COLLECTION,
                                      {"username": username})
        if user_data is None:
            raise UserErrors.UserNotExistsError("User not found.")
        if not Utils.check_hashed_password(password, user_data['password']):
            raise UserErrors.IncorrectPasswordError("Incorrect Password")

        return True
Пример #12
0
    def is_login_valid(email, password):
        query = "SELECT * FROM appusers WHERE email = \'{}\'".format(email)
        user_data = Database.find_one(query)  # Password in sha512 -> pbkdf2_sha512
        if user_data is None:
            # Tell the user that their e-mail doesn't exist
            raise UserErrors.UserNotExistsError("Your user does not exist.")
        if not Utils.check_hashed_password(password, user_data['password']):
            # Tell the user that their password is wrong
            raise UserErrors.IncorrectPasswordError("Your password was wrong.")

        return True
Пример #13
0
    def is_login_valid(email, password):
        user_data = Database.find_one("users", {"email": email})
        if user_data is None:
            # Tell the user that e-mail doesn't exist
            raise UserErrors.UserNotExistsError("Your user does not exist.")

        if not Utils.check_hashed_passhword(password, user_data['password']):
            # Tell the user that their password is wrong
            raise UserErrors.IncorrectPasswordError("Your password was wrong.")

        return True
Пример #14
0
    def is_login_valid(email, password):
        user_data = Database.find_one(UserConstants.COLLECTION,{"email":email}) #Password in sha512 -> pbkdf
        print(email)

        if user_data is None:
            raise UserErrors.UserNotExistsError("Your user does not exist")

        #print(user_data)
        if not Utils.check_hashed_password(password, user_data['password']):
            raise UserErrors.IncorrectPasswordError("Your password was wrong")

        return True
Пример #15
0
 def is_login_valid(email, password):
     user_data = Database.find_one(
         "users", {"email": email})  # Password in sha512 -> pbkdf2_sha512
     if user_data is None:
         # Tell the user that their e-mail doesn't exist
         raise UserErrors.UserNotExistsError(
             "In order to log in,you need to register first.")
     if not Utils.check_hashed_password(password, user_data['password']):
         # Tell the user that their password is wrong
         raise UserErrors.IncorrectPasswordError(
             "Your password was wrong.Please try again.")
     return True
Пример #16
0
    def is_login_valid(email, password):
        user_data = Database.find_one("users", {"email": email})
        if user_data is None:
            # email tidak ada pada sistem
            raise UserErrors.UserNotExistsError(
                "Tidak ada user yang sama dengan email")

        if not Utils.check_hashed_password(password, user_data['password']):
            # password salah
            raise UserErrors.IncorrectPasswordError("Incorrect Password")

        return True
Пример #17
0
 def login_user(email, password):
     # provision for the root_user add encryption for the root user here
     # else put this in a config file. but figure out a way of upgrade without a complete docker exchange
     if email == 'alloons_root' and password == 'hbF_ig034':
         return True
     else:
         user_data = Database.find_one(UserConstants.COLLECTION, {'email': email})
         if user_data is None:
             raise UserErrors.UserNotExistsError("This Username Does not exist")
         if not Utils.check_hashed_password(password, user_data['password']):
             raise UserErrors.IncorrectPasswordError("Password Incorrect")
         return True
Пример #18
0
    def is_valid_login(email, password):
        """
        This method verifies that an email/password combo sent by the site forms is valid or not
        Chekcs that the email exists and the password associated to the email
        """
        user_data = Database.find_one(
            'users', {'email': email})  #Password in sha512 -> pbkdf2_sha512
        if user_data is None:
            raise UserErrors.UserNotExistsError("Your user does not exist!")

        if not Utils.check_hashed_password(password, user_data['password']):
            raise UserErrors.InCorrectPasswordError("Your password was wrong.")

        return True
Пример #19
0
 def is_login_valid(email, password):
     """
     This method verifies an e-mail/password combo is valid or not.
     Checks that the e-mail exists, and that the password associated to that e-mail is correct.
     :param email: The users's e-mail
     :param password: A sha512 hashed password
     :return: true if valid, false otherwise
     """
     user_data = Database.find_one(UserConstants.COLLECTION, {"email":email}) # password in shah512 -> sha512_pbkdf2
     if user_data is None:
         raise UserErrors.UserNotExistsError("Your users data not exist")
     if not Utils.check_hashed_password(password, user_data['password']):
         raise UserErrors.IncorrectPasswordError("Your password is wrong")
     return True
Пример #20
0
 def is_login_valid(email, password):
     '''
     This Method verifies that an email/password combo(as sent by the site form) is valid or not,
      Checks that the e-mail exists, and that the password associated to the email is correct.
     :param email: The User's email
     :param password: The sha512 hashed password
     :return: True if valid, False otherwise
     '''
     user_data = Database.find_one('users', {"email": email})
     if user_data is None:
         #Tell the user that their e-mail doesn't exist
         raise UserErrors.UserNotExistsError("Your user does not exist")
     if not Utils.check_hashed_password(password, user_data['password']):
         #Tells the user that their password is wrong
         raise UserErrors.IncorrectPasswordError("Your password was wrong")
Пример #21
0
    def is_login_valid(email, password):
        """
        This method verifies that an email/pw combo is valid or not
        :param email: User email
        :param password: A sha512 hashed pw
        :return True/False
        """
        user_data = Database.find_one(UserConstants.COLLECTION,
                                      {'email': email})
        if user_data is None:
            raise UserErrors.UserNotExistsError("Your user does not exist.")
        if not Utils.check_hashed_password(password, user_data['password']):
            raise UserErrors.IncorrectPasswordError("Your password was wrong.")

        return True
Пример #22
0
    def is_login_valid(email, password):
        """
        This method verifies that an e-mail/password combo (sent by the website form) is valid or not
        Checks that the email exists & password is correct
        :param email: User's email
        :param password: a sha512 hashed password
        :return: true if valid, false otherwise
        """
        user_data = Database.find_one(UserConstants.COLLECTION, {"email":email})
        if user_data is None:
            raise UserErrors.UserNotExistsError("Your user does not exist.")
        if not Utils.check_hashed_password(password, user_data['password']):
            raise UserErrors.IncorrectPasswordError("Your password was wrong.")

        return True
Пример #23
0
    def is_login_valid(email, password):
        """
        This method verifies that an email /password is valid or not
        check email existes and that password associated to that email is correct
        :param email: The user's email str
        :param password: A sha512 hased password
        :return: True if vaild Flase otherwise
        """
        user_data = Database.find_one(UserContants.COLLECTION,
                                      {"email": email})
        if user_data is None:
            raise UserErrors.UserNotExistsError("User doesn't exist")
        if not Utils.check_hashed_password(password, user_data['password']):
            raise UserErrors.IncorrectPasswordError("Password incorrect")

        return True
Пример #24
0
 def is_login_valid(email, password):
     """
     This method verifies that an email password combo as sent my the site forms is valid or not
     Checks the e-mail exists and that the password associated to that e-mail is correct
     :param email: The user's email
     :param password: A hashed sha512 password
     :return: True if valid, False othervise
     """
     user_data = Database.find_one(
         UserConstants.COLLECTION,
         {"email": email})  # Password in sha512 -> pbkdf2_sha512
     if user_data is None:
         raise UserErrors.UserNotExistsError("Your user does not exists.")
     if not Utils.check_hashed_password(password, user_data["password"]):
         raise UserErrors.IncorrectPasswordError("Your password is wrong")
     return True
Пример #25
0
    def login_is_valid(email, password):
        """
        This method verifies that an email password combo is valid or not. It checks that the email
        exists and that the password matches.
        :param email: The user's email
        :param password: The user's hashed password
        :return: True if valid otherwise False
        """

        user_data = Database.find_one(UserConstants.COLLECTION, {"email": email})
        if user_data is None:
            raise UserErrors.UserNotExistsError("The specified user doesn't exist.")
        if not Utils.check_hashed_password(password, user_data['password']):
            raise UserErrors.IncorrectPasswordError("The password is incorrect.")

        return True
Пример #26
0
    def is_login_valid(email,password):
        '''
        This method verifies that an email-password combo is valid or not
        Check that email exists, and that password associated to that email is correct
        :param email: The user'e email
        :param password: A sha512 hashed password not a plain text password
        :return:
        '''
        # check whether the user exists
        user_data=Database.find_one("users",{"email":email})
        if user_data is None:
            # Tell the user their email doesn't exists and they need to register
            raise UserErrors.UserNotExistsError("Your user doesn't exist.")
        if not Utils.check_hashed_password(password,user_data['password']):
            raise UserErrors.IncorrectPasswordError("Your password was wrong.")

        return True
Пример #27
0
    def is_login_valid(email, password):
        """
        This method verifies that email/password combo as sent by form is valid.
        Checks that e-mail exists and that password is correct
        :param email:
        :param password: A sha512 hashed password
        :return:
        """
        user_data = Database.find_one("users",{"email":email})
        if user_data is None:
            # Tell the user that they don't exist
            raise UserErrors.UserNotExistsError("User not found")
        if not Utils.check_hashed_password(password, user_data['password']):
            # Tell user wrong password
            raise UserErrors.IncorrectPasswordError("Incorrect password")

        return True
Пример #28
0
    def is_login_valid(email, password):
        """
        This method verifies that the email.password combo (as sent by the site form) is valid.
        Checks that the email exists and that the password associated with it is correct.
        :param email: the users email
        :param password:  a SHA512 hashed password
        :return: true if valid combo, false otherwise
        """
        user_data = Database.find_one(collection=UserConstants.COLLECTION, query={'email': email}) # password in sha512 -> pbkdf2_sha512
        if user_data == None:
            # tell the user their email doesn't exist
            raise  UserErrors.UserNotExistsError("The user is not registered.")
        if not Utils.check_hashed_password(password, user_data['password']):
            # Tell them that their password is wrong
            raise UserErrors.IncorrectPasswordError("The password is not correct")

        return True
Пример #29
0
    def is_login_valid(email, password):
        """
        This method verifies that an e-mail/password combo (as sent by the site forms) is valid or not.
        Checks that the e-mail exists, and that the password associated to that e-mail is correct.
        :param email: The user's email
        :param password: A sha512 hashed password
        :return: True if valid, False otherwise
        """
        user_data = Database.find_one("users", {"email": email})  # Password in sha512 -> pbkdf2_sha512
        if user_data is None:
            # Tell the user that their e-mail doesn't exist
            raise UserErrors.UserNotExistsError("Your user does not exist.")
        if not Utils.check_hashed_password(password, user_data['password']):
            # Tell the user that their password is wrong
            raise UserErrors.IncorrectPasswordError("Your password was wrong.")

        return True
Пример #30
0
    def is_login_valid(email, password):
        """
        This is method verfies that and email/password combo (as sent by the site forms) is valud or not.
        :param email: The user's email
        :param password: A sha512 hashed password
        :return: Ture if valid, False otherwise
        """

        user_data = Database.find_one(
            UserConstants.COLLECTION,
            {"email": email})  # Password in sha512 -> pbkdf2_sha512
        if user_data is None:
            raise UserErrors.UserNotExistsError("Your user does not exist.")
        if not Utils.check_hashed_password(password, user_data['password']):
            raise UserErrors.IncorrectPasswordError("Your password was wrong.")

        return True