Skip to content
Snippets Groups Projects
Commit b822d2e9 authored by Hinrikus Wolf's avatar Hinrikus Wolf
Browse files

Merge branch 'master' of git.fsmpi.rwth-aachen.de:redl/redeleitsystem

parents 61a56285 88acb758
Branches
Tags v2.0.23
No related merge requests found
......@@ -3,7 +3,7 @@
from flask import Flask, g, current_app, request, session, flash, redirect, url_for, abort, render_template, Response
from flask.ext.login import login_user, logout_user, login_required, current_user
from flask.ext.principal import Principal, Identity, AnonymousIdentity, identity_changed, identity_loaded, UserNeed, RoleNeed
from flask.ext.script import Manager
from flask.ext.script import Manager, prompt, prompt_pass
from flask.ext.migrate import Migrate, MigrateCommand
from passlib.hash import pbkdf2_sha256
......@@ -29,6 +29,36 @@ from modules import admin, speech
app.register_blueprint(admin.admin, url_prefix="/admin")
app.register_blueprint(speech.speech, url_prefix="/speech")
@manager.command
def addadmin():
"""Add a new administrative user to the system"""
print("Adding new administrative user:")
admin_real_name = prompt("Real name")
admin_login = prompt("Username")
admin_pass = prompt_pass("Password")
if admin_real_name is not None and admin_login is not None and admin_pass is not None:
admin_hashed_pw = pbkdf2_sha256.encrypt(admin_pass, rounds=200000, salt_size=16)
u = User(admin_real_name, admin_login, admin_hashed_pw, ["admin", "user"])
db.session.add(u)
db.session.commit(u)
else:
print("The provided data was invalid.")
@manager.command
def adduser():
"""Add a new user to the system"""
print("Adding new user:")
admin_real_name = prompt("Real name")
admin_login = prompt("Username")
admin_pass = prompt_pass("Password")
if admin_real_name is not None and admin_login is not None and admin_pass is not None:
admin_hashed_pw = pbkdf2_sha256.encrypt(admin_pass, rounds=200000, salt_size=16)
u = User(admin_real_name, admin_login, admin_hashed_pw, ["user"])
db.session.add(u)
db.session.commit(u)
else:
print("The provided data was invalid.")
@app.route("/")
def index():
if not len(db.session.query(User).all()) > 0:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment