From 1adfd0e9be69a93c7f63bb7afc742c9fafe31aa3 Mon Sep 17 00:00:00 2001 From: Chris Date: Wed, 6 Sep 2017 17:12:54 -0500 Subject: app type transition (#7167) --- app/login.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'app/login.go') diff --git a/app/login.go b/app/login.go index 63f713cc8..b86df41bd 100644 --- a/app/login.go +++ b/app/login.go @@ -15,7 +15,7 @@ import ( "github.com/mssola/user_agent" ) -func AuthenticateUserForLogin(id, loginId, password, mfaToken, deviceId string, ldapOnly bool) (*model.User, *model.AppError) { +func (a *App) AuthenticateUserForLogin(id, loginId, password, mfaToken, deviceId string, ldapOnly bool) (*model.User, *model.AppError) { if len(password) == 0 { err := model.NewAppError("AuthenticateUserForLogin", "api.user.login.blank_pwd.app_error", nil, "", http.StatusBadRequest) return nil, err @@ -25,7 +25,7 @@ func AuthenticateUserForLogin(id, loginId, password, mfaToken, deviceId string, var err *model.AppError if len(id) != 0 { - if user, err = GetUser(id); err != nil { + if user, err = a.GetUser(id); err != nil { err.StatusCode = http.StatusBadRequest if einterfaces.GetMetricsInterface() != nil { einterfaces.GetMetricsInterface().IncrementLoginFail() @@ -33,7 +33,7 @@ func AuthenticateUserForLogin(id, loginId, password, mfaToken, deviceId string, return nil, err } } else { - if user, err = GetUserForLogin(loginId, ldapOnly); err != nil { + if user, err = a.GetUserForLogin(loginId, ldapOnly); err != nil { if einterfaces.GetMetricsInterface() != nil { einterfaces.GetMetricsInterface().IncrementLoginFail() } @@ -42,7 +42,7 @@ func AuthenticateUserForLogin(id, loginId, password, mfaToken, deviceId string, } // and then authenticate them - if user, err = authenticateUser(user, password, mfaToken); err != nil { + if user, err = a.authenticateUser(user, password, mfaToken); err != nil { if einterfaces.GetMetricsInterface() != nil { einterfaces.GetMetricsInterface().IncrementLoginFail() } @@ -56,7 +56,7 @@ func AuthenticateUserForLogin(id, loginId, password, mfaToken, deviceId string, return user, nil } -func DoLogin(w http.ResponseWriter, r *http.Request, user *model.User, deviceId string) (*model.Session, *model.AppError) { +func (a *App) DoLogin(w http.ResponseWriter, r *http.Request, user *model.User, deviceId string) (*model.Session, *model.AppError) { session := &model.Session{UserId: user.Id, Roles: user.GetRawRoles(), DeviceId: deviceId, IsOAuth: false} maxAge := *utils.Cfg.ServiceSettings.SessionLengthWebInDays * 60 * 60 * 24 @@ -65,7 +65,7 @@ func DoLogin(w http.ResponseWriter, r *http.Request, user *model.User, deviceId session.SetExpireInDays(*utils.Cfg.ServiceSettings.SessionLengthMobileInDays) // A special case where we logout of all other sessions with the same Id - if err := RevokeSessionsForDeviceId(user.Id, deviceId, ""); err != nil { + if err := a.RevokeSessionsForDeviceId(user.Id, deviceId, ""); err != nil { err.StatusCode = http.StatusInternalServerError return nil, err } @@ -103,7 +103,7 @@ func DoLogin(w http.ResponseWriter, r *http.Request, user *model.User, deviceId session.AddProp(model.SESSION_PROP_BROWSER, fmt.Sprintf("%v/%v", bname, bversion)) var err *model.AppError - if session, err = CreateSession(session); err != nil { + if session, err = a.CreateSession(session); err != nil { err.StatusCode = http.StatusInternalServerError return nil, err } -- cgit v1.2.3-1-g7c22