Исправление на поле select

This commit is contained in:
2024-11-07 16:30:47 +03:00
parent f0f88f28c5
commit 2ba5b63b65
3 changed files with 10 additions and 5 deletions

View File

@@ -9,14 +9,14 @@ def auth():
return render_template('auth.html') return render_template('auth.html')
else: else:
data = request.form.to_dict() data = request.form.to_dict()
data['table'] = 'internal_users' if 'internal' in data else 'external_users' print(data)
auth_data = auth_model(data) auth_data = auth_model(data)
if auth_data.status: if auth_data.status:
session.update({ session.update({
'login': auth_data.result[0]['login'], 'login': auth_data.result[0]['login'],
'access_user': data['access'],
'role': auth_data.result[0]['user_role'], 'role': auth_data.result[0]['user_role'],
'db_config': current_app.config['db_config'], 'db_config': current_app.config['db_config'],
'access_user': 'in' if 'internal' in data else 'ext',
'permanent': True 'permanent': True
}) })
return redirect(url_for('index')) return redirect(url_for('index'))

View File

@@ -1,4 +1,4 @@
SELECT login, user_role FROM $table SELECT login, user_role FROM $access
WHERE login = '$login' WHERE login = '$login'
AND password = '$password' AND password = '$password'
LIMIT 1; LIMIT 1;

View File

@@ -13,10 +13,15 @@
<input type="text" name="login" required> <input type="text" name="login" required>
<label for="password">Пароль: </label> <label for="password">Пароль: </label>
<input type="password" name="password" required><br> <input type="password" name="password" required><br>
<p><input type="checkbox" name="internal">Внутренний пользователь</p> <p>
Уровень доступа:
<select name="access">
<option value="internal_users">Внутренний</option>
<option value="external_users">Внешний</option>
</select>
</p>
<input type="submit" value="Вход"> <input type="submit" value="Вход">
</form> </form>
</div> </div>
</body> </body>
</html> </html>