diff --git a/app/Http/Controllers/Auth/LoginController.php b/app/Http/Controllers/Auth/LoginController.php index 2fce4158..6a1e1efd 100644 --- a/app/Http/Controllers/Auth/LoginController.php +++ b/app/Http/Controllers/Auth/LoginController.php @@ -93,7 +93,10 @@ class LoginController extends Controller public function autologin($uuid) { - + $user = User::where('autologin', $uuid)->first(); + Auth::login($user); + session(['current_user' => $user]); + return redirect()->route('dash'); } /** diff --git a/app/Http/Controllers/SettingsController.php b/app/Http/Controllers/SettingsController.php index f44d921c..24d4c413 100644 --- a/app/Http/Controllers/SettingsController.php +++ b/app/Http/Controllers/SettingsController.php @@ -103,10 +103,11 @@ class SettingsController extends Controller */ public function clear($id) { + $user = $this->user(); $setting = Setting::find($id); if((bool)$setting->system !== true) { - $setting->value = ''; - $setting->save(); + $user->settings()->detach($setting->id); + $user->settings()->save($setting, ['uservalue' => '']); } $route = route('settings.index', [], false); return redirect($route) diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index 2bfb9d2f..fce89c09 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -7,7 +7,6 @@ use Artisan; use Schema; use App\Setting; use App\User; -use Session; class AppServiceProvider extends ServiceProvider { @@ -18,7 +17,7 @@ class AppServiceProvider extends ServiceProvider */ public function boot() { - $alt_bg = ''; + if(!is_file(base_path('.env'))) { touch(base_path('.env')); @@ -34,11 +33,6 @@ class AppServiceProvider extends ServiceProvider } if(is_file(database_path('app.sqlite'))) { if(Schema::hasTable('settings')) { - die("s: ".\Session::get('current_user')); - //die("c: ".User::currentUser()); - if($bg_image = Setting::_fetch('background_image', User::currentUser())) { - $alt_bg = ' style="background-image: url(/storage/'.$bg_image.')"'; - } // check version to see if an upgrade is needed $db_version = Setting::_fetch('version'); @@ -49,16 +43,25 @@ class AppServiceProvider extends ServiceProvider } else { Artisan::call('migrate', array('--path' => 'database/migrations', '--force' => true, '--seed' => true)); } - $lang = Setting::fetch('language'); - \App::setLocale($lang); } if(!is_file(public_path('storage'))) { Artisan::call('storage:link'); } - view()->share('alt_bg', $alt_bg); - //var_dump(env('FORCE_HTTPS')); + // User specific settings need to go here as session isn't available at this point in the app + view()->composer('*', function ($view) + { + $alt_bg = ''; + if($bg_image = Setting::fetch('background_image')) { + $alt_bg = ' style="background-image: url(/storage/'.$bg_image.')"'; + } + $lang = Setting::fetch('language'); + \App::setLocale($lang); + + $view->with('alt_bg', $alt_bg ); + }); + if (env('FORCE_HTTPS') === true) { \URL::forceScheme('https'); diff --git a/database/migrations/2018_10_12_140451_create_setting_user_pivot_table.php b/database/migrations/2018_10_12_140451_create_setting_user_pivot_table.php index 94cd1cd0..64e858cb 100644 --- a/database/migrations/2018_10_12_140451_create_setting_user_pivot_table.php +++ b/database/migrations/2018_10_12_140451_create_setting_user_pivot_table.php @@ -19,7 +19,7 @@ class CreateSettingUserPivotTable extends Migration $table->integer('user_id')->unsigned()->index(); $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade'); $table->primary(['setting_id', 'user_id']); - $table->string('value')->nullable(); + $table->string('uservalue')->nullable(); }); } diff --git a/database/seeds/UsersSeeder.php b/database/seeds/UsersSeeder.php index 38428483..615b022b 100644 --- a/database/seeds/UsersSeeder.php +++ b/database/seeds/UsersSeeder.php @@ -16,8 +16,8 @@ class UsersSeeder extends Seeder if(!$user = User::find(1)) { $user = new User; $user->id = 1; - $user->name = 'User'; - $user->email = 'test@test.com'; + $user->name = 'Admin'; + $user->email = 'admin@test.com'; $user->save(); } else { //$user->save(); diff --git a/public/css/app.css b/public/css/app.css index f9a450ab..bbfd705f 100644 --- a/public/css/app.css +++ b/public/css/app.css @@ -233,6 +233,17 @@ body { background: #cfd2d4; } +#switchuser { + background: rgba(0, 0, 0, 0.6); + position: absolute; + padding: 5px; + color: white; + text-align: center; + top: 0; + left: 0; + right: 0; +} + #app { display: -webkit-box; display: -ms-flexbox; @@ -323,7 +334,7 @@ body { } #app main, #app #sortable { - padding: 10px; + padding: 30px 10px; display: -webkit-box; display: -ms-flexbox; display: flex; @@ -374,6 +385,68 @@ body { margin-top: 12px; } +.userlist { + display: -webkit-box; + display: -ms-flexbox; + display: flex; + -webkit-box-pack: center; + -ms-flex-pack: center; + justify-content: center; + -webkit-box-align: center; + -ms-flex-align: center; + align-items: center; +} + +.userlist .user { + background: rgba(0, 0, 0, 0.5); + display: -webkit-box; + display: -ms-flexbox; + display: flex; + padding: 15px; + -webkit-box-orient: vertical; + -webkit-box-direction: normal; + -ms-flex-direction: column; + flex-direction: column; + -webkit-box-pack: center; + -ms-flex-pack: center; + justify-content: center; + -webkit-box-align: center; + -ms-flex-align: center; + align-items: center; + margin: 20px; + color: white; + text-decoration: none; + border-radius: 15px; + border: 5px solid rgba(255, 255, 255, 0.7); + -webkit-box-shadow: 0 0 10px 0px rgba(0, 0, 0, 0.4); + box-shadow: 0 0 10px 0px rgba(0, 0, 0, 0.4); +} + +.userlist .user-img { + width: 130px; + height: 130px; + margin-bottom: 20px; + border-radius: 50%; + margin: 10px 10px 15px; +} + +.userlist #password { + color: #2f313a; + width: 100%; + padding: 5px 10px; + margin: 15px -5px; +} + +.userlist .btn { + width: 100%; +} + +.userlist .forgot { + color: white; + font-size: 12px; + margin-top: 25px; +} + .item-container { position: relative; } diff --git a/public/mix-manifest.json b/public/mix-manifest.json index e906db68..4a6d1f2a 100644 --- a/public/mix-manifest.json +++ b/public/mix-manifest.json @@ -1,4 +1,4 @@ { - "/css/app.css": "/css/app.css?id=2aa9dedf14862069c2ff", + "/css/app.css": "/css/app.css?id=6bc80b2f799b708a8024", "/js/app.js": "/js/app.js?id=32cbf6f4924b46ae7e05" } \ No newline at end of file diff --git a/resources/assets/sass/_app.scss b/resources/assets/sass/_app.scss index c2f0dcdc..f81a66a0 100644 --- a/resources/assets/sass/_app.scss +++ b/resources/assets/sass/_app.scss @@ -7,7 +7,16 @@ html { body { background: $body-bg; } - +#switchuser { + background: rgba(0,0,0,0.6); + position: absolute; + padding: 5px; + color: white; + text-align: center; + top:0; + left: 0; + right: 0; +} #app { display: flex; min-height: 100vh; @@ -70,7 +79,7 @@ body { flex-direction: column; } main, #sortable { - padding: 10px; + padding: 30px 10px; display: flex; justify-content: center; align-items: center; @@ -104,6 +113,47 @@ body { } } +.userlist { + display: flex; + justify-content: center; + align-items: center; + .user { + background: rgba(0,0,0,0.5); + display: flex; + padding: 15px; + flex-direction: column; + justify-content: center; + align-items: center; + margin: 20px; + color: white; + text-decoration: none; + border-radius: 15px; + border: 5px solid rgba(255,255,255, 0.7); + box-shadow: 0 0 10px 0px rgba(0,0,0,0.4); + } + .user-img { + width: 130px; + height: 130px; + margin-bottom: 20px; + border-radius: 50%; + margin: 10px 10px 15px; + } + #password { + color: $app-text; + width: 100%; + padding: 5px 10px; + margin: 15px -5px; + } + .btn { + width: 100%; + } + .forgot { + color: white; + font-size: 12px; + margin-top: 25px; + } +} + .item-container { //width: 340px; //transition: width .35s ease-in-out; diff --git a/resources/views/auth/login.blade.php b/resources/views/auth/login.blade.php index 33605813..883bb16a 100644 --- a/resources/views/auth/login.blade.php +++ b/resources/views/auth/login.blade.php @@ -1,55 +1,25 @@ @extends('layouts.app') @section('content') -