public function getRelations()
 {
     $channelPublic = SlackChannelPublic::all();
     $channelUsers = SlackChannelUser::all();
     $channelRoles = SlackChannelRole::all();
     $channelCorporations = SlackChannelCorporation::all();
     $channelAlliances = SlackChannelAlliance::all();
     $users = User::all();
     $roles = Role::all();
     $corporations = CorporationSheet::all();
     $alliances = AllianceList::all();
     $channels = SlackChannel::all();
     return view('slackbot::list', compact('channelPublic', 'channelUsers', 'channelRoles', 'channelCorporations', 'channelAlliances', 'users', 'roles', 'corporations', 'alliances', 'channels'));
 }
Exemple #2
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     $this->line('SeAT Admin Reset Tool');
     $admin = User::firstOrNew(['name' => 'admin']);
     if (!$admin->exists) {
         $this->warn('User \'admin\' does not exist. It will be created.');
     }
     $password = null;
     while (strlen($password) < 6) {
         $password = $this->secret('Please enter a min 6 character password for the \'admin\' user');
     }
     $this->line('Setting password');
     $admin->fill(['name' => 'admin', 'email' => '*****@*****.**', 'password' => bcrypt($password)])->save();
     $this->line('Checking if \'admin\' is a super user');
     if (!$admin->has('superuser')) {
         $this->line('Searching for the \'Superuser\' role');
         $role = Role::where('title', 'Superuser')->first();
         if (!$role) {
             $this->comment('Creating the Superuser role');
             $role = Role::create(['title' => 'Superuser']);
         }
         $this->line('Checking if the Superuser role has the superuser permission');
         $role_permissions = $this->getCompleteRole($role->id)->permissions;
         if (!$role_permissions->contains('superuser')) {
             $this->comment('Adding the superuser permission to the role');
             $this->giveRolePermission($role->id, 'superuser', false);
         }
         $this->comment('Adding \'admin\' to the Superuser role');
         $this->giveUserRole($admin->id, $role->id);
     }
     $this->line('Ensuring the \'admin\' user is enabled.');
     if (!$admin->active) {
         $admin->active = true;
         $admin->save();
     }
     // Analytics
     $this->dispatch((new Analytics((new AnalyticsContainer())->set('type', 'event')->set('ec', 'admin')->set('ea', 'password_reset')->set('el', 'console')))->onQueue('medium'));
     $this->info('Done');
 }
Exemple #3
0
 /**
  * Give a user a Role
  *
  * @param $user_id
  * @param $role_id
  */
 public function giveUserRole($user_id, $role_id)
 {
     $user = UserModel::find($user_id);
     $role = RoleModel::firstOrNew(['id' => $role_id]);
     // If the role does not already have the user
     // add it.
     if (!$role->users->contains($user->id)) {
         $role->users()->save($user);
     }
     return;
 }
 public function testRole()
 {
     $permission = SlackChannelRole::where('role_id', '=', 1)->first();
     $artifact = Role::find(1);
     $this->assertEquals($artifact, $permission->role);
 }
Exemple #5
0
 /**
  * Display the specified resource.
  *
  * @param  int $id
  *
  * @return \Illuminate\Http\Response
  */
 public function getDetail($id)
 {
     $role = Role::with('users', 'permissions', 'affiliations')->where(is_numeric($id) ? 'id' : 'title', $id)->first();
     return response()->json($role);
 }