limit bumps to 1 record

This commit is contained in:
Your Name 2020-12-18 20:41:28 -05:00
parent 69e2778b3d
commit 4db3ca30a9
1 changed files with 4 additions and 3 deletions

View File

@ -7,13 +7,14 @@ import (
"encoding/base32" "encoding/base32"
"encoding/json" "encoding/json"
"fmt" "fmt"
"github.com/jmoiron/sqlx"
"golang.org/x/crypto/bcrypt"
"html/template" "html/template"
"log" "log"
"net/smtp" "net/smtp"
"strings" "strings"
"time" "time"
"github.com/jmoiron/sqlx"
"golang.org/x/crypto/bcrypt"
) )
type templates struct { type templates struct {
@ -195,7 +196,7 @@ func SaveUser(username string, d UserData) bool {
func Bump(username string, ip string) { func Bump(username string, ip string) {
username = strings.ToLower(username) username = strings.ToLower(username)
q := fmt.Sprintf("update %s_auth set lastseen=CURRENT_TIMESTAMP, lastseenip=$2 where username = $1", c.TablePrefix) q := fmt.Sprintf("update %s_auth set lastseen=CURRENT_TIMESTAMP, lastseenip=$2 where username = $1 limit 1", c.TablePrefix)
_, err := c.db.Exec(q, username, ip) _, err := c.db.Exec(q, username, ip)
if err != nil { if err != nil {
log.Printf("scsusers.Bump: Error on user bump: %s : %s\n", username, err.Error()) log.Printf("scsusers.Bump: Error on user bump: %s : %s\n", username, err.Error())