/**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     Schema::table('cms_users', function (Blueprint $table) {
         $table->dropColumn('remember_token');
         $table->string('session_token', 68);
     });
     //New password for new login handler
     \Cms\Models\User::where("username", "=", "admin")->update(array("password" => md5(md5("admin"))));
 }
 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     Schema::create('cms_menus', function (Blueprint $table) {
         $table->increments('id');
         $table->timestamps();
         $table->string('slug', 255);
         $table->string('title', 255);
         $table->integer('edit_order');
     });
     \Cms\Models\Menu::create(array("slug" => "main-menu", "title" => "Main menu", "edit_order" => 10));
     Schema::create('cms_pages', function (Blueprint $table) {
         $table->increments('id');
         $table->timestamps();
         $table->dateTime('publish_start');
         $table->dateTime('publish_end');
         $table->integer('is_home');
         $table->integer('menu_id');
         $table->integer('allow_dropdown');
         $table->integer('parent_id');
         $table->string('link', 150);
         $table->string('slug', 150);
         $table->string('url', 100);
         $table->string('controller', 100);
         $table->string('template', 255);
         $table->integer('order');
         $table->integer('published');
         $table->integer('crawled');
     });
     Schema::create('cms_page_content', function (Blueprint $table) {
         $table->increments('id');
         $table->timestamps();
         $table->integer('page_id');
         $table->integer('removed');
         $table->string('title', 255);
         $table->longText('body');
     });
     Schema::create('cms_settings', function (Blueprint $table) {
         $table->increments('id');
         $table->timestamps();
         $table->string('name', 100);
         $table->string('value', 255);
     });
     Cms\Models\Setting::create(array("name" => "datepicker_format", "value" => "yyyy-MM-dd hh:mm:ss"));
     Cms\Models\Setting::create(array("name" => "extend_url_template_page", "value" => "cms::layouts.page"));
     Cms\Models\Setting::create(array("name" => "content_section_name", "value" => "content"));
     Schema::create('cms_users', function (Blueprint $table) {
         $table->increments('id');
         $table->timestamps();
         $table->string('username', 30);
         $table->string('password', 68);
         $table->smallInteger('edit');
         $table->smallInteger('admin');
         $table->string('remember_token', 100)->nullable();
     });
     \Cms\Models\User::create(array("username" => "admin", "password" => Hash::make("admin"), "edit" => 1, "admin" => 1));
 }
예제 #3
0
 /**
  * Make login attempt
  * Store to session if successful
  * @param CmsUsername $username
  * @param CmsPassword $password
  * @return bool
  */
 public static function attempt(CmsUsername $username, CmsPassword $password)
 {
     if ($user = User::where("username", "=", $username)->where("password", "=", md5(md5($password)))->first()) {
         //Add token
         $user->update(array("session_token" => md5(time())));
         //Login user
         self::loginUser($user);
         return $user;
     }
     return false;
 }
예제 #4
0
 /**
  * Removing a User must also reset all pages to user_id = 0 (put in Unsorted Pages)
  * @param $userId
  * @return mixed
  */
 public function removeUser($userId)
 {
     if ($userId == 1) {
         return Redirect::back()->with('flash_error', 'Cannot remove main user');
     }
     $user = \Cms\Models\User::find($userId);
     if ($user) {
         $user->delete();
     }
     return Redirect::route('users')->with('flash_notice', 'User removed');
 }
예제 #5
0
    // authentication failure! lets go back to the login page
    return Redirect::route('cmsLogin')->with('flash_error', 'Felaktigt användarnamn / lösenord.')->withInput();
});
Route::get('cms/logout', array('as' => 'cmsLogout', function () {
    \Cms\Models\User::logout();
    return Redirect::route('cmsLogin')->with('flash_notice', 'Du har nu loggats ut.');
}))->before('cmsAuth');
/**
 * FILTERS
 */
Route::filter('cmsAdmin', function () {
    if (\Cms\Models\User::guest()) {
        return Redirect::route('cmsLogin');
    }
    if (!\Cms\Models\User::getUser()->admin) {
        return Redirect::route('cmsLogin')->with('flash_notice', 'Du måste vara Admin för att komma åt admin.');
    }
});
Route::filter('cmsEdit', function () {
    if (\Cms\Models\User::guest()) {
        return Redirect::route('cmsLogin');
    }
    if (!\Cms\Models\User::getUser()->edit) {
        return Redirect::route('cmsLogin')->with('flash_notice', 'Du måste vara Redaktör för att komma åt edit.');
    }
});
Route::filter('cmsAuth', function () {
    if (\Cms\Models\User::guest()) {
        return Redirect::route('cmsLogin');
    }
});