Remove remote users from the license counting and explicitly dissallow them to log in (#22582)

* Making all the counts aware of Remote users

* Disable login for remote users

* Adding tests for login remote_users error

* Adding tests for the store

* Adding frontend part of not counting remote users in the license

* Addressing PR review comment

* Adding the new ExternaUserId field to users

* Running make migrations-extract

* Running make app-layers and make gen-serialized

* Revert "Adding the new ExternaUserId field to users"

This reverts commit 12e5fd518962a16cdbdb8964179b6cd8e915f230.

* Adding GetUserByRemoteID methods

* Adding needed migration for users

* i18n-extract

* Fixing postgres increase remote user id field size migration up and down

* run make gen-serialized

* Removing migration code

* Not count remote users as part of the cloud pricing

* Add the cloud subscription when a user gets promote from remote to not-remote

* Fixing merge problems

---------

Co-authored-by: Mattermost Build <build@mattermost.com>
Этот коммит содержится в:
Jesús Espino
2023-08-14 17:54:10 +02:00
коммит произвёл GitHub
родитель 5a349873f7
Коммит 5f7482e541
19 изменённых файлов: 295 добавлений и 3 удалений

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

@@ -541,6 +541,32 @@ func (_m *UserStore) GetByEmail(email string) (*model.User, error) {
return r0, r1
}
// GetByRemoteID provides a mock function with given fields: remoteID
func (_m *UserStore) GetByRemoteID(remoteID string) (*model.User, error) {
ret := _m.Called(remoteID)
var r0 *model.User
var r1 error
if rf, ok := ret.Get(0).(func(string) (*model.User, error)); ok {
return rf(remoteID)
}
if rf, ok := ret.Get(0).(func(string) *model.User); ok {
r0 = rf(remoteID)
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(*model.User)
}
}
if rf, ok := ret.Get(1).(func(string) error); ok {
r1 = rf(remoteID)
} else {
r1 = ret.Error(1)
}
return r0, r1
}
// GetByUsername provides a mock function with given fields: username
func (_m *UserStore) GetByUsername(username string) (*model.User, error) {
ret := _m.Called(username)

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

@@ -3963,6 +3963,15 @@ func testCount(t *testing.T, ss store.Store) {
require.NoError(t, err)
defer func() { require.NoError(t, ss.User().PermanentDelete(deletedUser.Id)) }()
// Remote User
remoteId := "remote-id"
remoteUser, err := ss.User().Save(&model.User{
Email: MakeEmail(),
RemoteId: &remoteId,
})
require.NoError(t, err)
defer func() { require.NoError(t, ss.User().PermanentDelete(remoteUser.Id)) }()
// Bot
botUser, err := ss.User().Save(&model.User{
Email: MakeEmail(),
@@ -4067,6 +4076,71 @@ func testCount(t *testing.T, ss store.Store) {
},
0,
},
{
"Include remote accounts no deleted accounts and no team id",
model.UserCountOptions{
IncludeRemoteUsers: true,
IncludeDeleted: false,
TeamId: "",
},
5,
},
{
"Include delete accounts no remote accounts and no team id",
model.UserCountOptions{
IncludeRemoteUsers: false,
IncludeDeleted: true,
TeamId: "",
},
5,
},
{
"Include remote accounts and deleted accounts and no team id",
model.UserCountOptions{
IncludeRemoteUsers: true,
IncludeDeleted: true,
TeamId: "",
},
6,
},
{
"Include remote accounts and deleted accounts with existing team id",
model.UserCountOptions{
IncludeRemoteUsers: true,
IncludeDeleted: true,
TeamId: teamId,
},
4,
},
{
"Include remote accounts and deleted accounts with fake team id",
model.UserCountOptions{
IncludeRemoteUsers: true,
IncludeDeleted: true,
TeamId: model.NewId(),
},
0,
},
{
"Include remote accounts and deleted accounts with existing team id and view restrictions allowing team",
model.UserCountOptions{
IncludeRemoteUsers: true,
IncludeDeleted: true,
TeamId: teamId,
ViewRestrictions: &model.ViewUsersRestrictions{Teams: []string{teamId}},
},
4,
},
{
"Include remote accounts and deleted accounts with existing team id and view restrictions not allowing current team",
model.UserCountOptions{
IncludeRemoteUsers: true,
IncludeDeleted: true,
TeamId: teamId,
ViewRestrictions: &model.ViewUsersRestrictions{Teams: []string{model.NewId()}},
},
0,
},
{
"Filter by system admins only",
model.UserCountOptions{