Been too long since i did anything, can't remember what the hell is in all this....
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
package models
|
||||
|
||||
import "time"
|
||||
import (
|
||||
"database/sql"
|
||||
"time"
|
||||
)
|
||||
|
||||
type Syndicate struct {
|
||||
ID int
|
||||
@@ -27,3 +30,12 @@ type SyndicateInvite struct {
|
||||
Status string
|
||||
CreatedAt time.Time
|
||||
}
|
||||
|
||||
type SyndicateInviteToken struct {
|
||||
Token string
|
||||
InvitedByUserID int
|
||||
AcceptedByUserID sql.NullInt64
|
||||
CreatedAt time.Time
|
||||
ExpiresAt time.Time
|
||||
AcceptedAt sql.NullTime
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ func SetDB(database *sql.DB) {
|
||||
|
||||
func CreateUser(username, passwordHash string) error {
|
||||
_, err := db.Exec("INSERT INTO users (username, password_hash) VALUES (?, ?)", username, passwordHash)
|
||||
|
||||
//ToDo: Why is SQL in here?
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -77,11 +77,11 @@ func GetUserByID(id int) *User {
|
||||
|
||||
func LogLoginAttempt(username string, success bool) {
|
||||
_, err := db.Exec("INSERT INTO auditlog (username, success, timestamp) VALUES (?, ?, ?)",
|
||||
username, boolToInt(success), time.Now().Format(time.RFC3339))
|
||||
username, boolToInt(success), time.Now().Format(time.RFC3339)) // tOdO: SHOULD BE USING UTC
|
||||
if err != nil {
|
||||
log.Println("❌ Failed to log login:", err)
|
||||
}
|
||||
}
|
||||
} // ToDo this shouldn't be in models. Also why did i build a bool to int? just use the bool
|
||||
|
||||
func boolToInt(b bool) int {
|
||||
if b {
|
||||
|
||||
Reference in New Issue
Block a user