fix indentation (tabs to 4 spaces) (oops)
This commit is contained in:
parent
fe4a788898
commit
23a02617f9
38 changed files with 447 additions and 447 deletions
|
@ -1,17 +1,17 @@
|
|||
package controller
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strings"
|
||||
"time"
|
||||
"database/sql"
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"arimelody-web/log"
|
||||
"arimelody-web/model"
|
||||
"arimelody-web/log"
|
||||
"arimelody-web/model"
|
||||
|
||||
"github.com/jmoiron/sqlx"
|
||||
"github.com/jmoiron/sqlx"
|
||||
)
|
||||
|
||||
const TOKEN_LEN = 64
|
||||
|
@ -33,19 +33,19 @@ func GetSessionFromRequest(app *model.AppState, r *http.Request) (*model.Session
|
|||
}
|
||||
|
||||
if session != nil {
|
||||
if session.UserAgent != r.UserAgent() {
|
||||
msg := "Session user agent mismatch. A cookie may have been hijacked!"
|
||||
if session.Account != nil {
|
||||
account, _ := GetAccountByID(app.DB, session.Account.ID)
|
||||
msg += " (Account \"" + account.Username + "\")"
|
||||
}
|
||||
app.Log.Warn(log.TYPE_ACCOUNT, msg)
|
||||
err = DeleteSession(app.DB, session.Token)
|
||||
if err != nil {
|
||||
app.Log.Warn(log.TYPE_ACCOUNT, "Failed to delete affected session")
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
if session.UserAgent != r.UserAgent() {
|
||||
msg := "Session user agent mismatch. A cookie may have been hijacked!"
|
||||
if session.Account != nil {
|
||||
account, _ := GetAccountByID(app.DB, session.Account.ID)
|
||||
msg += " (Account \"" + account.Username + "\")"
|
||||
}
|
||||
app.Log.Warn(log.TYPE_ACCOUNT, msg)
|
||||
err = DeleteSession(app.DB, session.Token)
|
||||
if err != nil {
|
||||
app.Log.Warn(log.TYPE_ACCOUNT, "Failed to delete affected session")
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue