fix
This commit is contained in:
parent
05f302465e
commit
7f74ddef2e
@ -8,6 +8,7 @@ import (
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
"os"
|
||||
|
||||
"github.com/edgedb/edgedb-go"
|
||||
"github.com/gofiber/fiber/v2"
|
||||
@ -30,9 +31,6 @@ type TokenResponse struct {
|
||||
ProviderToken string `json:"provider_token"`
|
||||
}
|
||||
|
||||
// TODO add to env
|
||||
const EDGEDB_AUTH_BASE_URL = "https://jade-hackathon--mrbounty.c-40.i.aws.edgedb.cloud/db/main/ext/auth"
|
||||
|
||||
func getGoogleUserProfile(providerToken string) (string, string, string) {
|
||||
// Fetch the discovery document
|
||||
resp, err := http.Get("https://accounts.google.com/.well-known/openid-configuration")
|
||||
@ -158,7 +156,7 @@ func handleUiSignIn(c *fiber.Ctx) error {
|
||||
Secure: true,
|
||||
})
|
||||
|
||||
return c.Redirect(fmt.Sprintf("%s/ui/signup?challenge=%s", EDGEDB_AUTH_BASE_URL, challenge), fiber.StatusTemporaryRedirect)
|
||||
return c.Redirect(fmt.Sprintf("%s/ui/signup?challenge=%s", os.Getenv("EDGEDB_AUTH_BASE_URL"), challenge), fiber.StatusTemporaryRedirect)
|
||||
}
|
||||
|
||||
func handleCallbackSignup(c *fiber.Ctx) error {
|
||||
@ -174,7 +172,7 @@ func handleCallbackSignup(c *fiber.Ctx) error {
|
||||
panic("Could not find 'verifier' in the cookie store. Is this the same user agent/browser that started the authorization flow?")
|
||||
}
|
||||
|
||||
codeExchangeURL := fmt.Sprintf("%s/token?code=%s&verifier=%s", EDGEDB_AUTH_BASE_URL, code, verifier)
|
||||
codeExchangeURL := fmt.Sprintf("%s/token?code=%s&verifier=%s", os.Getenv("EDGEDB_AUTH_BASE_URL"), code, verifier)
|
||||
resp, err := http.Get(codeExchangeURL)
|
||||
if err != nil {
|
||||
fmt.Println("Error exchanging code for access token")
|
||||
@ -281,7 +279,7 @@ func handleCallback(c *fiber.Ctx) error {
|
||||
panic("Could not find 'verifier' in the cookie store. Is this the same user agent/browser that started the authorization flow?")
|
||||
}
|
||||
|
||||
codeExchangeURL := fmt.Sprintf("%s/token?code=%s&verifier=%s", EDGEDB_AUTH_BASE_URL, code, verifier)
|
||||
codeExchangeURL := fmt.Sprintf("%s/token?code=%s&verifier=%s", os.Getenv("EDGEDB_AUTH_BASE_URL"), code, verifier)
|
||||
resp, err := http.Get(codeExchangeURL)
|
||||
if err != nil {
|
||||
fmt.Println("Error exchanging code for access token")
|
||||
|
1
Chat.go
1
Chat.go
@ -443,7 +443,6 @@ func generateLimitReachedChatHTML(c *fiber.Ctx) string {
|
||||
|
||||
clientSecretSession := CreateClientSecretSession(c)
|
||||
|
||||
// TODO Replace by live API call
|
||||
stripeTable := `
|
||||
<stripe-pricing-table
|
||||
pricing-table-id="prctbl_1PJAxDP2nW0okNQyY0Q3mbg4"
|
||||
|
@ -209,7 +209,6 @@ func Message2RequestMessage(messages []Message, context string) []RequestMessage
|
||||
}
|
||||
|
||||
func GetAvailableModels(c *fiber.Ctx) []ModelInfo {
|
||||
// TODO Filter if key is not available
|
||||
var models []ModelInfo
|
||||
err := edgeGlobalClient.WithGlobals(map[string]interface{}{"ext::auth::client_token": c.Cookies("jade-edgedb-auth-token")}).Query(edgeCtx, `
|
||||
SELECT ModelInfo {
|
||||
|
@ -29,7 +29,6 @@ func generatePricingTableChatHTML(c *fiber.Ctx) string {
|
||||
|
||||
clientSecretSession := CreateClientSecretSession(c)
|
||||
|
||||
// TODO Replace by live API call
|
||||
stripeTable := `
|
||||
<stripe-pricing-table
|
||||
pricing-table-id="prctbl_1PJAxDP2nW0okNQyY0Q3mbg4"
|
||||
@ -85,7 +84,6 @@ func CreateNewStripeCustomer(name string, email string) string {
|
||||
}
|
||||
|
||||
func IsCurrentUserSubscribed(c *fiber.Ctx) (bool, bool) {
|
||||
// TODO Change to add both plan
|
||||
var user User
|
||||
err := edgeGlobalClient.WithGlobals(map[string]interface{}{"ext::auth::client_token": c.Cookies("jade-edgedb-auth-token")}).QuerySingle(edgeCtx, "SELECT global currentUser { stripe_id } LIMIT 1;", &user)
|
||||
if err != nil {
|
||||
|
5
main.go
5
main.go
@ -166,11 +166,6 @@ func main() {
|
||||
}
|
||||
}
|
||||
|
||||
// The route to add keys, idk where to put it so it's here
|
||||
// Deserve a good REDO lol
|
||||
// I mean, look at this shit...
|
||||
// 300 lines, I'm sure it can be done in 50
|
||||
// TODO REDO and maybe find it a better place
|
||||
func addKeys(c *fiber.Ctx) error {
|
||||
openaiKey := c.FormValue("openai_key")
|
||||
anthropicKey := c.FormValue("anthropic_key")
|
||||
|
@ -22,7 +22,7 @@
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<div class="column" id="content-column">
|
||||
<div class="column" id="content-column" style="width: 100px;">
|
||||
{% if not IsPlaceholder %}
|
||||
<div class="{% if not notFlex%} is-flex {% endif %} is-align-items-start">
|
||||
<div class="message-content" style="width: 100%; overflow-y: hidden;"
|
||||
|
@ -6,7 +6,7 @@
|
||||
</figure>
|
||||
</div>
|
||||
|
||||
<div class="column" id="content-column">
|
||||
<div class="column" id="content-column" style="width: 100px;">
|
||||
<div class="is-flex is-align-items-start">
|
||||
<div class="message-content" style="width: 100%; overflow-y: hidden;">
|
||||
<div class="message-header">
|
||||
|
Loading…
x
Reference in New Issue
Block a user