def register(self): isdone = False while not isdone: helper.printOut(helper.printColor("HEADER",'Ok, let\'s register you. I need some data from you')) name = input('Please, write your Name?\r\n') email = input('Please, write your Email?\r\n') email=email.lower() password = input('Please, write your Password (At least 6 chars with Letters and Numbers)?\r\n') if name == 'out' or email == 'out' or password == 'out': isdone = True helper.printOut('Good Bye, I am here to server you!') elif name != '' and email !='' and password != '': emailOk = self.checkEmail(email) passOk = self.checkPassword(password) if not emailOk: helper.printError(f'Your email: {email} is not a valid email.') elif not passOk: helper.printError('You have to write a valid password (At least 6 chars with Letters and Numbers).') elif len(name)<=2: helper.printError('You have to write a valid name (At least more than 2 chars).') else: isdone = True userData = user.User('', name, email, password) userData.register() quizAction.quizzesMenu(userData) else: helper.printError('You have to file correctly your data or write out to exit (All fields are mandatory).')
def edit_record(_id): """Edit a user request record @param name: post : the name of the user @param type: post : the type of the user @return: 200: a user_request as a flask/response object \ with application/json mimetype. @raise 400: misunderstood request """ USER_REQUESTS = return_user_dictionary('user') type = USER_REQUESTS[_id]['type'] USER_REQUESTS_TYPE = return_user_dictionary(type) if _id not in USER_REQUESTS: abort(404) if not request.get_json(): abort(400) data = request.get_json(force=True) if not data.get('name'): abort(400) if not data.get('password'): abort(400) user.User(data['name'], data['password'], type, data['enabled']).add_user(_id, type) USER_REQUESTS = return_user_dictionary('user') return jsonify(USER_REQUESTS[_id]), 200
def login(self): isdone = False while not isdone: helper.printOut(helper.printColor("HEADER",'Ok, let\'s login you. I need some data from you')) email = input('Please, write your Email?\r\n') email = email.lower() password = input('Please, write your Password?\r\n') # TODO remove it if email == 'p' and password == 'p': email = '*****@*****.**' password = '******' # TODO remove it if email == 'out' or password == 'out': isdone = True helper.printOut('Good Bye, I am here to server you!') elif email != '' and password != '': emailOk = self.checkEmail(email) passOk = self.checkPassword(password) if not emailOk: helper.printError(f'Your email: {email} is not a valid email.') elif not passOk: helper.printError('You have to write a valid password (At least 6 chars with Letters and Numbers).') else: userData = user.User(0, '', email, password) isdone = userData.login() if not isdone: helper.printError('There is not any user with this email and password.', 6.0) else: quizAction.quizzesMenu(userData) else: helper.printError('You have to file correctly your data or write out to exit.')
def user_loader(username): if username not in users: return user_model = user.User() user_model.id = username return user_model
def get_all(self): query = """Select id, username, password FROM users""" con, cur = get_connection_cursor(self.name) results = cur.execute(query).fetchall() res = list() for elem in results: res.append( user.User(id=elem[0], username=elem[1], password=elem[2])) con.close() return res
def get_by_name(self, name): query = """SELECT id, username, password FROM users WHERE username = ?""" con, cur = get_connection_cursor(self.name) result = cur.execute(query, (name, )).fetchone() if result is None: con.close() return None con.close() return user.User(id=result[0], username=result[1], password=result[2])
def register(self): print("\nPerfecto, vamos a registrarte en el sistema") name = input("¿Cuál es tu nombre?: ") lastname = input("¿Cuáles son tus apellidos?: ") email = input("Introduce tu email: ") password = input("Introduce tu contraseña: ") user = model.User(name, lastname, email, password) register = user.register() if(register[0] >= 1): print(f"\nPerfecto, {register[1].name} te has registrado con el email {register[1].email}") else: print("\nError al registrarse")
def register(self): print("\n" + "**************ok***************") name = input("Please enter your name: ") email = input("Please enter your email: ") password = input("Please enter your password: "******"ok!! {register[1].name} you have registered with the email {register[1].email}" ) else: print("Something has gone wrong, you have registered incorrectly")
def login(self): print("\nBien, identifícate en el sistema") try: email = input("Introduce tu email: ") password = input("Introduce tu contraseña: ") user = model.User("", "", email, password) login = user.login() if email == login[3]: print(f"\nBienvenido {login[1]}, te has registrado en el sistema el {login[5]}") self.nextActions(login) except Exception as e: print(type(e)) print(type(e).__name__) print(f"Login incorrecto")
def request_create(self, name, password): found = self.get_by_name(name) if not (found is None): return None query = """INSERT INTO users(username, password) VALUES (?, ?)""" con, cur = get_connection_cursor(self.name) result = cur.execute(query, (name, password)) if not result.rowcount > 0: con.close() return None new_user = user.User(id=result.lastrowid, username=name, password=password) con.commit() con.close() return new_user
def login(self): print("\n" + "**************ok***************") try: email = input("Please enter your email: ") password = input("Please enter your password: "******"", email, password) login = user.indentify() if email == login[2]: print(f"\nWelcome {login[1]} !!!") self.nextActions(login) except: print("\n") print("-----Failed login-------") print("Wrong password or email.")
def check(): if flask_login.current_user.is_authenticated: return redirect(url_for("content.home")) else: try: users_accounts = users.UsersAccounts.users username = request.form["user_name"] if sha256_crypt.verify(request.form["password"], users_accounts[username]["password"]): user_model = user.User() user_model.id = username flask_login.login_user(user_model) return redirect(url_for("content.home")) else: message = "Wrong username or password" return render_template("login.html", message=message) except: message = "Wrong username or password" return render_template("login.html", message=message)