separated user data

This commit is contained in:
Ross Mountjoy 2020-01-28 08:39:21 -05:00
parent e65f345bae
commit 984ec6ae20
31 changed files with 58 additions and 390 deletions

6
.gitignore vendored
View File

@ -115,3 +115,9 @@ dmypy.json
.directory .directory
scheduler.db scheduler.db
scheduler.db scheduler.db
.idea/
dashmachine/user_data/
dashmachine/static/user_icons
dashmachine/static/backgrounds

19
.idea/DashMachine.iml generated
View File

@ -1,19 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
<component name="Flask">
<option name="enabled" value="true" />
</component>
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="jdk" jdkName="Python 3.8 (DashMachineEnv)" jdkType="Python SDK" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
<component name="TemplatesService">
<option name="TEMPLATE_CONFIGURATION" value="Jinja2" />
<option name="TEMPLATE_FOLDERS">
<list>
<option value="$MODULE_DIR$/dashmachine/templates" />
</list>
</option>
</component>
</module>

View File

@ -1,6 +0,0 @@
<component name="InspectionProjectProfileManager">
<settings>
<option name="USE_PROJECT_PROFILE" value="false" />
<version value="1.0" />
</settings>
</component>

7
.idea/misc.xml generated
View File

@ -1,7 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="JavaScriptSettings">
<option name="languageLevel" value="ES6" />
</component>
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.8 (DashMachineEnv)" project-jdk-type="Python SDK" />
</project>

8
.idea/modules.xml generated
View File

@ -1,8 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/DashMachine.iml" filepath="$PROJECT_DIR$/.idea/DashMachine.iml" />
</modules>
</component>
</project>

6
.idea/vcs.xml generated
View File

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>

25
.idea/watcherTasks.xml generated
View File

@ -1,25 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectTasksOptions">
<TaskOptions isEnabled="true">
<option name="arguments" value="$FilePath$" />
<option name="checkSyntaxErrors" value="true" />
<option name="description" />
<option name="exitCodeBehavior" value="ERROR" />
<option name="fileExtension" value="py" />
<option name="immediateSync" value="false" />
<option name="name" value="black" />
<option name="output" value="$FilePath$" />
<option name="outputFilters">
<array />
</option>
<option name="outputFromStdout" value="false" />
<option name="program" value="/usr/bin/black" />
<option name="runOnExternalChanges" value="true" />
<option name="scopeName" value="Project Files" />
<option name="trackOnlyRoot" value="false" />
<option name="workingDir" value="$ProjectFileDir$" />
<envs />
</TaskOptions>
</component>
</project>

208
.idea/workspace.xml generated
View File

@ -1,208 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ChangeListManager">
<list default="true" id="2d244493-7af1-4307-a64a-32ac4c2ea0a0" name="Default Changelist" comment="">
<change afterPath="$PROJECT_DIR$/dashmachine/static/images/apps/bitwarden.png" afterDir="false" />
<change afterPath="$PROJECT_DIR$/dashmachine/static/images/apps/jackett.png" afterDir="false" />
<change afterPath="$PROJECT_DIR$/dashmachine/static/images/apps/radarr.png" afterDir="false" />
<change afterPath="$PROJECT_DIR$/dashmachine/static/images/apps/sonarr.png" afterDir="false" />
<change afterPath="$PROJECT_DIR$/dashmachine/static/images/backgrounds/Boy4aow.png" afterDir="false" />
<change afterPath="$PROJECT_DIR$/dashmachine/static/images/backgrounds/Hk1KgQS.png" afterDir="false" />
<change afterPath="$PROJECT_DIR$/dashmachine/static/images/backgrounds/ZtkPKMg.jpg" afterDir="false" />
<change afterPath="$PROJECT_DIR$/dashmachine/static/images/backgrounds/aodvrziifxcjmgvqhbsg.png" afterDir="false" />
<change afterPath="$PROJECT_DIR$/dashmachine/static/images/backgrounds/avbtqymfykwfcjylgqql.jpg" afterDir="false" />
<change afterPath="$PROJECT_DIR$/dashmachine/static/images/backgrounds/fns7rzzwluh11.png" afterDir="false" />
<change afterPath="$PROJECT_DIR$/dashmachine/static/images/backgrounds/glWla8v.png" afterDir="false" />
<change afterPath="$PROJECT_DIR$/dashmachine/static/images/backgrounds/mKkaVVc.gif" afterDir="false" />
<change afterPath="$PROJECT_DIR$/dashmachine/static/images/backgrounds/wallpaper-hd-of-pixel-art-and-background-powerpoint-inspirations-picture-pics-desktop.jpg" afterDir="false" />
<change afterPath="$PROJECT_DIR$/dashmachine/static/images/backgrounds/xdWDtvx.png" afterDir="false" />
<change afterPath="$PROJECT_DIR$/dashmachine/static/images/backgrounds/xsxgvgayvfvekklkvwvf.png" afterDir="false" />
<change afterPath="$PROJECT_DIR$/dashmachine/user_data/config.ini" afterDir="false" />
<change afterPath="$PROJECT_DIR$/dashmachine/user_data/site.db" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/config.ini" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/dashmachine/__init__.py" beforeDir="false" afterPath="$PROJECT_DIR$/dashmachine/__init__.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/dashmachine/main/utils.py" beforeDir="false" afterPath="$PROJECT_DIR$/dashmachine/main/utils.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/dashmachine/settings_system/routes.py" beforeDir="false" afterPath="$PROJECT_DIR$/dashmachine/settings_system/routes.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/dashmachine/site.db" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/dashmachine/sources.py" beforeDir="false" afterPath="$PROJECT_DIR$/dashmachine/sources.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/dashmachine/static/css/global/dashmachine-theme.css" beforeDir="false" afterPath="$PROJECT_DIR$/dashmachine/static/css/global/dashmachine-theme.css" afterDir="false" />
<change beforePath="$PROJECT_DIR$/dashmachine/static/css/global/dashmachine.css" beforeDir="false" afterPath="$PROJECT_DIR$/dashmachine/static/css/global/dashmachine.css" afterDir="false" />
<change beforePath="$PROJECT_DIR$/dashmachine/static/css/global/style.css" beforeDir="false" afterPath="$PROJECT_DIR$/dashmachine/static/css/global/style.css" afterDir="false" />
<change beforePath="$PROJECT_DIR$/dashmachine/static/js/global/dashmachine.js" beforeDir="false" afterPath="$PROJECT_DIR$/dashmachine/static/js/global/dashmachine.js" afterDir="false" />
<change beforePath="$PROJECT_DIR$/dashmachine/templates/main/home.html" beforeDir="false" afterPath="$PROJECT_DIR$/dashmachine/templates/main/home.html" afterDir="false" />
<change beforePath="$PROJECT_DIR$/dashmachine/templates/main/layout.html" beforeDir="false" afterPath="$PROJECT_DIR$/dashmachine/templates/main/layout.html" afterDir="false" />
<change beforePath="$PROJECT_DIR$/dashmachine/templates/settings_system/settings.html" beforeDir="false" afterPath="$PROJECT_DIR$/dashmachine/templates/settings_system/settings.html" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="Git.Settings">
<option name="PREVIOUS_COMMIT_AUTHORS">
<list>
<option value="Ross Mountjoy &lt;ross.mountjoy@gmail.com&gt;" />
</list>
</option>
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
</component>
<component name="ProjectId" id="1Vyp2sIL21mINKX6JBxGZr1SlH8" />
<component name="ProjectLevelVcsManager" settingsEditedManually="true">
<ConfirmationsSetting value="2" id="Add" />
</component>
<component name="ProjectViewState">
<option name="autoscrollFromSource" value="true" />
<option name="autoscrollToSource" value="true" />
<option name="hideEmptyMiddlePackages" value="true" />
<option name="showExcludedFiles" value="true" />
<option name="showLibraryContents" value="true" />
</component>
<component name="PropertiesComponent">
<property name="ASKED_ADD_EXTERNAL_FILES" value="true" />
<property name="NewWatcherDialog.advanced.open" value="true" />
<property name="RunOnceActivity.ShowReadmeOnStart" value="true" />
<property name="WebServerToolWindowFactoryState" value="false" />
<property name="last_opened_file_path" value="$PROJECT_DIR$/run.py" />
<property name="node.js.detected.package.eslint" value="true" />
<property name="node.js.detected.package.tslint" value="true" />
<property name="node.js.path.for.package.eslint" value="project" />
<property name="node.js.path.for.package.tslint" value="project" />
<property name="node.js.selected.package.eslint" value="(autodetect)" />
<property name="node.js.selected.package.tslint" value="(autodetect)" />
<property name="settings.editor.selected.configurable" value="watcher.settings" />
</component>
<component name="RunManager">
<configuration name="DashMachine" type="PythonConfigurationType" factoryName="Python">
<module name="DashMachine" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" />
<envs>
<env name="PYTHONUNBUFFERED" value="1" />
</envs>
<option name="SDK_HOME" value="" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
<option name="IS_MODULE_SDK" value="true" />
<option name="ADD_CONTENT_ROOTS" value="true" />
<option name="ADD_SOURCE_ROOTS" value="true" />
<EXTENSION ID="PythonCoverageRunConfigurationExtension" runner="coverage.py" />
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/run.py" />
<option name="PARAMETERS" value="" />
<option name="SHOW_COMMAND_LINE" value="false" />
<option name="EMULATE_TERMINAL" value="false" />
<option name="MODULE_MODE" value="false" />
<option name="REDIRECT_INPUT" value="false" />
<option name="INPUT_FILE" value="" />
<method v="2" />
</configuration>
</component>
<component name="ServiceViewManager">
<option name="viewStates">
<list>
<serviceView>
<treeState>
<expand />
<select />
</treeState>
</serviceView>
</list>
</option>
</component>
<component name="SvnConfiguration">
<configuration />
</component>
<component name="TaskManager">
<task active="true" id="Default" summary="Default task">
<changelist id="2d244493-7af1-4307-a64a-32ac4c2ea0a0" name="Default Changelist" comment="" />
<created>1578234985306</created>
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1578234985306</updated>
<workItem from="1578234992218" duration="34772000" />
<workItem from="1578313408670" duration="637000" />
<workItem from="1578359378893" duration="4330000" />
<workItem from="1580169186784" duration="11024000" />
</task>
<task id="LOCAL-00001" summary="1">
<created>1578313443241</created>
<option name="number" value="00001" />
<option name="presentableId" value="LOCAL-00001" />
<option name="project" value="LOCAL" />
<updated>1578313443242</updated>
</task>
<task id="LOCAL-00002" summary="1">
<created>1578364236996</created>
<option name="number" value="00002" />
<option name="presentableId" value="LOCAL-00002" />
<option name="project" value="LOCAL" />
<updated>1578364236996</updated>
</task>
<option name="localTasksCounter" value="3" />
<servers />
</component>
<component name="TypeScriptGeneratedFilesManager">
<option name="version" value="1" />
</component>
<component name="VcsManagerConfiguration">
<option name="ADD_EXTERNAL_FILES_SILENTLY" value="true" />
<MESSAGE value="1" />
<option name="LAST_COMMIT_MESSAGE" value="1" />
</component>
<component name="WindowStateProjectService">
<state x="560" y="215" key="#File_Watchers" timestamp="1578246024784">
<screen x="0" y="28" width="1920" height="1052" />
</state>
<state x="560" y="215" key="#File_Watchers/0.28.1920.1052@0.28.1920.1052" timestamp="1578246024784" />
<state x="418" y="212" key="#com.intellij.execution.impl.EditConfigurationsDialog" timestamp="1578235072139">
<screen x="0" y="28" width="1920" height="1052" />
</state>
<state x="418" y="212" key="#com.intellij.execution.impl.EditConfigurationsDialog/0.28.1920.1052@0.28.1920.1052" timestamp="1578235072139" />
<state x="515" y="145" width="879" height="818" key="CommitChangelistDialog2" timestamp="1578364236672">
<screen x="0" y="28" width="1920" height="1052" />
</state>
<state x="515" y="145" width="879" height="818" key="CommitChangelistDialog2/0.28.1920.1052@0.28.1920.1052" timestamp="1578364236672" />
<state x="554" y="321" width="810" height="703" key="EditFileWatcherDialog" timestamp="1578246021501">
<screen x="0" y="28" width="1920" height="1052" />
</state>
<state x="554" y="321" width="810" height="703" key="EditFileWatcherDialog/0.28.1920.1052@0.28.1920.1052" timestamp="1578246021501" />
<state x="748" y="311" key="FileChooserDialogImpl" timestamp="1578235103537">
<screen x="0" y="28" width="1920" height="1052" />
</state>
<state x="748" y="311" key="FileChooserDialogImpl/0.28.1920.1052@0.28.1920.1052" timestamp="1578235103537" />
<state width="1870" height="117" key="GridCell.Tab.0.bottom" timestamp="1580176048036">
<screen x="0" y="28" width="1920" height="1052" />
</state>
<state width="1870" height="117" key="GridCell.Tab.0.bottom/0.28.1920.1052@0.28.1920.1052" timestamp="1580176048036" />
<state width="1870" height="117" key="GridCell.Tab.0.center" timestamp="1580176048036">
<screen x="0" y="28" width="1920" height="1052" />
</state>
<state width="1870" height="117" key="GridCell.Tab.0.center/0.28.1920.1052@0.28.1920.1052" timestamp="1580176048036" />
<state width="1870" height="117" key="GridCell.Tab.0.left" timestamp="1580176048036">
<screen x="0" y="28" width="1920" height="1052" />
</state>
<state width="1870" height="117" key="GridCell.Tab.0.left/0.28.1920.1052@0.28.1920.1052" timestamp="1580176048036" />
<state width="1870" height="117" key="GridCell.Tab.0.right" timestamp="1580176048036">
<screen x="0" y="28" width="1920" height="1052" />
</state>
<state width="1870" height="117" key="GridCell.Tab.0.right/0.28.1920.1052@0.28.1920.1052" timestamp="1580176048036" />
<state x="446" y="188" key="SettingsEditor" timestamp="1578245994652">
<screen x="0" y="28" width="1920" height="1052" />
</state>
<state x="446" y="188" key="SettingsEditor/0.28.1920.1052@0.28.1920.1052" timestamp="1578245994652" />
<state x="560" y="289" key="Vcs.Push.Dialog.v2" timestamp="1578364242204">
<screen x="0" y="28" width="1920" height="1052" />
</state>
<state x="560" y="289" key="Vcs.Push.Dialog.v2/0.28.1920.1052@0.28.1920.1052" timestamp="1578364242204" />
<state x="525" y="224" width="869" height="660" key="find.popup" timestamp="1580178406392">
<screen x="0" y="28" width="1920" height="1052" />
</state>
<state x="525" y="224" width="869" height="660" key="find.popup/0.28.1920.1052@0.28.1920.1052" timestamp="1580178406392" />
<state x="623" y="260" width="672" height="678" key="search.everywhere.popup" timestamp="1580213161556">
<screen x="0" y="28" width="1920" height="1052" />
</state>
<state x="623" y="260" width="672" height="678" key="search.everywhere.popup/0.28.1920.1052@0.28.1920.1052" timestamp="1580213161556" />
</component>
<component name="com.intellij.coverage.CoverageDataManagerImpl">
<SUITE FILE_PATH="coverage/DashMachine$DashMachine.coverage" NAME="DashMachine Coverage Results" MODIFIED="1580169229147" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" />
</component>
</project>

View File

@ -1,5 +1,5 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
import os
from flask import Flask from flask import Flask
from flask_caching import Cache from flask_caching import Cache
from flask_sqlalchemy import SQLAlchemy from flask_sqlalchemy import SQLAlchemy
@ -10,6 +10,9 @@ from flask_avatars import Avatars
from apscheduler.jobstores.sqlalchemy import SQLAlchemyJobStore from apscheduler.jobstores.sqlalchemy import SQLAlchemyJobStore
from flask_apscheduler import APScheduler from flask_apscheduler import APScheduler
if not os.path.isdir("dashmachine/user_data"):
os.mkdir("dashmachine/user_data")
app = Flask(__name__) app = Flask(__name__)
cache = Cache(app, config={"CACHE_TYPE": "simple"}) cache = Cache(app, config={"CACHE_TYPE": "simple"})

View File

@ -0,0 +1,30 @@
import os
from shutil import copyfile
from dashmachine.paths import dashmachine_folder, images_folder
from dashmachine.main.utils import read_config
from dashmachine.user_system.models import User
from dashmachine.user_system.utils import add_edit_user
def dashmachine_init():
user_data_folder = os.path.join(dashmachine_folder, "user_data")
# create the user_data subdirectories, link them to static
user_backgrounds_folder = os.path.join(user_data_folder, "backgrounds")
if not os.path.isdir(user_backgrounds_folder):
os.mkdir(user_backgrounds_folder)
os.symlink(user_backgrounds_folder, os.path.join(images_folder, "backgrounds"))
user_icons_folder = os.path.join(user_data_folder, "user_icons")
if not os.path.isdir(user_icons_folder):
os.mkdir(user_icons_folder)
os.symlink(user_icons_folder, os.path.join(images_folder, "user_icons"))
config_file = os.path.join(user_data_folder, "config.ini")
if not os.path.exists(config_file):
copyfile("default_config.ini", config_file)
read_config()
user = User.query.first()
if not user:
add_edit_user(username="admin", password="admin")

View File

@ -1,4 +1,4 @@
from configparser import ConfigParser, DuplicateSectionError from configparser import ConfigParser
from dashmachine.main.models import Apps from dashmachine.main.models import Apps
from dashmachine.settings_system.models import Settings from dashmachine.settings_system.models import Settings
from dashmachine import db from dashmachine import db

View File

@ -11,9 +11,9 @@ def get_root_folder():
root_folder = get_root_folder() root_folder = get_root_folder()
elm_folder = os.path.join(root_folder, "dashmachine") dashmachine_folder = os.path.join(root_folder, "dashmachine")
static_folder = os.path.join(elm_folder, "static") static_folder = os.path.join(dashmachine_folder, "static")
images_folder = os.path.join(static_folder, "images") images_folder = os.path.join(static_folder, "images")

Binary file not shown.

Before

Width:  |  Height:  |  Size: 251 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 373 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 566 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 892 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 115 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 540 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 151 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 291 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 638 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 332 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 29 KiB

View File

@ -1,88 +0,0 @@
[Settings]
theme = dark
accent=orange
background=random
[Home Assistant]
prefix = https://
url = hass.wolf-house.net
icon =static/images/apps/home-assistant.png
description = Home automation software.
open_in = iframe
[Nextcloud]
prefix = https://
url = cloud.wolf-house.net
icon = static/images/apps/nextcloud.png
description = File server and sync software.
open_in = new_tab
[Wolflix]
prefix = https://
url = wolflix.wolf-house.net
icon = static/images/apps/emby.png
description = Movies and TV.
open_in = iframe
[Bitwarden]
prefix = https://
url = passwords.wolf-house.net
icon = static/images/apps/bitwarden.png
description = Password server.
open_in = this_tab
[Gitea]
prefix = https://
url = git.wolf-house.net
icon = static/images/apps/gitea.png
description = Self hosted git repo.
open_in = this_tab
[Black Pearl]
prefix = https://
url = blackpearl.wolf-house.net
icon = static/images/apps/deluge.png
description = Containerized torrent server with vpn.
open_in = iframe
[WolfPrime SSH]
prefix = https://
url = ssh.wolf-house.net
icon = static/images/apps/terminal.png
description = Terminal access for WolfPrime.
open_in = iframe
[Portainer]
prefix = https://
url = port.wolf-house.net
icon = static/images/apps/portainer.png
description = Manage docker containers.
open_in = iframe
[Nginx Proxy Manager]
prefix = https://
url = proxies.wolf-house.net
icon = static/images/apps/nginxproxymanager.png
description = Manage the nginx reverse proxy.
open_in = new_tab
[Sonarr]
prefix = https://
url = sonarr.wolf-house.net
icon = static/images/apps/sonarr.png
description = TV Shows.
open_in = iframe
[Radarr]
prefix = https://
url = radarr.wolf-house.net
icon = static/images/apps/radarr.png
description = Movies.
open_in = iframe
[Jackett]
prefix = http://
url = 192.168.39.175:9117
icon = static/images/apps/jackett.png
description = Torrent indexer.
open_in = this_tab

Binary file not shown.

View File

@ -9,13 +9,8 @@ def load_user(user_id):
class User(db.Model, UserMixin): class User(db.Model, UserMixin):
id = db.Column(db.Integer, primary_key=True) id = db.Column(db.Integer, primary_key=True)
email = db.Column(db.String(20), unique=True, nullable=False) username = db.Column(db.String(120), unique=True, nullable=False)
password = db.Column(db.String(60), nullable=False) password = db.Column(db.String(60), nullable=False)
fname = db.Column(db.String())
lname = db.Column(db.String())
phone = db.Column(db.String())
avatar = db.Column(db.String())
role = db.Column(db.String())
db.create_all() db.create_all()

View File

@ -7,9 +7,6 @@ from dashmachine.main.utils import public_route
user_system = Blueprint("user_system", __name__) user_system = Blueprint("user_system", __name__)
# *****REMINDER*****
# user accounts for this platform can only be created/edited with the
# functions in user_system.utils
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# User system routes # User system routes
@ -26,7 +23,7 @@ def login():
form = LoginForm() form = LoginForm()
if form.validate_on_submit(): if form.validate_on_submit():
user = User.query.filter_by(email=form.email.data.lower()).first() user = User.query.filter_by(username=form.email.data.lower()).first()
if user and bcrypt.check_password_hash(user.password, form.password.data): if user and bcrypt.check_password_hash(user.password, form.password.data):
login_user(user, remember=form.remember.data) login_user(user, remember=form.remember.data)

View File

@ -2,16 +2,13 @@ from dashmachine import db, bcrypt
from dashmachine.user_system.models import User from dashmachine.user_system.models import User
def add_user(email, password, fname, lname): def add_edit_user(username, password, user_id=None):
hashed_password = bcrypt.generate_password_hash(password).decode("utf-8")
user = User(email=email, fname=fname, lname=lname, password=hashed_password)
db.session.add(user)
db.session.commit()
def change_password(user_id, new_password):
user = User.query.filter_by(id=user_id).first() user = User.query.filter_by(id=user_id).first()
hashed_password = bcrypt.generate_password_hash(new_password).decode("utf-8") if not user:
user = User()
hashed_password = bcrypt.generate_password_hash(password).decode("utf-8")
user.username = username
user.password = hashed_password user.password = hashed_password
db.session.merge(user) db.session.merge(user)
db.session.commit() db.session.commit()

4
default_config.ini Normal file
View File

@ -0,0 +1,4 @@
[Settings]
theme = light
accent = orange
background = None

3
run.py
View File

@ -1,6 +1,9 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
from dashmachine import app from dashmachine import app
from dashmachine.dashmachine_init import dashmachine_init
dashmachine_init()
if __name__ == "__main__": if __name__ == "__main__":
app.run(debug=True, use_reloader=True, host="0.0.0.0", threaded=True) app.run(debug=True, use_reloader=True, host="0.0.0.0", threaded=True)