Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
redeleitsystem
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
redl
redeleitsystem
Commits
88acb758
Commit
88acb758
authored
9 years ago
by
Robin Sonnabend
Browse files
Options
Downloads
Patches
Plain Diff
Added user commands
parent
2a053b57
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
server.py
+31
-1
31 additions, 1 deletion
server.py
with
31 additions
and
1 deletion
server.py
+
31
−
1
View file @
88acb758
...
...
@@ -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
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment