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
1de39299
Commit
1de39299
authored
Feb 24, 2019
by
Ozzieisaacs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Unicode
parent
cc3088c5
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
14 deletions
+14
-14
oauth_bb.py
cps/oauth_bb.py
+14
-14
No files found.
cps/oauth_bb.py
View file @
1de39299
...
...
@@ -142,12 +142,12 @@ if ub.oauth_support:
@
oauth_authorized
.
connect_via
(
github_blueprint
)
def
github_logged_in
(
blueprint
,
token
):
if
not
token
:
flash
(
_
(
"Failed to log in with GitHub."
),
category
=
"error"
)
flash
(
_
(
u
"Failed to log in with GitHub."
),
category
=
"error"
)
return
False
resp
=
blueprint
.
session
.
get
(
"/user"
)
if
not
resp
.
ok
:
flash
(
_
(
"Failed to fetch user info from GitHub."
),
category
=
"error"
)
flash
(
_
(
u
"Failed to fetch user info from GitHub."
),
category
=
"error"
)
return
False
github_info
=
resp
.
json
()
...
...
@@ -158,12 +158,12 @@ if ub.oauth_support:
@
oauth_authorized
.
connect_via
(
google_blueprint
)
def
google_logged_in
(
blueprint
,
token
):
if
not
token
:
flash
(
_
(
"Failed to log in with Google."
),
category
=
"error"
)
flash
(
_
(
u
"Failed to log in with Google."
),
category
=
"error"
)
return
False
resp
=
blueprint
.
session
.
get
(
"/oauth2/v2/userinfo"
)
if
not
resp
.
ok
:
flash
(
_
(
"Failed to fetch user info from Google."
),
category
=
"error"
)
flash
(
_
(
u
"Failed to fetch user info from Google."
),
category
=
"error"
)
return
False
google_info
=
resp
.
json
()
...
...
@@ -226,7 +226,7 @@ if ub.oauth_support:
if
config
.
config_public_reg
:
return
redirect
(
url_for
(
'web.register'
))
else
:
flash
(
_
(
'Public registration is not enabled'
),
category
=
"error"
)
flash
(
_
(
u"Public registration is not enabled"
),
category
=
"error"
)
redirect
(
url_for
(
redirect_url
))
except
NoResultFound
:
return
redirect
(
url_for
(
redirect_url
))
...
...
@@ -261,14 +261,14 @@ if ub.oauth_support:
ub
.
session
.
delete
(
oauth
)
ub
.
session
.
commit
()
logout_oauth_user
()
flash
(
_
(
"Unlink to
%(oauth)
s success."
,
oauth
=
oauth_check
[
provider
]),
category
=
"success"
)
flash
(
_
(
u
"Unlink to
%(oauth)
s success."
,
oauth
=
oauth_check
[
provider
]),
category
=
"success"
)
except
Exception
as
e
:
app
.
logger
.
exception
(
e
)
ub
.
session
.
rollback
()
flash
(
_
(
"Unlink to
%(oauth)
s failed."
,
oauth
=
oauth_check
[
provider
]),
category
=
"error"
)
flash
(
_
(
u
"Unlink to
%(oauth)
s failed."
,
oauth
=
oauth_check
[
provider
]),
category
=
"error"
)
except
NoResultFound
:
app
.
logger
.
warning
(
"oauth
%
s for user
%
d not fount"
%
(
provider
,
current_user
.
id
))
flash
(
_
(
"Not linked to
%(oauth)
s."
,
oauth
=
oauth_check
[
provider
]),
category
=
"error"
)
flash
(
_
(
u
"Not linked to
%(oauth)
s."
,
oauth
=
oauth_check
[
provider
]),
category
=
"error"
)
return
redirect
(
url_for
(
'web.profile'
))
...
...
@@ -276,14 +276,14 @@ if ub.oauth_support:
@
oauth_error
.
connect_via
(
github_blueprint
)
def
github_error
(
blueprint
,
error
,
error_description
=
None
,
error_uri
=
None
):
msg
=
(
"OAuth error from {name}! "
"error={error} description={description} uri={uri}"
u
"OAuth error from {name}! "
u
"error={error} description={description} uri={uri}"
)
.
format
(
name
=
blueprint
.
name
,
error
=
error
,
description
=
error_description
,
uri
=
error_uri
,
)
)
# ToDo: Translate
flash
(
msg
,
category
=
"error"
)
...
...
@@ -322,14 +322,14 @@ if ub.oauth_support:
@
oauth_error
.
connect_via
(
google_blueprint
)
def
google_error
(
blueprint
,
error
,
error_description
=
None
,
error_uri
=
None
):
msg
=
(
"OAuth error from {name}! "
"error={error} description={description} uri={uri}"
u
"OAuth error from {name}! "
u
"error={error} description={description} uri={uri}"
)
.
format
(
name
=
blueprint
.
name
,
error
=
error
,
description
=
error_description
,
uri
=
error_uri
,
)
)
# ToDo: Translate
flash
(
msg
,
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