Add a login route to simply add characters
This commit is contained in:
29
main.go
29
main.go
@@ -70,16 +70,25 @@ func main() {
|
|||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
// Get token for character (this will add callback route temporarily)
|
mux.HandleFunc("/login", func(w http.ResponseWriter, r *http.Request) {
|
||||||
token, err := sso.GetToken(context.Background(), "PhatPhuckDave")
|
charName := r.URL.Query().Get("character")
|
||||||
if err != nil {
|
if charName == "" {
|
||||||
logger.Error("Failed to get token %v", err)
|
http.Error(w, "Missing character parameter", http.StatusBadRequest)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
logger.Info("Login requested for character %s", charName)
|
||||||
logger.Info("Got token %s", token)
|
// Trigger the auth flow (will register callback if needed)
|
||||||
// Use the token for ESI API calls
|
token, err := sso.GetToken(r.Context(), charName)
|
||||||
// The SSO handles all the complexity behind the scenes
|
if err != nil {
|
||||||
|
logger.Error("Failed to authenticate character %s: %v", charName, err)
|
||||||
|
http.Error(w, "Authentication failed", http.StatusInternalServerError)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
logger.Info("Successfully authenticated character %s", charName)
|
||||||
|
w.Header().Set("Content-Type", "text/plain")
|
||||||
|
w.WriteHeader(http.StatusOK)
|
||||||
|
w.Write([]byte("Authenticated! Access token: " + token))
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func LoadOptions() (Options, error) {
|
func LoadOptions() (Options, error) {
|
||||||
|
|||||||
Reference in New Issue
Block a user