Add bump with ip
This commit is contained in:
parent
7d96d46ac8
commit
1a31bb6b30
25
main.go
25
main.go
|
@ -2,19 +2,19 @@ package scsusers
|
|||
|
||||
import (
|
||||
"bytes"
|
||||
"crypto/rand"
|
||||
"database/sql"
|
||||
"encoding/base32"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/jmoiron/sqlx"
|
||||
"golang.org/x/crypto/bcrypt"
|
||||
"html/template"
|
||||
"log"
|
||||
"crypto/rand"
|
||||
"encoding/json"
|
||||
"encoding/base32"
|
||||
"net/smtp"
|
||||
"strings"
|
||||
)
|
||||
|
||||
"github.com/jmoiron/sqlx"
|
||||
"golang.org/x/crypto/bcrypt"
|
||||
)
|
||||
|
||||
type templates struct {
|
||||
Registration *template.Template
|
||||
|
@ -182,9 +182,9 @@ func SaveUser(username string, d UserData) bool {
|
|||
|
||||
}
|
||||
|
||||
func Bump(username string) {
|
||||
q:=fmt.Sprintf("update %s_auth set lastseen=CURRENT_TIMESTAMP where username ILIKE $1", c.TablePrefix)
|
||||
_, err :=c.db.Exec(q, username)
|
||||
func Bump(username string, ip string) {
|
||||
q := fmt.Sprintf("update %s_auth set lastseen=CURRENT_TIMESTAMP, set lastseenip=$2 where username ILIKE $1", c.TablePrefix)
|
||||
_, err := c.db.Exec(q, username, ip)
|
||||
if err != nil {
|
||||
log.Printf("scsusers.Bump: Error on user bump: %s : %s\n", username, err.Error())
|
||||
}
|
||||
|
@ -195,7 +195,7 @@ type Metadata struct {
|
|||
MetaValue string `db:meta_value`
|
||||
}
|
||||
|
||||
func GetAllMeta(username string) (map[string]string) {
|
||||
func GetAllMeta(username string) map[string]string {
|
||||
meta := make(map[string]string)
|
||||
q := fmt.Sprintf(`select meta_key, meta_value
|
||||
from %s_user_metadata where
|
||||
|
@ -253,7 +253,6 @@ func SetMeta(username string, metakey string, metavalue string) {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
func RecoverByUsername(u string) {
|
||||
var username, email string
|
||||
q := fmt.Sprintf("select username, email from %s_auth where username ILIKE $1", c.TablePrefix)
|
||||
|
@ -284,7 +283,6 @@ func RecoverByEmail(e string) {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
func randBytes(n int) []byte {
|
||||
randomBytes := make([]byte, 32)
|
||||
_, err := rand.Read(randomBytes)
|
||||
|
@ -321,7 +319,6 @@ func sendRegistrationEmail(recipient, username, password string) bool {
|
|||
return true
|
||||
}
|
||||
|
||||
|
||||
func sendAlertEmail(username, recipient, message string) bool {
|
||||
data := struct {
|
||||
SiteName string
|
||||
|
@ -377,7 +374,6 @@ func sendRecoveryEmail(recipient, username, code string) bool {
|
|||
return true
|
||||
}
|
||||
|
||||
|
||||
func SetRegistrationTemplate(t string) bool {
|
||||
if len(t) != 0 {
|
||||
r, err := template.New("reg").Parse(t)
|
||||
|
@ -414,7 +410,6 @@ func SetAlertTemplate(t string) bool {
|
|||
return false
|
||||
}
|
||||
|
||||
|
||||
func SetRecoveryTemplate(t string) bool {
|
||||
if len(t) != 0 {
|
||||
r, err := template.New("recovery").Parse(t)
|
||||
|
|
Loading…
Reference in New Issue