diff --git a/app/Services/Auth/StreamChatSSOService.php b/app/Services/Auth/StreamChatSSOService.php index 37a69e51..fffd9235 100644 --- a/app/Services/Auth/StreamChatSSOService.php +++ b/app/Services/Auth/StreamChatSSOService.php @@ -11,6 +11,8 @@ * See the License for the specific language governing permissions and * limitations under the License. **/ + +use App\libs\Auth\Models\IGroupSlugs; use App\Models\Repositories\IStreamChatSSOProfileRepository; use App\Models\SSO\StreamChat\StreamChatUserProfile; use App\Services\AbstractService; @@ -97,11 +99,27 @@ final class StreamChatSSOService * user * guest * admin + * help-qa-user + * qa-user + * help-user */ $role = 'user'; - if($current_user->isSuperAdmin() || $current_user->isAdmin()){ + $isAdmin = $current_user->isSuperAdmin() || $current_user->isAdmin(); + $isChatQA = $current_user->belongToGroup(IGroupSlugs::ChatQAGroup); + $isChatHelp = $current_user->belongToGroup(IGroupSlugs::ChatHelpGroup); + + if($isAdmin){ $role = 'admin'; } + else if($isChatQA && $isChatHelp){ + $role = 'help-qa-user'; + } + else if($isChatQA){ + $role = 'qa-user'; + } + else if($isChatHelp){ + $role = 'help-user'; + } // register user on stream api $client->updateUser([ 'id' => strval($current_user->getId()), diff --git a/app/libs/Auth/Models/IGroupSlugs.php b/app/libs/Auth/Models/IGroupSlugs.php index 35cd1f1d..2ca6a1f0 100644 --- a/app/libs/Auth/Models/IGroupSlugs.php +++ b/app/libs/Auth/Models/IGroupSlugs.php @@ -24,4 +24,6 @@ interface IGroupSlugs public const OAuth2SystemScopeAdminsGroup = 'oauth2-system-scope-admins'; public const OpenIdServerAdminsGroup = 'openid-server-admins'; public const RawUsersGroup = 'raw-users'; + public const ChatQAGroup = 'chat-qa'; + public const ChatHelpGroup = 'chat-help'; } \ No newline at end of file diff --git a/database/migrations/Version20200910212216.php b/database/migrations/Version20200910212216.php new file mode 100644 index 00000000..0afa3f2c --- /dev/null +++ b/database/migrations/Version20200910212216.php @@ -0,0 +1,57 @@ +findOneBy(['name' => 'chat qa']); + if(is_null($group)){ + $group = new Group(); + $group->setName('chat qa'); + $group->setSlug(IGroupSlugs::ChatQAGroup); + $group->setDefault(false); + $group->setActive(true); + EntityManager::persist($group); + EntityManager::flush(); + } + + $group = EntityManager::getRepository(Group::class)->findOneBy(['name' => 'chat help']); + if(is_null($group)){ + $group = new Group(); + $group->setName('chat help'); + $group->setSlug(IGroupSlugs::ChatHelpGroup); + $group->setDefault(false); + $group->setActive(true); + EntityManager::persist($group); + EntityManager::flush(); + } + } + + /** + * @param Schema $schema + */ + public function down(Schema $schema) + { + + } +}