def get_user_by_name(user_login): user = db.get_user_by_login(user_login) if(len(user) == 0): return make_response(jsonify({'error': 'Invalid user Login'}), 404) else: return make_response(jsonify(user), 200)
def validation_enter(login, password): connection = database.connect() database_answer = database.get_user_by_login(connection, login) if database_answer: if database_answer[0][2] != password: return False, 'Неверный пароль' else: return False, 'Нет такого логина' return True, ''
def validation_reg(login, password, password_check): connection = database.connect() if len(database.get_user_by_login(connection, login)) > 0: return False, 'Пользователь с таким ником уже существует' if password_check != password: return False, 'Пароли не совпадают' if len(password) < 8: return False, 'Ненадежный пароль' if not match(r'[a-zA-Z0-9]', login): return False, 'Логин должен состоять только из английских букв и цифр' return True, ''
def login(): if request.method == "POST": user = database.get_user_by_login(request.form['login'], connection) print(user, request.form['psw']) if user and user[2] == request.form['psw']: userlogin = UserLogin().create(user) login_user(userlogin) return redirect(url_for('main')) flash("Неверная пара логин/пароль", "error") return render_template("login.html", title="Авторизация")
def authenticate(username, password): # Make sure at least something was entered since username/password can't be empty if username == "" or password == "": return "False" database.init("../data/database.db") print(username + "," + password) # Get a user object belonging to the entered credentials user = database.get_user_by_login(username, password) # If the user object is not null, the credentials are valid if not user: return "False" else: return "True" database.close()