Commit d48cc7af authored by ale's avatar ale

Properly support login_method in the db

parent d6ae7dde
......@@ -31,17 +31,17 @@ var userlogDBStatements = map[string]string{
// optional device information).
"insert_userlog": `
INSERT INTO userlog (
username, service, log_type, message, timestamp
username, service, log_type, login_method, message, timestamp
) VALUES (
?, ?, ?, ?, ?
?, ?, ?, ?, ?, ?
)`,
"insert_userlog_with_device_info": `
INSERT INTO userlog (
username, service, log_type, message, timestamp,
username, service, log_type, login_method, message, timestamp,
device_id, device_remote_zone, device_user_agent,
device_browser, device_os, device_mobile
) VALUES (
?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?
?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?
)`,
// Database maintenance (prune old entries etc).
......@@ -55,7 +55,7 @@ var userlogDBStatements = map[string]string{
// Retrieve logs for a specific user.
"get_user_logs": `
SELECT
service, log_type, message, timestamp,
service, log_type, login_method, message, timestamp,
device_id, device_remote_zone, device_user_agent,
device_browser, device_os, device_mobile
FROM
......@@ -164,6 +164,7 @@ func (u *userlogDB) AddLog(entry *usermetadb.LogEntry) error {
entry.Username,
entry.Service,
entry.Type,
entry.LoginMethod,
entry.Message,
entry.Timestamp,
}
......@@ -213,6 +214,7 @@ func (u *userlogDB) GetUserLogs(username string, maxDays, limit int) ([]*usermet
if err := rows.Scan(
&e.Service,
&e.Type,
&e.LoginMethod,
&e.Message,
&e.Timestamp,
&e.DeviceInfo.ID,
......
......@@ -120,6 +120,7 @@ func bulkLoadTestLogs(t testing.TB, db *sql.DB) *usermetadb.LogEntry {
entry.Username,
entry.Service,
entry.Type,
entry.LoginMethod,
entry.Message,
entry.Timestamp,
entry.DeviceInfo.ID,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment