* add request context

* move initialialization to server

* use app interface instead of global app functions

* remove app context from webconn

* cleanup

* remove duplicated services

* move context to separate package

* remove finalize init method and move content to NewServer function

* restart workers and schedulers after adding license for tests

* reflect review comments

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
Ibrahim Serdar Acikgoz
2021-05-11 13:00:44 +03:00
коммит произвёл GitHub
родитель c09369f14a
Коммит 5ea06e51d0
235 изменённых файлов: 4048 добавлений и 3819 удалений

Просмотреть файл

@@ -112,7 +112,7 @@ func completeSaml(c *Context, w http.ResponseWriter, r *http.Request) {
handleError := func(err *model.AppError) {
if isMobile && hasRedirectURL {
err.Translate(c.App.T)
err.Translate(c.AppContext.T)
utils.RenderMobileError(c.App.Config(), w, err, redirectURL)
} else {
c.Err = err
@@ -120,7 +120,7 @@ func completeSaml(c *Context, w http.ResponseWriter, r *http.Request) {
}
}
user, err := samlInterface.DoLogin(encodedXML, relayProps)
user, err := samlInterface.DoLogin(c.AppContext, encodedXML, relayProps)
if err != nil {
c.LogAudit("fail")
mlog.Error(err.Error())
@@ -137,7 +137,7 @@ func completeSaml(c *Context, w http.ResponseWriter, r *http.Request) {
switch action {
case model.OAUTH_ACTION_SIGNUP:
if teamId := relayProps["team_id"]; teamId != "" {
if err = c.App.AddUserToTeamByTeamId(teamId, user); err != nil {
if err = c.App.AddUserToTeamByTeamId(c.AppContext, teamId, user); err != nil {
c.LogErrorByCode(err)
break
}
@@ -162,7 +162,7 @@ func completeSaml(c *Context, w http.ResponseWriter, r *http.Request) {
auditRec.AddMeta("obtained_user_id", user.Id)
c.LogAuditWithUserId(user.Id, "obtained user")
err = c.App.DoLogin(w, r, user, "", isMobile, false, true)
err = c.App.DoLogin(c.AppContext, w, r, user, "", isMobile, false, true)
if err != nil {
mlog.Error(err.Error())
handleError(err)
@@ -172,14 +172,14 @@ func completeSaml(c *Context, w http.ResponseWriter, r *http.Request) {
auditRec.Success()
c.LogAuditWithUserId(user.Id, "success")
c.App.AttachSessionCookies(w, r)
c.App.AttachSessionCookies(c.AppContext, w, r)
if hasRedirectURL {
if isMobile {
// Mobile clients with redirect url support
redirectURL = utils.AppendQueryParamsToURL(redirectURL, map[string]string{
model.SESSION_COOKIE_TOKEN: c.App.Session().Token,
model.SESSION_COOKIE_CSRF: c.App.Session().GetCSRF(),
model.SESSION_COOKIE_TOKEN: c.AppContext.Session().Token,
model.SESSION_COOKIE_CSRF: c.AppContext.Session().GetCSRF(),
})
utils.RenderMobileAuthComplete(w, redirectURL)
} else {