Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
H
haugebot
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
dnns01
haugebot
Commits
a6cecb72
Commit
a6cecb72
authored
4 years ago
by
dnns01
Browse files
Options
Downloads
Patches
Plain Diff
Fix login when using more than one possible hostname
parent
ee7f2b79
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
haugebot_web/static/css/styles.css
+4
-0
4 additions, 0 deletions
haugebot_web/static/css/styles.css
haugebot_web/views.py
+6
-4
6 additions, 4 deletions
haugebot_web/views.py
with
10 additions
and
4 deletions
haugebot_web/static/css/styles.css
+
4
−
0
View file @
a6cecb72
...
...
@@ -70,6 +70,10 @@ textarea {
padding
:
0
;
}
#content
>
.w3-container
:last-child
{
margin-bottom
:
16px
;
}
.tablink
{
text-align
:
center
;
}
...
...
This diff is collapsed.
Click to expand it.
haugebot_web/views.py
+
6
−
4
View file @
a6cecb72
...
...
@@ -59,8 +59,9 @@ def wusstest_du_schon_remove(request, id):
def
login
(
request
):
referer
=
request
.
headers
[
"
Referer
"
]
client_id
=
os
.
getenv
(
"
CLIENT_ID
"
)
redirect_uri
=
os
.
getenv
(
"
REDIRECT_URI
"
)
redirect_uri
=
referer
+
os
.
getenv
(
"
REDIRECT_URI
"
)
url
=
f
"
https://id.twitch.tv/oauth2/authorize?client_id=
{
client_id
}
&redirect_uri=
{
redirect_uri
}
&response_type=code&scope=moderation:read
"
return
redirect
(
url
)
...
...
@@ -71,8 +72,9 @@ def logout(request):
def
login_redirect
(
request
):
referer
=
request
.
headers
[
"
Referer
"
]
code
=
request
.
GET
.
get
(
'
code
'
)
user
=
exchange_code
(
code
)
user
=
exchange_code
(
code
,
referer
)
if
user
:
twitch_user
=
authenticate
(
request
,
user
=
user
)
twitch_user
=
list
(
twitch_user
).
pop
()
...
...
@@ -81,10 +83,10 @@ def login_redirect(request):
return
redirect
(
"
/
"
)
def
exchange_code
(
code
):
def
exchange_code
(
code
,
referer
):
client_id
=
os
.
getenv
(
"
CLIENT_ID
"
)
client_secret
=
os
.
getenv
(
"
CLIENT_SECRET
"
)
redirect_uri
=
os
.
getenv
(
"
REDIRECT_URI
"
)
redirect_uri
=
referer
+
os
.
getenv
(
"
REDIRECT_URI
"
)
url
=
f
"
https://id.twitch.tv/oauth2/token?client_id=
{
client_id
}
&client_secret=
{
client_secret
}
&code=
{
code
}
&grant_type=authorization_code&redirect_uri=
{
redirect_uri
}
"
response
=
requests
.
post
(
url
)
if
response
.
status_code
==
200
:
...
...
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