diff options
author | Chris <ccbrown112@gmail.com> | 2017-09-06 17:12:54 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-09-06 17:12:54 -0500 |
commit | 1adfd0e9be69a93c7f63bb7afc742c9fafe31aa3 (patch) | |
tree | 2766bacc1f045fa685ca3d8310cd6174d0311d09 /api4/context.go | |
parent | b84bd21089d305333fa4114b95be70f5ad94ad1b (diff) | |
download | chat-1adfd0e9be69a93c7f63bb7afc742c9fafe31aa3.tar.gz chat-1adfd0e9be69a93c7f63bb7afc742c9fafe31aa3.tar.bz2 chat-1adfd0e9be69a93c7f63bb7afc742c9fafe31aa3.zip |
app type transition (#7167)
Diffstat (limited to 'api4/context.go')
-rw-r--r-- | api4/context.go | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/api4/context.go b/api4/context.go index 2c0e54ea0..f8768b11e 100644 --- a/api4/context.go +++ b/api4/context.go @@ -20,6 +20,7 @@ import ( ) type Context struct { + App *app.App Session model.Session Params *ApiParams Err *model.AppError @@ -87,6 +88,7 @@ func (h handler) ServeHTTP(w http.ResponseWriter, r *http.Request) { l4g.Debug("%v - %v", r.Method, r.URL.Path) c := &Context{} + c.App = app.Global() c.T, _ = utils.GetTranslationsAndLocale(w, r) c.RequestId = model.NewId() c.IpAddress = utils.GetIpAddress(r) @@ -138,7 +140,7 @@ func (h handler) ServeHTTP(w http.ResponseWriter, r *http.Request) { } if len(token) != 0 { - session, err := app.GetSession(token) + session, err := app.Global().GetSession(token) if err != nil { l4g.Error(utils.T("api.context.invalid_session.error"), err.Error()) @@ -199,7 +201,7 @@ func (h handler) ServeHTTP(w http.ResponseWriter, r *http.Request) { func (c *Context) LogAudit(extraInfo string) { audit := &model.Audit{UserId: c.Session.UserId, IpAddress: c.IpAddress, Action: c.Path, ExtraInfo: extraInfo, SessionId: c.Session.Id} - if r := <-app.Srv.Store.Audit().Save(audit); r.Err != nil { + if r := <-app.Global().Srv.Store.Audit().Save(audit); r.Err != nil { c.LogError(r.Err) } } @@ -211,7 +213,7 @@ func (c *Context) LogAuditWithUserId(userId, extraInfo string) { } audit := &model.Audit{UserId: userId, IpAddress: c.IpAddress, Action: c.Path, ExtraInfo: extraInfo, SessionId: c.Session.Id} - if r := <-app.Srv.Store.Audit().Save(audit); r.Err != nil { + if r := <-app.Global().Srv.Store.Audit().Save(audit); r.Err != nil { c.LogError(r.Err) } } @@ -259,7 +261,7 @@ func (c *Context) MfaRequired() { return } - if user, err := app.GetUser(c.Session.UserId); err != nil { + if user, err := app.Global().GetUser(c.Session.UserId); err != nil { c.Err = model.NewAppError("", "api.context.session_expired.app_error", nil, "MfaRequired", http.StatusUnauthorized) return } else { |