Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
D
douban-api-proxy
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
captainwong
douban-api-proxy
Commits
e09f2c9b
Commit
e09f2c9b
authored
Jan 17, 2021
by
Ozzie Isaacs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added Password change on cli
parent
4bc3c8d9
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
2 deletions
+21
-2
cli.py
cps/cli.py
+4
-1
ub.py
cps/ub.py
+17
-1
No files found.
cps/cli.py
View file @
e09f2c9b
...
...
@@ -110,7 +110,10 @@ if ipadress:
sys
.
exit
(
1
)
# handle and check user password argument
user_password
=
args
.
s
or
None
user_credentials
=
args
.
s
or
None
if
user_credentials
and
":"
not
in
user_credentials
:
print
(
"No valid username:password format"
)
sys
.
exit
(
3
)
# Handles enableing of filepicker
filepicker
=
args
.
f
or
None
cps/ub.py
View file @
e09f2c9b
...
...
@@ -43,10 +43,11 @@ from sqlalchemy import Column, ForeignKey
from
sqlalchemy
import
String
,
Integer
,
SmallInteger
,
Boolean
,
DateTime
,
Float
,
JSON
from
sqlalchemy.ext.declarative
import
declarative_base
from
sqlalchemy.orm.attributes
import
flag_modified
from
sqlalchemy.sql.expression
import
func
from
sqlalchemy.orm
import
backref
,
relationship
,
sessionmaker
,
Session
,
scoped_session
from
werkzeug.security
import
generate_password_hash
from
.
import
constants
,
logger
from
.
import
constants
,
logger
,
cli
log
=
logger
.
create
()
...
...
@@ -680,6 +681,21 @@ def init_db(app_db_path):
create_admin_user
(
session
)
create_anonymous_user
(
session
)
if
cli
.
user_credentials
:
username
,
password
=
cli
.
user_credentials
.
split
(
':'
)
user
=
session
.
query
(
User
)
.
filter
(
func
.
lower
(
User
.
nickname
)
==
username
.
lower
())
.
first
()
if
user
:
user
.
password
=
generate_password_hash
(
password
)
if
session_commit
()
==
""
:
print
(
"Password for user '{}' changed"
.
format
(
username
))
sys
.
exit
(
0
)
else
:
print
(
"Failed changing password"
)
sys
.
exit
(
3
)
else
:
print
(
"Username '{}' not valid, can't change password"
.
format
(
username
))
sys
.
exit
(
3
)
def
dispose
():
global
session
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment