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
e787f9dd
Commit
e787f9dd
authored
May 12, 2020
by
Ozzieisaacs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Automatic username (#1172)
parent
ec7d5b17
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
16 additions
and
8 deletions
+16
-8
admin.py
cps/admin.py
+1
-0
config_sql.py
cps/config_sql.py
+1
-0
style.css
cps/static/css/style.css
+2
-1
config_edit.html
cps/templates/config_edit.html
+1
-1
register.html
cps/templates/register.html
+2
-0
web.py
cps/web.py
+9
-6
No files found.
cps/admin.py
View file @
e787f9dd
...
@@ -635,6 +635,7 @@ def _configuration_update_helper():
...
@@ -635,6 +635,7 @@ def _configuration_update_helper():
_config_checkbox_int
(
to_save
,
"config_uploading"
)
_config_checkbox_int
(
to_save
,
"config_uploading"
)
_config_checkbox_int
(
to_save
,
"config_anonbrowse"
)
_config_checkbox_int
(
to_save
,
"config_anonbrowse"
)
_config_checkbox_int
(
to_save
,
"config_public_reg"
)
_config_checkbox_int
(
to_save
,
"config_public_reg"
)
_config_checkbox_int
(
to_save
,
"config_register_email"
)
reboot_required
|=
_config_checkbox_int
(
to_save
,
"config_kobo_sync"
)
reboot_required
|=
_config_checkbox_int
(
to_save
,
"config_kobo_sync"
)
_config_checkbox_int
(
to_save
,
"config_kobo_proxy"
)
_config_checkbox_int
(
to_save
,
"config_kobo_proxy"
)
...
...
cps/config_sql.py
View file @
e787f9dd
...
@@ -77,6 +77,7 @@ class _Settings(_Base):
...
@@ -77,6 +77,7 @@ class _Settings(_Base):
config_uploading
=
Column
(
SmallInteger
,
default
=
0
)
config_uploading
=
Column
(
SmallInteger
,
default
=
0
)
config_anonbrowse
=
Column
(
SmallInteger
,
default
=
0
)
config_anonbrowse
=
Column
(
SmallInteger
,
default
=
0
)
config_public_reg
=
Column
(
SmallInteger
,
default
=
0
)
config_public_reg
=
Column
(
SmallInteger
,
default
=
0
)
config_register_email
=
Column
(
SmallInteger
,
default
=
0
)
config_remote_login
=
Column
(
Boolean
,
default
=
False
)
config_remote_login
=
Column
(
Boolean
,
default
=
False
)
config_kobo_sync
=
Column
(
Boolean
,
default
=
False
)
config_kobo_sync
=
Column
(
Boolean
,
default
=
False
)
...
...
cps/static/css/style.css
View file @
e787f9dd
...
@@ -213,7 +213,7 @@ span.glyphicon.glyphicon-tags {
...
@@ -213,7 +213,7 @@ span.glyphicon.glyphicon-tags {
.panel-body
{
background-color
:
#f5f5f5
;
}
.panel-body
{
background-color
:
#f5f5f5
;
}
.spinner
{
margin
:
0
41%
;
}
.spinner
{
margin
:
0
41%
;
}
.spinner2
{
margin
:
0
41%
;
}
.spinner2
{
margin
:
0
41%
;
}
.intend-form
{
margin-left
:
20px
;
}
table
.bg-dark-danger
{
background-color
:
#d9534f
;
color
:
#fff
;
}
table
.bg-dark-danger
{
background-color
:
#d9534f
;
color
:
#fff
;
}
table
.bg-dark-danger
a
{
color
:
#fff
;
}
table
.bg-dark-danger
a
{
color
:
#fff
;
}
table
.bg-dark-danger
:hover
{
background-color
:
#c9302c
;
}
table
.bg-dark-danger
:hover
{
background-color
:
#c9302c
;
}
...
@@ -302,3 +302,4 @@ div.log {
...
@@ -302,3 +302,4 @@ div.log {
white-space
:
nowrap
;
white-space
:
nowrap
;
padding
:
0.5em
;
padding
:
0.5em
;
}
}
cps/templates/config_edit.html
View file @
e787f9dd
...
@@ -179,7 +179,7 @@
...
@@ -179,7 +179,7 @@
<label
for=
"config_public_reg"
>
{{_('Enable Public Registration')}}
</label>
<label
for=
"config_public_reg"
>
{{_('Enable Public Registration')}}
</label>
</div>
</div>
<div
data-related=
"register_settings"
>
<div
data-related=
"register_settings"
>
<div
class=
"form-group"
>
<div
class=
"form-group
intend-form
"
>
<input
type=
"checkbox"
id=
"config_register_email"
name=
"config_register_email"
{%
if
config
.
config_register_email
%}
checked
{%
endif
%}
>
<input
type=
"checkbox"
id=
"config_register_email"
name=
"config_register_email"
{%
if
config
.
config_register_email
%}
checked
{%
endif
%}
>
<label
for=
"config_register_email"
>
{{_('Use E-Mail as Username')}}
</label>
<label
for=
"config_register_email"
>
{{_('Use E-Mail as Username')}}
</label>
</div>
</div>
...
...
cps/templates/register.html
View file @
e787f9dd
...
@@ -3,10 +3,12 @@
...
@@ -3,10 +3,12 @@
<div
class=
"well col-sm-6 col-sm-offset-2"
>
<div
class=
"well col-sm-6 col-sm-offset-2"
>
<h2
style=
"margin-top: 0"
>
{{_('Register New Account')}}
</h2>
<h2
style=
"margin-top: 0"
>
{{_('Register New Account')}}
</h2>
<form
method=
"POST"
role=
"form"
>
<form
method=
"POST"
role=
"form"
>
{% if not config.config_register_email %}
<div
class=
"form-group required"
>
<div
class=
"form-group required"
>
<label
for=
"nickname"
>
{{_('Username')}}
</label>
<label
for=
"nickname"
>
{{_('Username')}}
</label>
<input
type=
"text"
class=
"form-control"
id=
"nickname"
name=
"nickname"
placeholder=
"{{_('Choose a username')}}"
required
>
<input
type=
"text"
class=
"form-control"
id=
"nickname"
name=
"nickname"
placeholder=
"{{_('Choose a username')}}"
required
>
</div>
</div>
{% endif %}
<div
class=
"form-group required"
>
<div
class=
"form-group required"
>
<label
for=
"email"
>
{{_('E-mail Address')}}
</label>
<label
for=
"email"
>
{{_('E-mail Address')}}
</label>
<input
type=
"email"
class=
"form-control"
id=
"email"
name=
"email"
placeholder=
"{{_('Your email address')}}"
required
>
<input
type=
"email"
class=
"form-control"
id=
"email"
name=
"email"
placeholder=
"{{_('Your email address')}}"
required
>
...
...
cps/web.py
View file @
e787f9dd
...
@@ -1285,30 +1285,33 @@ def register():
...
@@ -1285,30 +1285,33 @@ def register():
if
request
.
method
==
"POST"
:
if
request
.
method
==
"POST"
:
to_save
=
request
.
form
.
to_dict
()
to_save
=
request
.
form
.
to_dict
()
if
not
to_save
[
"nickname"
]
or
not
to_save
[
"email"
]:
if
config
.
config_register_email
:
nickname
=
to_save
[
"email"
]
else
:
nickname
=
to_save
[
"nickname"
]
if
not
nickname
or
not
to_save
[
"email"
]:
flash
(
_
(
u"Please fill out all fields!"
),
category
=
"error"
)
flash
(
_
(
u"Please fill out all fields!"
),
category
=
"error"
)
return
render_title_template
(
'register.html'
,
title
=
_
(
u"register"
),
page
=
"register"
)
return
render_title_template
(
'register.html'
,
title
=
_
(
u"register"
),
page
=
"register"
)
existing_user
=
ub
.
session
.
query
(
ub
.
User
)
.
filter
(
func
.
lower
(
ub
.
User
.
nickname
)
==
to_save
[
"nickname"
]
existing_user
=
ub
.
session
.
query
(
ub
.
User
)
.
filter
(
func
.
lower
(
ub
.
User
.
nickname
)
==
nickname
.
lower
())
.
first
()
.
lower
())
.
first
()
existing_email
=
ub
.
session
.
query
(
ub
.
User
)
.
filter
(
ub
.
User
.
email
==
to_save
[
"email"
]
.
lower
())
.
first
()
existing_email
=
ub
.
session
.
query
(
ub
.
User
)
.
filter
(
ub
.
User
.
email
==
to_save
[
"email"
]
.
lower
())
.
first
()
if
not
existing_user
and
not
existing_email
:
if
not
existing_user
and
not
existing_email
:
content
=
ub
.
User
()
content
=
ub
.
User
()
# content.password = generate_password_hash(to_save["password"])
if
check_valid_domain
(
to_save
[
"email"
]):
if
check_valid_domain
(
to_save
[
"email"
]):
content
.
nickname
=
to_save
[
"nickname"
]
content
.
nickname
=
nickname
content
.
email
=
to_save
[
"email"
]
content
.
email
=
to_save
[
"email"
]
password
=
generate_random_password
()
password
=
generate_random_password
()
content
.
password
=
generate_password_hash
(
password
)
content
.
password
=
generate_password_hash
(
password
)
content
.
role
=
config
.
config_default_role
content
.
role
=
config
.
config_default_role
content
.
sidebar_view
=
config
.
config_default_show
content
.
sidebar_view
=
config
.
config_default_show
# content.mature_content = bool(config.config_default_show & constants.MATURE_CONTENT)
try
:
try
:
ub
.
session
.
add
(
content
)
ub
.
session
.
add
(
content
)
ub
.
session
.
commit
()
ub
.
session
.
commit
()
if
feature_support
[
'oauth'
]:
if
feature_support
[
'oauth'
]:
register_user_with_oauth
(
content
)
register_user_with_oauth
(
content
)
send_registration_mail
(
to_save
[
"email"
],
to_save
[
"nickname"
]
,
password
)
send_registration_mail
(
to_save
[
"email"
],
nickname
,
password
)
except
Exception
:
except
Exception
:
ub
.
session
.
rollback
()
ub
.
session
.
rollback
()
flash
(
_
(
u"An unknown error occurred. Please try again later."
),
category
=
"error"
)
flash
(
_
(
u"An unknown error occurred. Please try again later."
),
category
=
"error"
)
...
...
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