add changes from team review
Этот коммит содержится в:
@@ -377,6 +377,7 @@ func login(c *Context, w http.ResponseWriter, r *http.Request) {
|
|||||||
user = LoginByEmail(c, w, r, props["email"], props["name"], props["password"], props["device_id"])
|
user = LoginByEmail(c, w, r, props["email"], props["name"], props["password"], props["device_id"])
|
||||||
} else {
|
} else {
|
||||||
c.Err = model.NewAppError("login", "Either user id or team name and user email must be provided", "")
|
c.Err = model.NewAppError("login", "Either user id or team name and user email must be provided", "")
|
||||||
|
c.Err.StatusCode = http.StatusForbidden
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -25,12 +25,12 @@
|
|||||||
},
|
},
|
||||||
"SSOSettings": {
|
"SSOSettings": {
|
||||||
"gitlab": {
|
"gitlab": {
|
||||||
"Allow": true,
|
"Allow": false,
|
||||||
"Secret" : "0495d3d6e528d91ba46605622a3645a8409ac5971ee287b1c3a6519fe27e6f6a",
|
"Secret" : "",
|
||||||
"Id": "87a4aeb746c67e87a54df78f6eccf85229dd30a3a797bfdb423b82ba4e749cd0",
|
"Id": "",
|
||||||
"AuthEndpoint": "http://dockerhost:8080/oauth/authorize",
|
"AuthEndpoint": "<yourgitlabdomain>/oauth/authorize",
|
||||||
"TokenEndpoint": "http://dockerhost:8080/oauth/token",
|
"TokenEndpoint": "<yourgitlabdomain>/oauth/token",
|
||||||
"UserApiEndpoint": "http://dockerhost:8080/api/v3/user"
|
"UserApiEndpoint": "<yourgitlabdomain>/api/v3/user"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"SqlSettings": {
|
"SqlSettings": {
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ type User struct {
|
|||||||
Username string `json:"username"`
|
Username string `json:"username"`
|
||||||
Password string `json:"password"`
|
Password string `json:"password"`
|
||||||
AuthData string `json:"auth_data"`
|
AuthData string `json:"auth_data"`
|
||||||
|
AuthService string `json:"auth_service"`
|
||||||
Email string `json:"email"`
|
Email string `json:"email"`
|
||||||
EmailVerified bool `json:"email_verified"`
|
EmailVerified bool `json:"email_verified"`
|
||||||
Nickname string `json:"nickname"`
|
Nickname string `json:"nickname"`
|
||||||
@@ -50,7 +51,6 @@ type User struct {
|
|||||||
NotifyProps StringMap `json:"notify_props"`
|
NotifyProps StringMap `json:"notify_props"`
|
||||||
LastPasswordUpdate int64 `json:"last_password_update"`
|
LastPasswordUpdate int64 `json:"last_password_update"`
|
||||||
LastPictureUpdate int64 `json:"last_picture_update"`
|
LastPictureUpdate int64 `json:"last_picture_update"`
|
||||||
AuthService string `json:"auth_service"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type GitLabUser struct {
|
type GitLabUser struct {
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ func NewSqlUserStore(sqlStore *SqlStore) UserStore {
|
|||||||
table.ColMap("Username").SetMaxSize(64)
|
table.ColMap("Username").SetMaxSize(64)
|
||||||
table.ColMap("Password").SetMaxSize(128)
|
table.ColMap("Password").SetMaxSize(128)
|
||||||
table.ColMap("AuthData").SetMaxSize(128)
|
table.ColMap("AuthData").SetMaxSize(128)
|
||||||
|
table.ColMap("AuthService").SetMaxSize(32)
|
||||||
table.ColMap("Email").SetMaxSize(128)
|
table.ColMap("Email").SetMaxSize(128)
|
||||||
table.ColMap("Nickname").SetMaxSize(64)
|
table.ColMap("Nickname").SetMaxSize(64)
|
||||||
table.ColMap("FirstName").SetMaxSize(64)
|
table.ColMap("FirstName").SetMaxSize(64)
|
||||||
@@ -31,7 +32,6 @@ func NewSqlUserStore(sqlStore *SqlStore) UserStore {
|
|||||||
table.ColMap("Roles").SetMaxSize(64)
|
table.ColMap("Roles").SetMaxSize(64)
|
||||||
table.ColMap("Props").SetMaxSize(4000)
|
table.ColMap("Props").SetMaxSize(4000)
|
||||||
table.ColMap("NotifyProps").SetMaxSize(2000)
|
table.ColMap("NotifyProps").SetMaxSize(2000)
|
||||||
table.ColMap("AuthService").SetMaxSize(32)
|
|
||||||
table.SetUniqueTogether("Email", "TeamId")
|
table.SetUniqueTogether("Email", "TeamId")
|
||||||
table.SetUniqueTogether("Username", "TeamId")
|
table.SetUniqueTogether("Username", "TeamId")
|
||||||
}
|
}
|
||||||
@@ -59,7 +59,7 @@ func (us SqlUserStore) UpgradeSchemaIfNeeded() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
us.CreateColumnIfNotExists("Users", "AuthService", "LastPictureUpdate", "varchar(32)", "") // for OAuth Client
|
us.CreateColumnIfNotExists("Users", "AuthService", "AuthData", "varchar(32)", "") // for OAuth Client
|
||||||
}
|
}
|
||||||
|
|
||||||
//func (ss SqlStore) CreateColumnIfNotExists(tableName string, columnName string, afterName string, colType string, defaultValue string) bool {
|
//func (ss SqlStore) CreateColumnIfNotExists(tableName string, columnName string, afterName string, colType string, defaultValue string) bool {
|
||||||
|
|||||||
@@ -476,18 +476,18 @@ func signupWithOAuth(c *api.Context, w http.ResponseWriter, r *http.Request) {
|
|||||||
props := model.MapFromJson(strings.NewReader(data))
|
props := model.MapFromJson(strings.NewReader(data))
|
||||||
|
|
||||||
if !model.ComparePassword(hash, fmt.Sprintf("%v:%v", data, utils.Cfg.ServiceSettings.InviteSalt)) {
|
if !model.ComparePassword(hash, fmt.Sprintf("%v:%v", data, utils.Cfg.ServiceSettings.InviteSalt)) {
|
||||||
c.Err = model.NewAppError("createUser", "The signup link does not appear to be valid", "")
|
c.Err = model.NewAppError("signupWithOAuth", "The signup link does not appear to be valid", "")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
t, err := strconv.ParseInt(props["time"], 10, 64)
|
t, err := strconv.ParseInt(props["time"], 10, 64)
|
||||||
if err != nil || model.GetMillis()-t > 1000*60*60*48 { // 48 hours
|
if err != nil || model.GetMillis()-t > 1000*60*60*48 { // 48 hours
|
||||||
c.Err = model.NewAppError("createUser", "The signup link has expired", "")
|
c.Err = model.NewAppError("signupWithOAuth", "The signup link has expired", "")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if team.Id != props["id"] {
|
if team.Id != props["id"] {
|
||||||
c.Err = model.NewAppError("createUser", "Invalid team name", data)
|
c.Err = model.NewAppError("signupWithOAuth", "Invalid team name", data)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user