/**
  * Use this to create the initial admin account.
  *
  * @return void
  */
 public function run()
 {
     if (App::environment() == "production") {
         $this->command->error("You are about to create a user 'admin' with admin permissions?");
         if (!$this->command->confirm('Are you sure you want to continue? [y|n]:', false)) {
             $this->command->comment("Aborting.");
             return;
         }
     }
     $user = User::where("username", "admin")->first();
     if (!is_null($user)) {
         if (!$this->command->confirm("A user with username 'admin' already exists. This user will be removed. Are you sure you want to continue? [y|n]:", false)) {
             $this->command->comment("Aborting.");
             return;
         }
         $user->delete();
     }
     $password = $this->command->secret('Enter a password:'******'Re-enter password:'******'admin' with admin permissions.");
 }
Exemple #2
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     // this relies on the permission groups getting the same autoincremented ids each time which should happen
     if (App::environment() !== 'production' || $this->command->confirm('Do you want to create the user "test" with password "password" with admin permissions? [y|n]:', false)) {
         $user = User::create(array("username" => "test", "password_hash" => Hash::make("password"), "admin" => true));
     }
     DB::transaction(function () {
         $user = User::create(array("cosign_user" => "jenkinst", "admin" => true));
         PermissionGroup::find(6)->users()->attach($user);
     });
     DB::transaction(function () {
         $user = User::create(array("cosign_user" => "moscrop", "admin" => false));
         PermissionGroup::find(1)->users()->attach($user);
         PermissionGroup::find(2)->users()->attach($user);
     });
     DB::transaction(function () {
         $user = User::create(array("cosign_user" => "cosborn", "admin" => false));
         PermissionGroup::find(1)->users()->attach($user);
         PermissionGroup::find(2)->users()->attach($user);
         PermissionGroup::find(3)->users()->attach($user);
         PermissionGroup::find(4)->users()->attach($user);
     });
     $this->command->info('CMS users created and attached to groups!');
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::statement('SET FOREIGN_KEY_CHECKS=0;');
     LiveStream::truncate();
     MediaItem::truncate();
     MediaItemComment::truncate();
     MediaItemLike::truncate();
     MediaItemLiveStream::truncate();
     MediaItemVideo::truncate();
     Permission::truncate();
     PermissionGroup::truncate();
     QualityDefinition::truncate();
     LiveStreamUri::truncate();
     Playlist::truncate();
     Show::truncate();
     SiteUser::truncate();
     User::truncate();
     VideoFile::truncate();
     DB::table("media_item_to_playlist")->truncate();
     DB::table("permission_to_group")->truncate();
     DB::table("user_to_group")->truncate();
     DB::statement('SET FOREIGN_KEY_CHECKS=1;');
     $this->command->info('Tables truncated!');
 }
Exemple #4
0
 private function authenticateUser(User $user)
 {
     // add this session id to the users list of sessions
     $userSession = new UserSession(array("session_id" => Session::getId()));
     $user->userSessions()->save($userSession);
     $this->updateLastCosignUser();
     return true;
 }
 public function postDelete()
 {
     Auth::getUser()->hasPermissionOr401(Config::get("permissions.users"), 1);
     $resp = array("success" => false);
     if (FormHelpers::hasPost("id")) {
         $id = intval($_POST["id"], 10);
         DB::transaction(function () use(&$id, &$resp) {
             $user = User::find($id);
             if (!is_null($user)) {
                 if (!$user->resultsInNoAccessibleAdminLogin(true)) {
                     if ($user->delete() === false) {
                         throw new Exception("Error deleting User.");
                     }
                     $resp['success'] = true;
                 } else {
                     $resp['msg'] = "This user cannot be deleted at the moment as it would result in no admin with access to the system.";
                 }
             }
         });
     }
     return Response::json($resp);
 }