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
2e37c14d
Commit
2e37c14d
authored
6 years ago
by
Krakinou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clean some comment
parent
91f09080
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
6 deletions
+4
-6
ub.py
cps/ub.py
+1
-4
web.py
cps/web.py
+3
-2
No files found.
cps/ub.py
View file @
2e37c14d
...
...
@@ -157,10 +157,8 @@ class UserBase:
@
staticmethod
def
try_login
(
username
,
password
):
conn
=
get_ldap_connection
()
print
"bind : {}"
.
format
(
config
.
config_ldap_dn
)
print
"replace :{}"
.
format
(
config
.
config_ldap_dn
.
replace
(
"
%
s"
,
username
))
conn
.
simple_bind_s
(
'uid={},ou=users,dc=yunohost,dc=org'
.
format
(
username
),
config
.
config_ldap_dn
.
replace
(
"
%
s"
,
username
),
password
)
...
...
@@ -804,7 +802,6 @@ else:
#get LDAP connection
def
get_ldap_connection
():
print
"login to LDAP server ldap://{}"
.
format
(
config
.
config_ldap_provider_url
)
conn
=
ldap
.
initialize
(
'ldap://{}'
.
format
(
config
.
config_ldap_provider_url
))
return
conn
...
...
This diff is collapsed.
Click to expand it.
cps/web.py
View file @
2e37c14d
...
...
@@ -2343,8 +2343,9 @@ def login():
if
request
.
method
==
"POST"
:
form
=
request
.
form
.
to_dict
()
user
=
ub
.
session
.
query
(
ub
.
User
)
.
filter
(
func
.
lower
(
ub
.
User
.
nickname
)
==
form
[
'username'
]
.
strip
()
.
lower
())
.
first
()
if
config
.
config_use_ldap
and
u
b
.
User
.
try_login
(
form
[
'username'
],
form
[
'password'
])
:
if
config
.
config_use_ldap
and
u
ser
:
try
:
ub
.
User
.
try_login
(
form
[
'username'
],
form
[
'password'
])
login_user
(
user
,
remember
=
True
)
flash
(
_
(
u"you are now logged in as: '
%(nickname)
s'"
,
nickname
=
user
.
nickname
),
category
=
"success"
)
return
redirect_back
(
url_for
(
"index"
))
...
...
@@ -3076,7 +3077,7 @@ def configuration_helper(origin):
#LDAP configuratop,
if
"config_use_ldap"
in
to_save
and
to_save
[
"config_use_ldap"
]
==
"on"
:
if
not
"config_ldap_provider_url"
in
to_save
or
not
"con
tent.con
fig_ldap_dn"
in
to_save
:
if
not
"config_ldap_provider_url"
in
to_save
or
not
"config_ldap_dn"
in
to_save
:
ub
.
session
.
commit
()
flash
(
_
(
u'Please enter a LDAP provider and a DN'
),
category
=
"error"
)
return
render_title_template
(
"config_edit.html"
,
content
=
config
,
origin
=
origin
,
...
...
This diff is collapsed.
Click to expand it.
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