Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
toannd96 committed Jan 6, 2024
1 parent baffc2c commit cabd6c3
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 2 deletions.
22 changes: 22 additions & 0 deletions fly.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# fly.toml app configuration file generated for theodoiweb on 2024-01-07T01:01:37+07:00
#
# See https://fly.io/docs/reference/configuration/ for information about how to use this file.
#

app = "theodoiweb"
primary_region = "sin"

[build]

[http_service]
internal_port = 8080
force_https = true
auto_stop_machines = true
auto_start_machines = true
min_machines_running = 0
processes = ["app"]

[[vm]]
cpu_kind = "shared"
cpus = 1
memory_mb = 256
3 changes: 3 additions & 0 deletions internal/app/auth/repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import (
"analytics-api/internal/pkg/security"

"time"

"github.com/sirupsen/logrus"
)

// Repository ...
Expand All @@ -29,6 +31,7 @@ func (instance *repository) InsertAuth(userID string, tokenDetails *security.Tok

errAccess := configs.Redis.Client.Set(tokenDetails.AccessUUID, userID, at.Sub(now)).Err()
if errAccess != nil {
logrus.Error("Redis set at error ", errAccess)
return errAccess
}
// errRefresh := configs.Redis.Client.Set(tokenDetails.RefreshUUID, userID, rt.Sub(now)).Err()
Expand Down
5 changes: 4 additions & 1 deletion internal/app/user/delivery_http.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"analytics-api/internal/pkg/middleware"

"github.com/gin-gonic/gin"
"github.com/sirupsen/logrus"
)

type httpDelivery struct {
Expand Down Expand Up @@ -157,12 +158,14 @@ func (instance *httpDelivery) Signin(c *gin.Context) {
// create token
token, err := security.CreateToken(user.ID)
if err != nil {
logrus.Error("Create token error ", err)
c.HTML(http.StatusInternalServerError, "500.html", gin.H{})
return
}

InsertAuthErr := instance.authUsecase.InsertAuth(user.ID, token)
if InsertAuthErr != nil {
logrus.Error("Insert auth error ", err)
c.HTML(http.StatusInternalServerError, "500.html", gin.H{})
return
}
Expand All @@ -171,7 +174,7 @@ func (instance *httpDelivery) Signin(c *gin.Context) {
// user.RefreshToken = token.RefreshToken

// create cookie for client
c.SetCookie("access_token", token.AccessToken, 86400, "/", "localhost", false, true)
c.SetCookie("access_token", token.AccessToken, 86400, "/", "theodoiweb.fly.dev", false, true)
// c.SetCookie("refresh_token", token.RefreshToken, 86400, "/", "localhost", false, true)

// c.JSON(http.StatusOK, user)
Expand Down
2 changes: 1 addition & 1 deletion web/static/js/record.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ window.recorder = {
start() {
window.recorder.runner = setInterval(function receive() {
const session = window.recorder.session.get();
fetch('http://localhost:3000/session/receive', {
fetch('https://theodoiweb.fly.dev/session/receive', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(Object.assign({}, { events: window.recorder.events }, session)),
Expand Down

0 comments on commit cabd6c3

Please sign in to comment.