[MM-48409] url mapping to configured path for cws
Этот коммит содержится в:
17
api4/user.go
17
api4/user.go
@@ -1914,6 +1914,10 @@ func login(c *Context, w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func loginCWS(c *Context, w http.ResponseWriter, r *http.Request) {
|
func loginCWS(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||||
|
campaignToURL := map[string]string{
|
||||||
|
"focalboard": "/boards",
|
||||||
|
}
|
||||||
|
|
||||||
if !c.App.Channels().License().IsCloud() {
|
if !c.App.Channels().License().IsCloud() {
|
||||||
c.Err = model.NewAppError("loginCWS", "api.user.login_cws.license.error", nil, "", http.StatusUnauthorized)
|
c.Err = model.NewAppError("loginCWS", "api.user.login_cws.license.error", nil, "", http.StatusUnauthorized)
|
||||||
return
|
return
|
||||||
@@ -1921,6 +1925,7 @@ func loginCWS(c *Context, w http.ResponseWriter, r *http.Request) {
|
|||||||
r.ParseForm()
|
r.ParseForm()
|
||||||
var loginID string
|
var loginID string
|
||||||
var token string
|
var token string
|
||||||
|
var campaign string
|
||||||
if len(r.Form) > 0 {
|
if len(r.Form) > 0 {
|
||||||
for key, value := range r.Form {
|
for key, value := range r.Form {
|
||||||
if key == "login_id" {
|
if key == "login_id" {
|
||||||
@@ -1929,6 +1934,9 @@ func loginCWS(c *Context, w http.ResponseWriter, r *http.Request) {
|
|||||||
if key == "cws_token" {
|
if key == "cws_token" {
|
||||||
token = value[0]
|
token = value[0]
|
||||||
}
|
}
|
||||||
|
if key == "utm_campaign" {
|
||||||
|
campaign = value[0]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1952,7 +1960,14 @@ func loginCWS(c *Context, w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
c.LogAuditWithUserId(user.Id, "success")
|
c.LogAuditWithUserId(user.Id, "success")
|
||||||
c.App.AttachSessionCookies(c.AppContext, w, r)
|
c.App.AttachSessionCookies(c.AppContext, w, r)
|
||||||
http.Redirect(w, r, *c.App.Config().ServiceSettings.SiteURL, http.StatusFound)
|
|
||||||
|
redirectURL := *c.App.Config().ServiceSettings.SiteURL
|
||||||
|
if len(campaign) > 0 {
|
||||||
|
if url, ok := campaignToURL[campaign]; ok {
|
||||||
|
redirectURL += url
|
||||||
|
}
|
||||||
|
}
|
||||||
|
http.Redirect(w, r, redirectURL , http.StatusFound)
|
||||||
}
|
}
|
||||||
|
|
||||||
func logout(c *Context, w http.ResponseWriter, r *http.Request) {
|
func logout(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||||
|
|||||||
@@ -63,7 +63,6 @@ func (a *App) AuthenticateUserForLogin(c *request.Context, id, loginId, password
|
|||||||
if user, err = a.GetUserForLogin(id, loginId); err != nil {
|
if user, err = a.GetUserForLogin(id, loginId); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// CWS login allow to use the one-time token to login the users when they're redirected to their
|
// CWS login allow to use the one-time token to login the users when they're redirected to their
|
||||||
// installation for the first time
|
// installation for the first time
|
||||||
if IsCWSLogin(a, cwsToken) {
|
if IsCWSLogin(a, cwsToken) {
|
||||||
|
|||||||
@@ -76,6 +76,8 @@ type FeatureFlags struct {
|
|||||||
ThreadsEverywhere bool
|
ThreadsEverywhere bool
|
||||||
|
|
||||||
GlobalDrafts bool
|
GlobalDrafts bool
|
||||||
|
|
||||||
|
UrlMappingForCWS bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *FeatureFlags) SetDefaults() {
|
func (f *FeatureFlags) SetDefaults() {
|
||||||
@@ -105,6 +107,7 @@ func (f *FeatureFlags) SetDefaults() {
|
|||||||
f.ReduceOnBoardingTaskList = false
|
f.ReduceOnBoardingTaskList = false
|
||||||
f.ThreadsEverywhere = false
|
f.ThreadsEverywhere = false
|
||||||
f.GlobalDrafts = false
|
f.GlobalDrafts = false
|
||||||
|
f.UrlMappingForCWS = false
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *FeatureFlags) Plugins() map[string]string {
|
func (f *FeatureFlags) Plugins() map[string]string {
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user