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
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
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
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
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
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
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
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
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
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
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
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
def register_user(email, password): user_data = Database.find_one(UserConstants.COLLECTION, {"email": email}) if user_data is not None: raise UserErrors.UserAlredyRegError("User exists") if not Utils.emial_is_valid(email): raise UserErrors.InvalidEmailError("Email format is invalid") User(email, Utils.hash_password(password)).save_to_db() return True
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
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
def register_user(email,password,username): user_data = Database.find_one("users", {"email": email}) # Password in sha512 -> pbkdf if user_data is not None: raise UserErrors.UserAlreadyRegistered("The e-mail you registered already exists") if not Utils.email_is_valid(email): raise UserErrors.InvalidEmailError("The email does not have right format") User(email, Utils.hash_password(password), username).save_to_db() return True
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
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
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
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
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 you used to register already Exists") if not Utils.email_is_valid(email): raise UserErrors.InvalidEmailError("Invalid Email Address") User(email, Utils.hashed_password(password)).save_to_db() return True
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
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
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
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
def register_user(email, password): """ This method registers a user using an email and a password. The password already comes hashed as sha-512. :param email: user's email (might be valid) :param password: sha-512 hashed password :return: true if registed otherwise, false otherwise """ user_data = Database.find_one('users', {'email': email}) if user_data is not None: raise UserErrors.UserAlreadyRegisteredError( "The User already exists") if not Utils.email_is_valid(email): raise UserErrors.InvalidEmailError( "The Email does not have the right format") User(email, Utils.hash_password(password)).save_to_db() return True
def register_user(email, password): """ Register the user :param email: the email - make sure it's unique :param password: hashed digest of the password :return: true if successfully stored """ user_data = User.get_from_db_by_email(email) if user_data is not None: # raise an error if user does not exist raise user_errors.UserAlreadyExistsError('Your user already exists') if not Utils.email_is_valid(email): raise user_errors.InvalidEmailError('invalid email format') password = Utils.hash_password(password) User(email, password).save_to_db() return True
def register_user(email, password): """ This method registers users using email and password. password comes encrypt as sha512 :param email: users's email :param password: password as sha512 :return: true id registered, false otherwise """ user_data = Database.find_one(UserConstants.COLLECTION,{"email":email}) if user_data is not None: raise UserErrors.UserAlreadyRegisteredError("You are already Registered") if not Utils.email_is_valid(email): raise UserErrors.InvalidEmailError("Invalid e-mail id") User(email, Utils.hash_password(password)).save_to_db() return True
def register_user (email, password): """ Register an user with email and password password already in sha512 form, :param email: user's email :param password: sha512 hash :return: true if succesfull, false otherwise, and or exceptions """ user_data = Database.find_one(UserConstants.COLLECTION, {"email": email}) if user_data is not None: # already exists in the db raise UserErrors.UserAlreadyReegisteredErorr("Az e-mail cím már létezik az adatbázisban!") if not Utils.email_is_valid(email): raise UserErrors.InvalidEmailError("Az e-mail cím formátuma nem megfelelő ") pass User(email, Utils.hash_password(password)).save_to_db() return True
def register_user(email, password): """ Registers a user using email and password password is hashed as sha-512 :param email: :param password: :return: """ user_data = Database.find_one("users", {"email": email}) if user_data is not None: raise UserErrors.UserAlreadyRegisteredError("The e-mail already registered") if not Utils.email_is_valid(email): raise UserErrors.InvalidEmailError("Bad email format") User(email, Utils.hash_password(password))save_to_db() return True