コード例 #1
0
ファイル: user.py プロジェクト: ObedEG/complex_web
    def register_user(name, last_name, employee_num, email, password):
        """
        This method registers a user e-mail and password.
        The password already comes hashed as  sha-512
        :param email: user's email (might be invalid)
        :param password: sha-512 hashed password
        :param name:
        :param last_name:
        :param employee_num:
        :return: True if registered successfully, or False otherwise (exception can also be raised)
        """
        user_data = Database.find_one(UserConstants.COLLECTIONS,
                                      {"email": email})

        if user_data is not None:
            raise UserErrors.UserAlreadyRegisteredError(
                "The email you used to register already exists.")
        if not Utils.email_is_valid(email):
            raise UserErrors.InvalidEmailError(
                "The email does not have the right format.")

        User(name, last_name, employee_num, email,
             Utils.hash_password(password)).save_to_db()

        return True
コード例 #2
0
ファイル: user.py プロジェクト: nmartinovic/price-of-chair
    def register_user(email, password):
        '''

        This method registers a user using email and password
        The password comes hashed sha512
        :param email:  user's email (might be invalid)
        :param password: sha512 hashed password
        :return: True if registered successfully, or false otherwise.  Exceptions can be raised.
        '''

        user_data = Database.find_one(UserConstants.COLLECTION,
                                      {'email': email})

        if user_data is not None:
            #Tell user they are already registered
            raise UserErrors.UserAlreadyRegisteredError(
                "The email you used to register already exists")
        if not Utils.email_is_valid(email):
            #Tell user their email is not constructed properly
            raise UserErrors.InvalidEmailError(
                "The email does not have the proper format.")

        User(email, Utils.hash_password(password)).save_to_db()

        return True
コード例 #3
0
    def register_user(user_name, email, password):
        """
        This method register a user using e-mail and password.
        the password already comes hashed as sha-512
        :param name: the user name
        :param email: user's e-mail (might be invalid)
        :param password: sha512-hashed password
        :return: True if registered successfully, or False otherwise
        (exceptions can also be raised)
        """
        user_data = Database.find_one(
            UserConstants.COLLECTION,
            {"email": email})  # password in sha512 --> pdkdf2_sha512
        if user_data is not None:
            # need to tell the user are already exist
            raise UserErrors.UserAlreadyRegisteredError(
                "The user you tried to register is already exist")
        user_data = Database.find_one(UserConstants.COLLECTION,
                                      {"user_name": user_name})
        if user_data is not None:
            # need to tell the user are already exist
            raise UserErrors.UserAlreadyRegisteredError(
                "User with the same name is already exist")
        if not Utils.email_is_valid(email):
            # Tell the user his email is not constructed well
            raise UserErrors.InvalidEmailError(
                "The email you inserted is invalid")
        # Save the user to DB
        user = User(email, password, user_name)
        user.save_to_mongo()

        return True
コード例 #4
0
    def register_user(email, password):
        """
        This method registers an user with email and password
        The password already comes sha512
        :param email: user's email -- to be check is not already in the database
        :param password: sha512 hashed password to be converted into pbkdf2-sha512
        :return: True if user is registered, and False otherwise
        """

        # check the db for the email provided
        user_data = Database.find_one(UserConstants.COLLECTION,
                                      query={'email': email})

        # if we got a not None result
        if user_data is not None:
            # tell the user that he email provided is already in the db
            raise UserErrors.UserAlreadyRegisteredError(
                'The email provided already exists.')

        if not Utils.email_is_valid(email):
            # tell the suer that the email is not formatted as an email
            raise UserErrors.InvalidEmailError(
                'The email has not a proper format.')

        # if everything is OK, save the new user to the db
        User(email, Utils.hash_password(password)).save_to_db()

        return True
コード例 #5
0
ファイル: user.py プロジェクト: tainam04/my-price-of-chair
    def register_user(email, password):
        """
        This method registers a use using e-mail and password
        The password already comes hashed as sha-512
        :param email: User's email (might be invalid)
        :param passowrd: sha512-hashed password
        :return: True if registered successfully, or False otherwise (exceptions can also be raised)
        """
        user_data = Database.find_one(UserConstants.COLLECTION,
                                      {"email": email})

        if user_data is not None:
            # Tell user they are already registered
            raise UserErrors.UserAlreadyRegistered(
                "The email you used to register already exists ")

        if not Utils.email_is_valid(email):
            # Tell user that their e-mail is not constructed properly
            raise UserErrors.InvalidEmailError(
                "The email does not have right format.")
        hash_password = Utils.hash_password(password)
        user = User(email, hash_password)
        user.save_to_db()
        #User(email, Utils.hash_password(password)).save_to_db()

        return True
コード例 #6
0
ファイル: user.py プロジェクト: jslvtr/AC41004-Team-2
    def register_user(email, password):
        if not Utils.email_is_valid(email):
            return False
        if User.find_by_email(email) is not None:
            return False

        encrypted_password = sha256(password.encode("utf-8"))
        user = User(email, encrypted_password.hexdigest(), permissions=Permissions.default().name)
        user.data.update(
            {"points": {"action": 0, "practice": 0, "theory": 0, "networking": 0, "virtual": 0, "project": 0}}
        )
        user.data.update(
            {
                "country": "",
                "university": "",
                "school": "",
                "firstname": "",
                "lastname": "",
                "year": "",
                "level": "",
                "subject": "",
            }
        )

        user.save_to_db()
        return True
コード例 #7
0
    def register_user(email, password):
        """
        This method regsters a user using email and password
        Password already comes hashed as sha-512
        :param email: user's e-mail (might be invalid)
        :param password: sha512-hashed password
        :return: True is registered successfully, or False otherwise
                (exceptions can also be raised) """
        user_data = Database.find_one(UserConstants.COLLECTION,
                                      {"email": email})

        # if user is already registered
        if user_data is not None:
            # tell user they are already registered
            raise UserErrors.UserAlreadyRegisteredError(
                "The e-mail you used to register already exist.")
        # if e-mail is invalid
        if not Utils.email_is_valid(email):
            # tell user that their e-mail is not constructed properly
            raise UserErrors.InvalidEmailError(
                "The e-mail does not have the right format.")

        # set email and encrypted password to User attributes
        # then save to database
        User(email, Utils.hash_password(password)).save_to_db()

        return True
コード例 #8
0
ファイル: user.py プロジェクト: fdufay/udemy_price_chair
    def register_user(email, password):
        """
        This method registers a user using email and password.
        The password already comes hashed as sha-512.
        :param email: email
        :param password: sha-512 hashed password
        :return: True if registered successfully, or False otherwise (exceptions can also be raised)
        """

        user_data = Database.find_one(
            UserConstants.COLLECTION,
            {"email": email})  # Password in sha512 -> pbkdf2_sha512

        if user_data is not None:
            # Tell users they are already registered
            raise UserErrors.UserAlreadyRegisteredError(
                "The email you used to register already exists.")
        if not Utils.email_is_valid(email):
            # Tell user their email is not constructed properly
            raise UserErrors.InvalidEmailError(
                "The email does not have the right format.")

        User(email, Utils.hash_password(password)).save_to_db()

        return True
コード例 #9
0
    def register_user(email, password, fName, age):
        user_data = User.get_by_email(email)
        if user_data is not None:
            raise UserErrors.UserAlreadyRegisteredError("You already have an account with this email address.")
        if not Utils.email_is_valid(email):
            raise UserErrors.InvalidEmailError("This is an invalid email address!")

        User(email, Utils.hash_password(password), fName, age).save_to_mongo()
        return True
コード例 #10
0
ファイル: admin.py プロジェクト: jondanson/hbc_schedule
    def register_admin(email, password):
        user_data = Database.find_one(AdminConstants.COLLECTION, {"email": email})

        if user_data is not None:
            raise AdminErrors.AdminAlreadyRegisteredError("The email you used to register already exists.")
        if not Utils.email_is_valid(email):
            raise AdminErrors.InvalidEmailError("Not a valid email format.")

        Admin(email, Utils.hash_password(password)).save_to_mongo()
コード例 #11
0
 def register_user(email, password, name):
     user_data = Database.find_one(UserConstants.COLLECTION,
                                   {"email": email})
     if user_data is not None:
         raise UserErrors.UserAlreadyRegisteredError("Email already exists")
     if not Utils.email_is_valid(email):
         raise UserErrors.InvalidEmailError("The email address is invalid")
     User(email, Utils.hash_password(password), name).save()
     return True
コード例 #12
0
ファイル: user.py プロジェクト: eizaguirrec/WebStores
    def register_user(email, password):
        user_data = Database.find_one(collection=UserConstants.COLLECTION, query={'email': email})

        if user_data is not None:
            raise UserErrors.UserAlreadyRegisteredError("The e-mail you used to register already exists.")
        if not Utils.email_is_valid(email):
            raise UserErrors.InvalidEmailError("The email does not have the correct format.")
        User(email, Utils.hash_pasword(password)).save_to_db()

        return True
コード例 #13
0
ファイル: user.py プロジェクト: jslvtr/FChat
 def register_user(username, password, email, image):
     user_data = Database.find_one(UserConstant.COLLECTION, {'username':username})
     if user_data is not None:
         raise UserError.UserIsExist("The user is existing in the database")
     if not Utils.email_is_valid(email):
         raise UserError.EmailNotValid("Email is not valid")
     password = Utils.hash_password(password)
     user = User(username, password, email, image)
     user.save_to_mongo()
     return True
コード例 #14
0
ファイル: user.py プロジェクト: cuong19/PriceAlerts
    def register_user(email, password):
        user_data = Database.find_one('users', {'email': email})
        if user_data is not None:
            raise UserAlreadyRegisteredError("The email you used has already been used.")
        if not Utils.email_is_valid(email):
            raise InvalidEmailError("The email does not have the right format.")

        User(email, Utils.hash_password(password)).save_to_mongo()

        return True
コード例 #15
0
    def register_user(email, password):
        user_data = Database.find_one("users", {"email": email})

        if user_data is not None:
            raise UserErrors.UserAlreadyRegisteredError("The e-mail you used to register already exists.")
        if not Utils.email_is_valid(email):
            raise UserErrors.InvalidEmailError("The e-mail does not have the right format.")

        User(email, Utils.hash_password(password)).save_to_db()
        return True
コード例 #16
0
ファイル: user.py プロジェクト: tranngoctan18/pricing_alert
    def register_user(email, password):
        user_data = User.from_db_by_email(email)

        if user_data is not None:
            raise UserErrors.UserAlreadyRegisterError("Email is already registered.")
        if not Utils.email_is_valid(email):
            raise UserErrors.InvalidEmailError("Email is invalid.")

        User(email, Utils.hash_password(password)).save_to_db()
        return True
コード例 #17
0
ファイル: user.py プロジェクト: setijo01/Pangestoe_Web
    def register(email, sha512_password):
        user_data = Database.find_one(collection='users',
                                      query={'email': email})
        if user_data:
            raise UserErrors.UserAlreadyExistsError("User already registered.")
        if not Utils.email_is_valid(email):
            raise UserErrors.IncorrectEmailFormat("Invalid email.")

        User(email, Utils.hash_password(sha512_password)).save_to_database()

        return True
コード例 #18
0
    def register_user(email, password):
        user_data = Database.find_one(UserConstants.COLLECTION, {"email": email})

        if user_data is not None:
            raise UserErrors.UserAlreadyRegisteredError("The email that was used is already registered.")
        if not Utils.email_is_valid(email):
            raise UserErrors.InvalidEmailError("Invalid email format.")

        User(email, Utils.hash_password(password)).save_to_db()

        return True
コード例 #19
0
ファイル: user.py プロジェクト: jslvtr/alert-my-wishlist
    def register_user(email, password):
        user_data = Database.find_one(UserConstant.COLLECTION, {'email':email})

        if user_data is not None:
            raise UserError.UserAlreadyHasError("User is existing, please try again")
        if not Utils.email_is_valid(email):
            raise UserError.InvalidEmailError("Email is invalid, please enter another email")

        User(email, Utils.hash_password(password)).save_to_mongo()

        return True
コード例 #20
0
ファイル: user.py プロジェクト: Hongda-W/CovidAlert
    def register(cls, email: str, password: str) -> bool:
        if not Utils.email_is_valid(email):
            raise UserErrors.InvalidEmailError(f"{email} is not a valid email.")
        try:
            cls.find_by_email(email)
            raise UserErrors.UserAlreadyRegisteredError(f"{email} has already been registered.")
        except UserErrors.UserNotFoundError:
            User(email, Utils.hash_password(password)).save_to_mongo()
            cls.welcome(email)

        return True
コード例 #21
0
 def register(cls, email, password) -> bool:
     if not Utils.email_is_valid(email):
         raise UserErrors.InvalidEmailError(
             'The email does not have the right format.')
     try:
         cls.get_by_email(email)
         raise UserErrors.UserAlreadyRegisteredError(
             'The email you used to register already exits.')
     except UserErrors.UserNotFoundError:
         User(email, Utils.hash_password(password)).save_to_db()
     return True
コード例 #22
0
ファイル: user.py プロジェクト: Akash1507/Notif
    def register_user(email, password):
        user_data = Database.find_one("users", {'email': email})

        if user_data is not None:
            raise UserErrors.UserAlreadyRegisteredError(
                "User is already registered")
        if not Utils.email_is_valid():
            raise UserErrors.InvalidEmailError("Email is Invalid")

        User(email, Utils.hashed_password(password)).save_to_db()

        return True
コード例 #23
0
    def register_user(email, password):

        user_data = Database.find_one("users", {"email": email})

        if user_data is not None:
            pass
        if not Utils.email_is_valid(email):
            pass

        User(email, Utils.hash_password(password)).save_to_db()

        return True
コード例 #24
0
ファイル: user.py プロジェクト: yohncf/price-catcher
 def register_user(email, password):
     user_data = Database.find_one(UserConstants.COLLECTION,
                                   {"email": email})
     if user_data is not None:
         # Tell User they are already registered
         raise err.UserAlreadyRegister("The email you used already exists")
     if not Utils.email_is_valid(email):
         # Tell user that their email is not constructed properly
         raise err.InvalidEmailError(
             "The email does not have the right format")
     User(email, Utils.hash_pasword(password)).save_to_db()
     return True
コード例 #25
0
    def register_user(email, password):
        user_data = Database.find_one("users", {"email": email})
        if user_data is not None:
            raise UserErrors.UserAlreadyRegisteredError(
                "The User is already registered with the given Email.")
        if not Utils.email_is_valid(email):
            raise UserErrors.InvalidEmailFormatError(
                "The specified email format is incorrect.")

        User(email, Utils.hash_password(password)).save_to_db()

        return True
コード例 #26
0
    def register_user(email, password, name, age):
        query = "SELECT * FROM appusers WHERE email = \'{}\'".format(email)
        user_data = Database.find_one(query)

        if user_data is not None:
            raise UserErrors.UserAlreadyRegisteredError("The e-mail you used to register already exists.")
        if not Utils.email_is_valid(email):
            raise UserErrors.InvalidEmailError("The e-mail does not have the right format.")

        User(email, Utils.hash_password(password), name, age).save_to_db()

        return True
コード例 #27
0
    def register_user(email, password):
        user = db.find_one(UserConstraints.Collection, {'email': email})
        if user is not None:
            raise exc.UserAlreadyRegisterError(
                "The email you used to register is already exists.")
        if not Utils.email_is_valid(email):
            raise exc.InvalidEmailError(
                "The email doesn't have a valid format.")

        User(email, Utils.hash_password(password)).save_database()

        return True
コード例 #28
0
ファイル: user.py プロジェクト: bpt2017/product-pricing
    def register_user(cls, email: str, password: str) -> bool:
        if not Utils.email_is_valid(email):
            raise UserErrors.InvalidEmailError(
                'The e-mail does not have the correct format')

        try:
            user = cls.find_by_email(email)
            raise UserErrors.UserAlreadyRegisteredError(
                'The e-mail you used to register already exists.')
        except UserErrors.UserNotFoundError:
            User(email, Utils.hash_password(password)).save_to_mongo()

        return True
コード例 #29
0
ファイル: user.py プロジェクト: nupurbaghel/PriceAlertApp
    def register_user(email,password):

        user_data=Database.find_one('users',{'email':email})

        if user_data is not None:
            raise UserErrors.UserAlreadyRegisteredError("The email u entered already exists.")

        if not Utils.email_is_valid(email):
            raise UserErrors.InvalidEmailError("Your email has a invalid format.")


        User(email,Utils.hashed_password(password)).save_to_db()
        return True
コード例 #30
0
    def register_user(email, password):
        user_data = Database.find_one(UserConstant.COLLECTION,
                                      {'email': email})

        if user_data is not None:
            raise UserError.UserAlreadyHasError(
                "User is existing, please try again")
        if not Utils.email_is_valid(email):
            raise UserError.InvalidEmailError(
                "Email is invalid, please enter another email")

        User(email, Utils.hash_password(password)).save_to_mongo()

        return True
コード例 #31
0
 def register_user(email, password):
     """
     register a user using email and password
     :param email:
     :param password:
     :return: true if regsiters successfully
     """
     user_data = Database.find_one(UserConstants.COLLECTION,
                                   {"email": email})
     if user_data is not None:
         raise UserErrors.UserAlreadyRegisteredError("Email already exists")
     if not Utils.email_is_valid(email):
         raise UserErrors.InvalidEmailError("The email address is invalid")
     User(email, Utils.hash_password(password)).save()
     return True
コード例 #32
0
ファイル: user.py プロジェクト: dlautz/webtools
    def register_user(username, password, email):
        user_data = Database.find_one(UserConstants.COLLECTION,
                                      {"username": username})

        if user_data is not None:
            raise UserErrors.UserAlreadyRegisteredError(
                "Username taken.  Please choose another one.")
        if not Utils.email_is_valid(email):
            raise UserErrors.InvalidEmailError("Invalid email format.")

        User(username, Utils.hash_password(password), email).save_to_mongo()
        notebook = Notebook("inbox", username)
        notebook.save_to_mongo()

        return True
コード例 #33
0
ファイル: user.py プロジェクト: junw3i/carousell
 def register_user(email, password):
     """
     register user -- the password already comes hashed as sha-512
     :param email:
     :param password:
     :return:
     """
     user_data = Database.find_one(UserConstants.COLLECTION, {"email": email})
     if user_data is not None:
         # already registered
         raise UserErrors.UserAlreadyRegisteredError("Email already exists.")
     if not Utils.email_is_valid(email):
         # incorrect email format
         raise UserErrors.InvalidEmailError("Invalid email address.")
     User(email, Utils.hash_password(password)).save_to_db()
     return True
コード例 #34
0
ファイル: app.py プロジェクト: nupurbaghel/nupur-blog
def register_user():
    email=request.form['email']
    password=request.form['password']
    if (email is "") or (password is ""):
        flash("Please fill email id and password")
    else:
        user_data = Database.find_one('users', {'email': email})
        if not Utils.email_is_valid(email):
            flash("Your email has a invalid format.")
        elif user_data is not None:
            flash("User email id already exists!")
        else:
            User.register(email,password)
            return render_template('profile.html', email=session['email'])

    return render_template('register.html')
コード例 #35
0
def register_user():
    email = request.form['email']
    password = request.form['password']
    if (email is "") or (password is ""):
        flash("Please fill email id and password")
    else:
        user_data = Database.find_one('users', {'email': email})
        if not Utils.email_is_valid(email):
            flash("Your email has a invalid format.")
        elif user_data is not None:
            flash("User email id already exists!")
        else:
            User.register(email, password)
            return render_template('profile.html', email=session['email'])

    return render_template('register.html')
コード例 #36
0
ファイル: user.py プロジェクト: satya-komal/Price-Alerts
    def register_user(email, password):
        user_data = Database.find_one(UserConstants.COLLECTION,
                                      {"email": email})
        if user_data is not None:
            # Tell user that email already exist & can not register
            raise UserErrors.UserAlreadyRegisteredError(
                "The email is already registered")

        if not Utils.email_is_valid(email):
            #Tell user that their e-mail is not constructed properly
            raise UserErrors.InvalidEmailError(
                "The email is not in the right format")

        User(email, Utils.hash_password(password)).save_to_db()

        return True
コード例 #37
0
ファイル: user.py プロジェクト: AlinaKay/price-of-chair
    def register_user(email, password):
        """
        This method registers a user using e-mail and password.
        The password already comes hashed as sha-512.
        :param email: user's e-mail (might be invalid)
        :param password: sha512-hashed password
        :return: True if registered successfully, or False otherwise (exceptions can also be raised)
        """
        user_data = Database.find_one("users", {"email": email})

        if user_data is not None:
            raise UserErrors.UserAlreadyRegisteredError("The e-mail you used to register already exists.")
        if not Utils.email_is_valid(email):
            raise UserErrors.InvalidEmailError("The e-mail does not have the right format.")

        User(email, Utils.hash_password(password)).save_to_db()

        return True
コード例 #38
0
ファイル: user.py プロジェクト: FMGordillo/price_of_chair_web
    def register_user(email, password):
        '''
        this method register a user using email and password.
        The password already comes hashed as sha512
        :param email: user's email (might bbe invalid)
        :param password: sha512-hashed password
        :return: True if registered succefully, or False otherwise (exceptions can also be raised)
        '''

        user_data = Database.find_one(UserConstants.COLLECTION, {'email': email})
        if user_data is not None:
            raise UserErrors.UserAlreadyRegisteredError('That email already exists')
        if not Utils.email_is_valid(email):
            raise UserErrors.InvalidEmailError('The email has not the right format')

        User(email, Utils.hash_password(password)).save_to_db()

        return True
コード例 #39
0
ファイル: members.py プロジェクト: jondanson/hbc_schedule
    def register_member(first_name, last_name, email, cell_phone):
        """
        Registers a Member. The Admin will have to create
        himself as a general user for scheduling purposes.
        :param first_name:
        :param last_name:
        :param email:
        :param cell_phone:
        :return:
        :return: True if registered successfully or False if otherwise (exceptions can be raised)
        """
        member_data = Database.find_one(MemberConstants.COLLECTION, {"email": email})

        if DEBUG is False:
            if member_data is not None:
                raise MemberErrors.MemberEmailAlreadyUsed("THe email address you used is already in use.")
        if not Utils.email_is_valid(email):
            raise MemberErrors.InvalidEmailError("Not a valid email format.")

        Member(first_name, last_name, email, cell_phone).save_to_mongo()

        return True
コード例 #40
0
ファイル: user.py プロジェクト: cmj123/price-of-chair-learn
    def register_user(email, password):
        """
        This method registers a user using e-mail and password
        The password already comes hashed as sha-512
        :param email: user's email (might be invalid)
        :param password: sha512-hashed password
        :return: True if registered successfully, or False otherwise (exceptions can also be raised
        """

        user_data = Database.find_one(UserConstants.COLLECTION, {"email": email})

        if user_data is not None:
            # Tell user they are already registered
            raise UserErrors.UserAlreadyRegisteredError("The e-mail you used to register already exists")

        if not Utils.email_is_valid(email):
            # Tell user that their e-mail is not constructed properly
            raise UserErrors.InvalidEmailError("The e-mail does not have the right format")

        User(email, Utils.hash_password(password)).save_to_db()

        return True