Skip to content

Commit

Permalink
Merge pull request #47 from Quaver/login-ip-timestamp
Browse files Browse the repository at this point in the history
Add timestamp when inserting login ip
  • Loading branch information
Swan authored Oct 7, 2024
2 parents d569bd8 + 9b64ee8 commit aafa1a4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
9 changes: 6 additions & 3 deletions db/login_ips.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@ package db

import (
"database/sql"
"time"
)

type LoginIp struct {
UserId int `db:"user_id"`
Ip string `db:"ip"`
UserId int `db:"user_id"`
Ip string `db:"ip"`
Timestamp int64 `db:"timestamp"`
}

// InsertLoginIpAddress Logs the ip address of a user in the database
Expand All @@ -19,7 +21,8 @@ func InsertLoginIpAddress(userId int, ip string) error {
return err
}

_, err = SQL.Exec("INSERT INTO login_ips (user_id, ip) VALUES (?, ?)", userId, ip)
_, err = SQL.Exec("INSERT INTO login_ips (user_id, ip, timestamp) VALUES (?, ?, ?)",
userId, ip, time.Now().UnixMilli())

if err != nil {
return err
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module example.com/Quaver/Z

go 1.22
go 1.23.2

require (
github.com/Philipp15b/go-steamapi v0.0.0-20210114153316-ec4fdd23b4c1
Expand Down

0 comments on commit aafa1a4

Please sign in to comment.