Add a login route to simply add characters
This commit is contained in:
25
main.go
25
main.go
@@ -70,16 +70,25 @@ func main() {
|
||||
}
|
||||
}()
|
||||
|
||||
// Get token for character (this will add callback route temporarily)
|
||||
token, err := sso.GetToken(context.Background(), "PhatPhuckDave")
|
||||
if err != nil {
|
||||
logger.Error("Failed to get token %v", err)
|
||||
mux.HandleFunc("/login", func(w http.ResponseWriter, r *http.Request) {
|
||||
charName := r.URL.Query().Get("character")
|
||||
if charName == "" {
|
||||
http.Error(w, "Missing character parameter", http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
|
||||
logger.Info("Got token %s", token)
|
||||
// Use the token for ESI API calls
|
||||
// The SSO handles all the complexity behind the scenes
|
||||
logger.Info("Login requested for character %s", charName)
|
||||
// Trigger the auth flow (will register callback if needed)
|
||||
token, err := sso.GetToken(r.Context(), charName)
|
||||
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) {
|
||||
|
||||
Reference in New Issue
Block a user