mirror of
https://github.com/esphome/esphome.git
synced 2024-11-30 02:34:12 +01:00
Fix HA addon auth using HA credentials (#3758)
This commit is contained in:
parent
60e46d485e
commit
acd0b50b40
1 changed files with 5 additions and 2 deletions
|
@ -816,14 +816,17 @@ class LoginHandler(BaseHandler):
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
headers = {
|
headers = {
|
||||||
"Authentication": f"Bearer {os.getenv('SUPERVISOR_TOKEN')}",
|
"X-Supervisor-Token": os.getenv("SUPERVISOR_TOKEN"),
|
||||||
}
|
}
|
||||||
|
|
||||||
data = {
|
data = {
|
||||||
"username": self.get_argument("username", ""),
|
"username": self.get_argument("username", ""),
|
||||||
"password": self.get_argument("password", ""),
|
"password": self.get_argument("password", ""),
|
||||||
}
|
}
|
||||||
try:
|
try:
|
||||||
req = requests.post("http://supervisor/auth", headers=headers, data=data)
|
req = requests.post(
|
||||||
|
"http://supervisor/auth", headers=headers, json=data, timeout=30
|
||||||
|
)
|
||||||
if req.status_code == 200:
|
if req.status_code == 200:
|
||||||
self.set_secure_cookie("authenticated", cookie_authenticated_yes)
|
self.set_secure_cookie("authenticated", cookie_authenticated_yes)
|
||||||
self.redirect("/")
|
self.redirect("/")
|
||||||
|
|
Loading…
Reference in a new issue