Skip to content

Commit

Permalink
~ | Rdy for prod
Browse files Browse the repository at this point in the history
  • Loading branch information
BolvicBolvicovic committed Nov 15, 2024
1 parent be7aebe commit 08e1a02
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 15 deletions.
32 changes: 22 additions & 10 deletions goserv/app/api/post.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,22 @@ package api
import (
"time"
"net/http"
"fmt"
"database/sql"
"crypto/rand"
"encoding/base64"
"encoding/json"
"log"
"os"

"github.com/gin-gonic/gin"
"github.com/BolvicBolvicovic/bluebeam/templates/components"
"github.com/BolvicBolvicovic/bluebeam/database"
"github.com/BolvicBolvicovic/bluebeam/analyzer"
"github.com/BolvicBolvicovic/bluebeam/criterias"
"google.golang.org/api/sheets/v4"
"google.golang.org/api/drive/v3"
"fmt"
"database/sql"
"crypto/rand"
"golang.org/x/crypto/bcrypt"
"encoding/base64"
"encoding/json"
"log"
)

func ClearSessionKey(username string, c *gin.Context) error {
Expand All @@ -29,8 +31,13 @@ SET
WHERE
username = ?;
`
c.SetCookie("bluebeam_username", "", -1, "/", "localhost", true, true)
c.SetCookie("bluebeam_session_key", "", -1, "/", "localhost", true, true)
if os.Getenv("MODE") == "dev" {
c.SetCookie("bluebeam_username", "", -1, "/", "localhost", true, true)
c.SetCookie("bluebeam_session_key", "", -1, "/", "localhost", true, true)
} else {
c.SetCookie("bluebeam_username", "", -1, "/", "bluebeam.dev", true, true)
c.SetCookie("bluebeam_session_key", "", -1, "/", "bluebeam.dev", true, true)
}
_, err := database.Db.Exec(query, username)
return err
}
Expand Down Expand Up @@ -393,8 +400,13 @@ WHERE
c.JSON(http.StatusInternalServerError, gin.H{"error": "Error updating key session"})
return
}
c.SetCookie("bluebeam_username", user.Username, 86400, "/", "localhost", true, true)
c.SetCookie("bluebeam_session_key", strkey, 86400, "/", "localhost", true, true)
if os.Getenv("MODE") == "dev" {
c.SetCookie("bluebeam_username", user.Username, 86400, "/", "localhost", true, true)
c.SetCookie("bluebeam_session_key", strkey, 86400, "/", "localhost", true, true)
} else {
c.SetCookie("bluebeam_username", user.Username, 86400, "/", "bluebeam.dev", true, true)
c.SetCookie("bluebeam_session_key", strkey, 86400, "/", "bluebeam.dev", true, true)
}
c.JSON(http.StatusAccepted, gin.H{"message": "connected!"})
}
}
Expand Down
8 changes: 4 additions & 4 deletions goserv/app/templates/pages/dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ function sendCriterias(event) {
reader.onload = function() {
const features = JSON.parse(reader.result);

fetch('https://localhost/criterias', {
fetch('/criterias', {
method: 'POST',
mode: 'cors',
headers: { 'Content-Type': 'application/json' },
Expand Down Expand Up @@ -302,7 +302,7 @@ function updateEmail(event) {
const email = document.getElementById("email").value;
const emailStatus = document.getElementById("emailStatus");

fetch('https://localhost/updateEmail', {
fetch('/updateEmail', {
method: 'PATCH',
mode: 'cors',
headers: { 'Content-Type': 'application/json' },
Expand Down Expand Up @@ -335,7 +335,7 @@ function updateAPIKey(event) {
const apiKey = document.getElementById("apiKey").value;
const apiKeyStatus = document.getElementById("apiKeyStatus");
const api = apiKey.indexOf("-") == -1 ? "gemini" : "openai";
fetch('https://localhost/updateAPIKey', {
fetch('/updateAPIKey', {
method: 'PATCH',
mode: 'cors',
headers: { 'Content-Type': 'application/json' },
Expand Down Expand Up @@ -478,7 +478,7 @@ async function pickerCallback(data) {
return obj;
});

fetch('https://localhost/criterias', {
fetch('/criterias', {
method: 'POST',
mode: 'cors',
headers: { 'Content-Type': 'application/json' },
Expand Down
2 changes: 1 addition & 1 deletion goserv/app/templates/pages/login_page.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
if (data.error) {
messageOutput.innerHTML = data.error;
} else {
window.location.href = "https://localhost";
window.location.href = "/";
}
})
.catch(error => {
Expand Down

0 comments on commit 08e1a02

Please sign in to comment.