-
-
Notifications
You must be signed in to change notification settings - Fork 720
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Mercedes: generalize provider login (#2384)
- Loading branch information
Showing
19 changed files
with
243 additions
and
233 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
<!DOCTYPE html><html lang="de"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><meta name="description" content="EV Charge Controller"><meta name="author" content="andig"><meta name="apple-mobile-web-app-capable" content="yes"><meta name="apple-mobile-web-app-status-bar-style" content="black"><link rel="apple-touch-icon" sizes="180x180" href="ico/apple-touch-icon.png?[[.Version]]"><link rel="icon" type="image/png" sizes="32x32" href="ico/favicon-32x32.png?[[.Version]]"><link rel="icon" type="image/png" sizes="16x16" href="ico/favicon-16x16.png?[[.Version]]"><link rel="manifest" href="ico/site.webmanifest"><link rel="mask-icon" href="ico/safari-pinned-tab.svg?[[.Version]]" color="#18191a"><link rel="shortcut icon" href="ico/favicon.ico?[[.Version]]"><meta name="apple-mobile-web-app-title" content="evcc"><meta name="application-name" content="evcc"><meta name="msapplication-TileColor" content="#18191a"><meta name="msapplication-config" content="ico/browserconfig.xml"><meta name="theme-color" content="#18191a"><title>evcc</title><link href="css/chunk-vendors.4692b1e2.css" rel="preload" as="style"><link href="css/index.55163eb0.css" rel="preload" as="style"><link href="js/chunk-vendors.323cc329.js" rel="preload" as="script"><link href="js/index.b87bdfa4.js" rel="preload" as="script"><link href="css/chunk-vendors.4692b1e2.css" rel="stylesheet"><link href="css/index.55163eb0.css" rel="stylesheet"></head><body><script>window.evcc = { | ||
<!DOCTYPE html><html lang="de"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><meta name="description" content="EV Charge Controller"><meta name="author" content="andig"><meta name="apple-mobile-web-app-capable" content="yes"><meta name="apple-mobile-web-app-status-bar-style" content="black"><link rel="apple-touch-icon" sizes="180x180" href="ico/apple-touch-icon.png?[[.Version]]"><link rel="icon" type="image/png" sizes="32x32" href="ico/favicon-32x32.png?[[.Version]]"><link rel="icon" type="image/png" sizes="16x16" href="ico/favicon-16x16.png?[[.Version]]"><link rel="manifest" href="ico/site.webmanifest"><link rel="mask-icon" href="ico/safari-pinned-tab.svg?[[.Version]]" color="#18191a"><link rel="shortcut icon" href="ico/favicon.ico?[[.Version]]"><meta name="apple-mobile-web-app-title" content="evcc"><meta name="application-name" content="evcc"><meta name="msapplication-TileColor" content="#18191a"><meta name="msapplication-config" content="ico/browserconfig.xml"><meta name="theme-color" content="#18191a"><title>evcc</title><link href="css/chunk-vendors.4692b1e2.css" rel="preload" as="style"><link href="css/index.6aeecebf.css" rel="preload" as="style"><link href="js/chunk-vendors.323cc329.js" rel="preload" as="script"><link href="js/index.e5e2e523.js" rel="preload" as="script"><link href="css/chunk-vendors.4692b1e2.css" rel="stylesheet"><link href="css/index.6aeecebf.css" rel="stylesheet"></head><body><script>window.evcc = { | ||
version: "[[.Version]]", | ||
configured: "[[.Configured]]", | ||
commit: "[[.Commit]]", | ||
};</script><div id="app"></div><script src="js/chunk-vendors.323cc329.js"></script><script src="js/index.b87bdfa4.js"></script></body></html> | ||
};</script><div id="app"></div><script src="js/chunk-vendors.323cc329.js"></script><script src="js/index.e5e2e523.js"></script></body></html> |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package util | ||
|
||
import "sync" | ||
|
||
type AuthCollection struct { | ||
mu sync.Mutex | ||
paramC chan<- Param | ||
vehicles map[string]*AuthProvider | ||
} | ||
|
||
func NewAuthCollection(paramC chan<- Param) *AuthCollection { | ||
return &AuthCollection{ | ||
paramC: paramC, | ||
vehicles: make(map[string]*AuthProvider), | ||
} | ||
} | ||
|
||
func (ac *AuthCollection) Register(title, baseURI string) *AuthProvider { | ||
ap := &AuthProvider{ | ||
ac: ac, | ||
Uri: baseURI, | ||
} | ||
|
||
ac.mu.Lock() | ||
ac.vehicles[title] = ap | ||
ac.mu.Unlock() | ||
|
||
return ap | ||
} | ||
|
||
// publish routes and status | ||
func (ac *AuthCollection) Publish() { | ||
ac.mu.Lock() | ||
defer ac.mu.Unlock() | ||
|
||
val := struct { | ||
Vehicles map[string]*AuthProvider `json:"vehicles"` | ||
}{ | ||
Vehicles: ac.vehicles, | ||
} | ||
|
||
ac.paramC <- Param{Key: "auth", Val: val} | ||
} | ||
|
||
type AuthProvider struct { | ||
ac *AuthCollection | ||
Uri string `json:"uri"` | ||
Authenticated bool `json:"authenticated"` | ||
} | ||
|
||
func (ap *AuthProvider) Handler() chan<- bool { | ||
c := make(chan bool) | ||
|
||
go func() { | ||
for auth := range c { | ||
ap.ac.mu.Lock() | ||
ap.Authenticated = auth | ||
ap.ac.mu.Unlock() | ||
ap.ac.Publish() | ||
} | ||
}() | ||
|
||
return c | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.