conform service design/usage patterns
This commit is contained in:
parent
89a5fdc4e5
commit
fd3b2a0dba
13 changed files with 65 additions and 60 deletions
|
|
@ -241,7 +241,7 @@ func registerAccountHandler(app *app.AppState) http.Handler {
|
|||
return
|
||||
}
|
||||
|
||||
app.Log.Info(
|
||||
app.LogService.Info(
|
||||
model.LOG_ACCOUNT,
|
||||
"Account \"%s\" (%s) created using invite \"%s\". (%s)",
|
||||
credentials.Username,
|
||||
|
|
@ -252,7 +252,7 @@ func registerAccountHandler(app *app.AppState) http.Handler {
|
|||
|
||||
err = controller.DeleteInvite(app.DB, invite.Code)
|
||||
if err != nil {
|
||||
app.Log.Warn(model.LOG_ACCOUNT, "Failed to delete expired invite \"%s\": %v", invite.Code, err)
|
||||
app.LogService.Warn(model.LOG_ACCOUNT, "Failed to delete expired invite \"%s\": %v", invite.Code, err)
|
||||
}
|
||||
|
||||
// registration success!
|
||||
|
|
@ -332,7 +332,7 @@ func loginHandler(app *app.AppState) http.Handler {
|
|||
|
||||
err = bcrypt.CompareHashAndPassword([]byte(account.Password), []byte(password))
|
||||
if err != nil {
|
||||
app.Log.Warn(model.LOG_ACCOUNT, "\"%s\" attempted login with incorrect password. (%s)", account.Username, controller.ResolveIP(app, r))
|
||||
app.LogService.Warn(model.LOG_ACCOUNT, "\"%s\" attempted login with incorrect password. (%s)", account.Username, controller.ResolveIP(app, r))
|
||||
if locked := handleFailedLogin(app, account, r); locked {
|
||||
controller.SetSessionError(app.DB, session, "Too many failed attempts. This account is now locked.")
|
||||
} else {
|
||||
|
|
@ -366,8 +366,8 @@ func loginHandler(app *app.AppState) http.Handler {
|
|||
|
||||
// login success!
|
||||
// TODO: log login activity to user
|
||||
app.Log.Info(model.LOG_ACCOUNT, "\"%s\" logged in. (%s)", account.Username, controller.ResolveIP(app, r))
|
||||
app.Log.Warn(model.LOG_ACCOUNT, "\"%s\" does not have any TOTP methods assigned.", account.Username)
|
||||
app.LogService.Info(model.LOG_ACCOUNT, "\"%s\" logged in. (%s)", account.Username, controller.ResolveIP(app, r))
|
||||
app.LogService.Warn(model.LOG_ACCOUNT, "\"%s\" does not have any TOTP methods assigned.", account.Username)
|
||||
|
||||
err = controller.SetSessionAccount(app.DB, session, account)
|
||||
if err != nil {
|
||||
|
|
@ -420,7 +420,7 @@ func loginTOTPHandler(app *app.AppState) http.Handler {
|
|||
totpCode := r.FormValue("totp")
|
||||
|
||||
if len(totpCode) != controller.TOTP_CODE_LENGTH {
|
||||
app.Log.Warn(model.LOG_ACCOUNT, "\"%s\" failed login (Invalid TOTP). (%s)", session.AttemptAccount.Username, controller.ResolveIP(app, r))
|
||||
app.LogService.Warn(model.LOG_ACCOUNT, "\"%s\" failed login (Invalid TOTP). (%s)", session.AttemptAccount.Username, controller.ResolveIP(app, r))
|
||||
controller.SetSessionError(app.DB, session, "Invalid TOTP.")
|
||||
render()
|
||||
return
|
||||
|
|
@ -434,7 +434,7 @@ func loginTOTPHandler(app *app.AppState) http.Handler {
|
|||
return
|
||||
}
|
||||
if totpMethod == nil {
|
||||
app.Log.Warn(model.LOG_ACCOUNT, "\"%s\" failed login (Incorrect TOTP). (%s)", session.AttemptAccount.Username, controller.ResolveIP(app, r))
|
||||
app.LogService.Warn(model.LOG_ACCOUNT, "\"%s\" failed login (Incorrect TOTP). (%s)", session.AttemptAccount.Username, controller.ResolveIP(app, r))
|
||||
if locked := handleFailedLogin(app, session.AttemptAccount, r); locked {
|
||||
controller.SetSessionError(app.DB, session, "Too many failed attempts. This account is now locked.")
|
||||
controller.SetSessionAttemptAccount(app.DB, session, nil)
|
||||
|
|
@ -446,7 +446,7 @@ func loginTOTPHandler(app *app.AppState) http.Handler {
|
|||
return
|
||||
}
|
||||
|
||||
app.Log.Info(model.LOG_ACCOUNT, "\"%s\" logged in with TOTP method \"%s\". (%s)", session.AttemptAccount.Username, totpMethod.Name, controller.ResolveIP(app, r))
|
||||
app.LogService.Info(model.LOG_ACCOUNT, "\"%s\" logged in with TOTP method \"%s\". (%s)", session.AttemptAccount.Username, totpMethod.Name, controller.ResolveIP(app, r))
|
||||
|
||||
err = controller.SetSessionAccount(app.DB, session, session.AttemptAccount)
|
||||
if err != nil {
|
||||
|
|
@ -574,7 +574,7 @@ func handleFailedLogin(app *app.AppState, account *model.Account, r *http.Reques
|
|||
account.Username,
|
||||
err,
|
||||
)
|
||||
app.Log.Warn(
|
||||
app.LogService.Warn(
|
||||
model.LOG_ACCOUNT,
|
||||
"Failed to lock account \"%s\"",
|
||||
account.Username,
|
||||
|
|
@ -588,7 +588,7 @@ func handleFailedLogin(app *app.AppState, account *model.Account, r *http.Reques
|
|||
model.MAX_LOGIN_FAIL_ATTEMPTS,
|
||||
controller.ResolveIP(app, r),
|
||||
)
|
||||
app.Log.Warn(
|
||||
app.LogService.Warn(
|
||||
model.LOG_ACCOUNT,
|
||||
"Account \"%s\" was locked: %d failed login attempts (IP: %s)",
|
||||
account.Username,
|
||||
|
|
@ -606,7 +606,7 @@ func handleFailedLogin(app *app.AppState, account *model.Account, r *http.Reques
|
|||
account.Username,
|
||||
err,
|
||||
)
|
||||
app.Log.Warn(
|
||||
app.LogService.Warn(
|
||||
model.LOG_ACCOUNT,
|
||||
"Failed to increment login failures for \"%s\"",
|
||||
account.Username,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue