use App\Models\QuoteRequest;
use App\Models\Settings;
use App\Models\News;
-use App\Models\Clients;
+use App\Models\Client;
use Carbon\Carbon;
use Cubist\Backpack\app\Http\Controllers\CubistFrontController;
use Cubist\Backpack\app\Magic\PageData;
use Illuminate\Support\Facades\Mail;
use Illuminate\Support\Facades\Validator;
use Illuminate\Support\Facades\Hash;
-use Illuminate\Http\RedirectResponse;
use Illuminate\Support\Facades\Auth;
class AjaxController extends CubistFrontController
throw new ValidationException($validator);
}
- $email = Clients::where('email', $request->email)->get();
+ $email = Client::where('email', $request->email)->get();
return $email;
}
- public function signin(Request $request)
- {
+ public function signin(Request $request) {
$validation = [
'email' => 'required|email',
- 'password' => 'required',
+ 'password' => 'required'
];
$validator = Validator::make($request->all(), $validation);
throw new ValidationException($validator);
}
+ $status = Client::where('email', $request->email)->get('status');
+ if (!$status) {
+ throw ValidationException::withMessages(['email' => __('Le compte lié à cette adresse est en cours de validation')]);
+ }
+
$validator->validate();
$data = $validator->validated();
- if (Auth::guard('web-clients')->attempt($data)) {
- $request->session()->regenerate();
+ $remember = $request->stay_log ? true : false;
- var_dump(Auth::user());
+ if (Auth::guard('web-clients')->attempt($data, $remember)) {
+ $request->session()->regenerate();
+ return Auth::guard('web-clients')->user();
}else{
- return 'pas ok';
+ return false;
}
}
$data['status'] = 0;
$data['password'] = Hash::make($data['password']);
- $client = new Clients($data);
+ $client = new Client($data);
$client->save();
return $data;
<?php
namespace App\Http\Controllers;
+use Cubist\Backpack\app\Magic\Menu\Menu;
+use Cubist\Backpack\app\Magic\Models\CMSPage;
+use Cubist\Backpack\app\Magic\Models\Locale;
+use Cubist\Backpack\app\Magic\Models\Settings;
+use Cubist\Backpack\Facades\App;
+use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Http\Request;
-use App\Models\BackpackClient;
+use Illuminate\Http\RedirectResponse;
use Illuminate\Support\Facades\Auth;
-use Cubist\Backpack\app\Http\Controllers\CubistFrontController;
+use Cubist\Backpack\app\Http\Controllers\CubistPageController;
+use Illuminate\Support\Str;
-class ClientController extends CubistFrontController
+class ClientController extends CubistPageController
{
- public function view(Request $request) {
- return $request->user();
+ public function logout(Request $request): RedirectResponse
+ {
+ //Auth::guard('web-clients')->logout();
+
+ $request->session()->invalidate();
+
+ $request->session()->regenerateToken();
+
+ return redirect('/se-connecter');
}
}
class SignInController extends CubistFrontController
{
- public function view(Request $request, $id)
+ public function view(Request $request)
{
return view('pages.signin');
}
'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class,
'can' => \Illuminate\Auth\Middleware\Authorize::class,
'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
+ 'client' => \App\Http\Middleware\RedirectClientIfAuthenticated::class,
'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class,
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
--- /dev/null
+<?php
+
+namespace App\Http\Middleware;
+
+use Closure;
+use Illuminate\Support\Facades\Auth;
+
+class RedirectClientIfAuthenticated
+{
+ /**
+ * Handle an incoming request.
+ *
+ * @param \Illuminate\Http\Request $request
+ * @param \Closure $next
+ * @return mixed
+ */
+ public function handle($request, Closure $next)
+ {
+ if ($request->is('se-connecter') && Auth::guard('web-clients')->check()) {
+ return redirect('/');
+ }
+
+ return $next($request);
+ }
+}
public function handle($request, Closure $next, $guard = null)
{
if (Auth::guard($guard)->check()) {
- return redirect('/home');
+ return redirect('/');
}
return $next($request);
--- /dev/null
+<?php
+namespace App\Models;
+
+use Illuminate\Foundation\Auth\User as Authenticatable;
+
+class AuthClient extends Authenticatable
+{
+
+ protected $table = 'clients';
+
+ /**
+ * The attributes that are mass assignable.
+ *
+ * @var array
+ */
+ protected $fillable = [
+ 'email', 'password',
+ ];
+
+ /**
+ * The attributes that should be hidden for arrays.
+ *
+ * @var array
+ */
+ protected $hidden = [
+ 'remember_token',
+ ];
+}
+++ /dev/null
-<?php
-namespace App\Models;
-
-use App\User;
-use Backpack\Base\app\Models\Traits\InheritsRelationsFromParentModel;
-use Backpack\Base\app\Notifications\ResetPasswordNotification as ResetPasswordNotification;
-
-class BackpackClient extends User
-{
- use InheritsRelationsFromParentModel;
-
- protected $table = 'clients';
-}
--- /dev/null
+<?php
+namespace App\Models;
+
+use Cubist\Backpack\app\Magic\Models\CubistMagicAbstractModel;
+
+class Client extends CubistMagicAbstractModel
+{
+
+ protected $table = 'clients';
+
+ protected $_options = ['name' => 'clients',
+ 'singular' => 'Client',
+ 'plural' => 'Client'];
+
+ public function setFields()
+ {
+ parent::setFields();
+
+ $this->addField(['name' => 'email',
+ 'label' => 'Email',
+ 'type' => 'Email',
+ 'column' => true,
+ 'tab' => 'Informations client']);
+
+ $this->addField(['name' => 'password',
+ 'label' => 'Password',
+ 'type' => 'Text']);
+
+ $this->addField(['name' => 'name',
+ 'label' => 'Nom',
+ 'type' => 'Text',
+ 'column' => true,
+ 'tab' => 'Informations client']);
+
+ $this->addField(['name' => 'firstname',
+ 'label' => 'Prénom',
+ 'type' => 'Text',
+ 'column' => true,
+ 'tab' => 'Informations client']);
+
+ $this->addField(['name' => 'company',
+ 'label' => 'Société',
+ 'type' => 'Text',
+ 'column' => true,
+ 'tab' => 'Informations client']);
+
+ $this->addField(['name' => 'vat',
+ 'label' => 'TVA',
+ 'type' => 'Text',
+ 'column' => true,
+ 'tab' => 'Informations client']);
+
+ $this->addField(['name' => 'siren',
+ 'label' => 'Siren',
+ 'type' => 'Number',
+ 'column' => true,
+ 'tab' => 'Informations client'
+ ]);
+
+ $this->addField([
+ 'name' => 'address',
+ 'label' => 'Adresse',
+ 'type' => 'BunchOfFieldsMultiple',
+ 'bunch' => 'App\SubForms\Address',
+ 'column' => true,
+ 'tab' => 'Informations client'
+ ]);
+
+ $this->addField(['name' => 'status',
+ 'label' => 'Utilisateur approuvé',
+ 'type' => 'Checkbox',
+ 'column' => true,
+ 'tab' => 'Informations client'
+ ]);
+
+ $this->addField([
+ 'name' => 'remember_token',
+ 'label' => 'remember_token',
+ 'type' => 'Text',
+ 'column' => true
+ ]);
+ }
+}
+++ /dev/null
-<?php
-namespace App\Models;
-
-use Cubist\Backpack\app\Magic\Models\CubistMagicAbstractModel;
-
-class Clients extends CubistMagicAbstractModel
-{
- protected $table = 'clients';
-
- protected $_options = ['name' => 'clients',
- 'singular' => 'Client',
- 'plural' => 'Clients'];
-
- public function setFields()
- {
- parent::setFields();
-
- $this->addField(['name' => 'email',
- 'label' => 'Email',
- 'type' => 'Email',
- 'column' => true,
- 'tab' => 'Informations client']);
-
- $this->addField(['name' => 'password',
- 'label' => 'Password',
- 'type' => 'Text']);
-
- $this->addField(['name' => 'name',
- 'label' => 'Nom',
- 'type' => 'Text',
- 'column' => true,
- 'tab' => 'Informations client']);
-
- $this->addField(['name' => 'firstname',
- 'label' => 'Prénom',
- 'type' => 'Text',
- 'column' => true,
- 'tab' => 'Informations client']);
-
- $this->addField(['name' => 'company',
- 'label' => 'Société',
- 'type' => 'Text',
- 'column' => true,
- 'tab' => 'Informations client']);
-
- $this->addField(['name' => 'vat',
- 'label' => 'TVA',
- 'type' => 'Text',
- 'column' => true,
- 'tab' => 'Informations client']);
-
- $this->addField(['name' => 'siren',
- 'label' => 'Siren',
- 'type' => 'Number',
- 'column' => true,
- 'tab' => 'Informations client'
- ]);
-
- $this->addField([
- 'name' => 'address',
- 'label' => 'Adresse',
- 'type' => 'BunchOfFieldsMultiple',
- 'bunch' => 'App\SubForms\Address',
- 'column' => true,
- 'tab' => 'Informations client'
- ]);
-
- $this->addField(['name' => 'status',
- 'label' => 'Utilisateur approuvé',
- 'type' => 'Checkbox',
- 'column' => true,
- 'tab' => 'Informations client'
- ]);
- }
-}
namespace App\Templates;
use Cubist\Backpack\app\Template\TemplatePage;
+use http\Env\Request;
class Base extends TemplatePage
{
'type' => 'BunchOfFieldsMultiple',
'bunch' => 'App\SubForms\Logo',
'label' => 'Logos',
- 'tab' => 'Clients']);
+ 'tab' => 'Client']);
}
// Set extra data for Home blade view
--- /dev/null
+<?php
+
+
+namespace App\Templates;
+
+
+class MyAccount extends Base
+{
+ public function getName()
+ {
+ return 'Mon compte';
+ }
+
+ public function init()
+ {
+ parent::init();
+ }
+}
public function init()
{
parent::init();
-
- $form_login = "Formulaire de connexion";
- $form_register = "Formulaire d'inscription";
-
- $this->removeField('intro');
-
- $this->addField(['name' => 'page_heading',
- 'type' => 'Text',
- 'label' => 'Titre de la page',
- 'tab' => 'Contenus'
- ]);
-
- $this->addField([
- 'name' => 'email',
- 'type' => 'Email',
- 'label' => 'Email',
- 'tab' => $form_login
- ]);
-
-
- // Enable form
- $this->addForm();
}
}
'clients' => [
'driver' => 'eloquent',
- 'model' => App\Models\BackpackClient::class,
+ 'model' => App\Models\AuthClient::class,
]
// 'users' => [
--- /dev/null
+<?php
+
+return [
+
+ /*
+ |--------------------------------------------------------------------------
+ | Debugbar Settings
+ |--------------------------------------------------------------------------
+ |
+ | Debugbar is enabled by default, when debug is set to true in app.php.
+ | You can override the value by setting enable to true or false instead of null.
+ |
+ | You can provide an array of URI's that must be ignored (eg. 'api/*')
+ |
+ */
+
+ 'enabled' => env('DEBUGBAR_ENABLED', null),
+ 'except' => [
+ 'telescope*',
+ 'horizon*'
+ ],
+
+ /*
+ |--------------------------------------------------------------------------
+ | Storage settings
+ |--------------------------------------------------------------------------
+ |
+ | DebugBar stores data for session/ajax requests.
+ | You can disable this, so the debugbar stores data in headers/session,
+ | but this can cause problems with large data collectors.
+ | By default, file storage (in the storage folder) is used. Redis and PDO
+ | can also be used. For PDO, run the package migrations first.
+ |
+ */
+ 'storage' => [
+ 'enabled' => true,
+ 'driver' => 'file', // redis, file, pdo, custom
+ 'path' => storage_path('debugbar'), // For file driver
+ 'connection' => null, // Leave null for default connection (Redis/PDO)
+ 'provider' => '' // Instance of StorageInterface for custom driver
+ ],
+
+ /*
+ |--------------------------------------------------------------------------
+ | Vendors
+ |--------------------------------------------------------------------------
+ |
+ | Vendor files are included by default, but can be set to false.
+ | This can also be set to 'js' or 'css', to only include javascript or css vendor files.
+ | Vendor files are for css: font-awesome (including fonts) and highlight.js (css files)
+ | and for js: jquery and and highlight.js
+ | So if you want syntax highlighting, set it to true.
+ | jQuery is set to not conflict with existing jQuery scripts.
+ |
+ */
+
+ 'include_vendors' => true,
+
+ /*
+ |--------------------------------------------------------------------------
+ | Capture Ajax Requests
+ |--------------------------------------------------------------------------
+ |
+ | The Debugbar can capture Ajax requests and display them. If you don't want this (ie. because of errors),
+ | you can use this option to disable sending the data through the headers.
+ |
+ | Optionally, you can also send ServerTiming headers on ajax requests for the Chrome DevTools.
+ */
+
+ 'capture_ajax' => true,
+ 'add_ajax_timing' => false,
+
+ /*
+ |--------------------------------------------------------------------------
+ | Custom Error Handler for Deprecated warnings
+ |--------------------------------------------------------------------------
+ |
+ | When enabled, the Debugbar shows deprecated warnings for Symfony components
+ | in the Messages tab.
+ |
+ */
+ 'error_handler' => false,
+
+ /*
+ |--------------------------------------------------------------------------
+ | Clockwork integration
+ |--------------------------------------------------------------------------
+ |
+ | The Debugbar can emulate the Clockwork headers, so you can use the Chrome
+ | Extension, without the server-side code. It uses Debugbar collectors instead.
+ |
+ */
+ 'clockwork' => false,
+
+ /*
+ |--------------------------------------------------------------------------
+ | DataCollectors
+ |--------------------------------------------------------------------------
+ |
+ | Enable/disable DataCollectors
+ |
+ */
+
+ 'collectors' => [
+ 'phpinfo' => true, // Php version
+ 'messages' => true, // Messages
+ 'time' => true, // Time Datalogger
+ 'memory' => true, // Memory usage
+ 'exceptions' => true, // Exception displayer
+ 'log' => true, // Logs from Monolog (merged in messages if enabled)
+ 'db' => true, // Show database (PDO) queries and bindings
+ 'views' => true, // Views with their data
+ 'route' => true, // Current route information
+ 'auth' => true, // Display Laravel authentication status
+ 'gate' => true, // Display Laravel Gate checks
+ 'session' => true, // Display session data
+ 'symfony_request' => true, // Only one can be enabled..
+ 'mail' => true, // Catch mail messages
+ 'laravel' => false, // Laravel version and environment
+ 'events' => false, // All events fired
+ 'default_request' => false, // Regular or special Symfony request logger
+ 'logs' => false, // Add the latest log messages
+ 'files' => false, // Show the included files
+ 'config' => false, // Display config settings
+ 'cache' => false, // Display cache events
+ 'models' => true, // Display models
+ 'livewire' => true, // Display Livewire (when available)
+ ],
+
+ /*
+ |--------------------------------------------------------------------------
+ | Extra options
+ |--------------------------------------------------------------------------
+ |
+ | Configure some DataCollectors
+ |
+ */
+
+ 'options' => [
+ 'auth' => [
+ 'show_name' => true, // Also show the users name/email in the debugbar
+ ],
+ 'db' => [
+ 'with_params' => true, // Render SQL with the parameters substituted
+ 'backtrace' => true, // Use a backtrace to find the origin of the query in your files.
+ 'backtrace_exclude_paths' => [], // Paths to exclude from backtrace. (in addition to defaults)
+ 'timeline' => false, // Add the queries to the timeline
+ 'explain' => [ // Show EXPLAIN output on queries
+ 'enabled' => false,
+ 'types' => ['SELECT'], // // workaround ['SELECT'] only. https://github.com/barryvdh/laravel-debugbar/issues/888 ['SELECT', 'INSERT', 'UPDATE', 'DELETE']; for MySQL 5.6.3+
+ ],
+ 'hints' => false, // Show hints for common mistakes
+ ],
+ 'mail' => [
+ 'full_log' => false
+ ],
+ 'views' => [
+ 'data' => false, //Note: Can slow down the application, because the data can be quite large..
+ ],
+ 'route' => [
+ 'label' => true // show complete route on bar
+ ],
+ 'logs' => [
+ 'file' => null
+ ],
+ 'cache' => [
+ 'values' => true // collect cache values
+ ],
+ ],
+
+ /*
+ |--------------------------------------------------------------------------
+ | Inject Debugbar in Response
+ |--------------------------------------------------------------------------
+ |
+ | Usually, the debugbar is added just before </body>, by listening to the
+ | Response after the App is done. If you disable this, you have to add them
+ | in your template yourself. See http://phpdebugbar.com/docs/rendering.html
+ |
+ */
+
+ 'inject' => true,
+
+ /*
+ |--------------------------------------------------------------------------
+ | DebugBar route prefix
+ |--------------------------------------------------------------------------
+ |
+ | Sometimes you want to set route prefix to be used by DebugBar to load
+ | its resources from. Usually the need comes from misconfigured web server or
+ | from trying to overcome bugs like this: http://trac.nginx.org/nginx/ticket/97
+ |
+ */
+ 'route_prefix' => '_debugbar',
+
+ /*
+ |--------------------------------------------------------------------------
+ | DebugBar route domain
+ |--------------------------------------------------------------------------
+ |
+ | By default DebugBar route served from the same domain that request served.
+ | To override default domain, specify it as a non-empty value.
+ */
+ 'route_domain' => null,
+
+ /*
+ |--------------------------------------------------------------------------
+ | DebugBar theme
+ |--------------------------------------------------------------------------
+ |
+ | Switches between light and dark theme. If set to auto it will respect system preferences
+ | Possible values: auto, light, dark
+ */
+ 'theme' => 'auto',
+];
form = document.getElementById('signin-form'),
data = new FormData(form)
- console.log(form)
-
axios.post('/ajax/signin', data)
.then(function (response) {
//
- let lastVisitedUrl = document.referrer;
+
+ let lastVisitedUrl = document.querySelector('[name="previous-url"]').getAttribute('content');
let homeUrl = window.location.origin;
if(lastVisitedUrl){
if(lastVisitedUrl.includes('pm-instrumentation')){
- history.back()
+ window.location.replace(lastVisitedUrl)
}else{
window.location.replace(homeUrl)
}
$content-max-width = $base-width * 0.9 // Allows 5% either side
$header-height = 134px
-$header-height-minimized = 60px
+$header-height-minimized = 75px
$transition-duration = 500ms
// Gutters (assumed to always be a vw, vh or % unit)
width: 34px
height: 36px
-
.site-header
@apply bg-navy text-white text-lg font-display font-medium antialiased fixed top-0
to
opacity: 1
-.nav-primary
- @apply flex mx-auto px-8
+.nav-primary,
+.account-header
// Trigger for submenus, at any depth
li:hover > ul
overflow: hidden
text-overflow: ellipsis
+.nav-primary
+ @apply flex mx-auto px-8
+
#mobile-nav
+below($breakpoint-menu)
display: block
@endif
@if(config('features.clients'))
- {{-- Our Clients --}}
+ {{-- Our Client --}}
<full-width class="bg-grey-100">
<content>
<text-block :title="__('Nos clients')"/>
</div>
<div class="form-group mb-5">
<label class="flex items-center">
- <input type="checkbox" name="stay-log" class="w-4 h-4" />
+ <input type="checkbox" name="remember_me" class="w-4 h-4" />
<span class="ml-4">{{ __('Rester connecté') }}</span>
</label>
</div>
-<span class="account-header-title">{{ __('Se connecter') }}</span>
+<span class="account-header-title">
+ @if(Auth::guard('web-clients')->check())
+ {{ Auth::guard('web-clients')->user()->firstname }}
+ @else
+ {{ __('Se connecter') }}
+ @endif
+</span>
<span class="header-icon-wrapper account-icon-wrapper">
@svg('icon-account', 'account-header-icon header-icon')
</span>
</nav>
- @php
- var_dump(Auth::user());
- @endphp
- @guest
- <a href="{{ $nav->getHrefByName('signin') }}"
- class="text-right flex items-center cursor-pointer text-white hover:text-primary"
- >
- @include('partials.account')
- </a>
- @endguest
+ <ul class="account-header">
+ <li>
+ <a href="{{ $nav->getHrefByName('signin') }}"
+ class="text-right flex items-center cursor-pointer text-white hover:text-primary"
+ >
+ @include('partials.account')
+ </a>
+ @include('partials.nav-account')
+ </li>
+ </ul>
@if (config('features.quote'))
<a href="{{ $nav->getHrefByName('cart') }}"
--- /dev/null
+@if(Auth::guard('web-clients')->check())
+ <ul class="account-header-list">
+ <li>
+ <a href="">
+ <span>{{ __('Mon compte') }}</span>
+ </a>
+ </li>
+ <li>
+ <a href="">
+ <span>{{ __('Mes commandes') }}</span>
+ </a>
+ </li>
+ <li>
+ <a href="">
+ <span>{{ __('Panier enregistrés') }}</span>
+ </a>
+ </li>
+ <li>
+ <a href="/deconnexion">
+ <span>{{ __('Deconnexion') }}</span>
+ </a>
+ </li>
+ </ul>
+@endif
<?php
+Route::get('/deconnexion', 'ClientController@logout');
+
Route::any('{page}/{subs?}', 'PageController@catchall')
- ->where(['page' => '^(((?=(?!admin))(?=(?!\/)).))*$', 'subs' => '.*']);
+ ->where(['page' => '^(((?=(?!admin))(?=(?!\/)).))*$', 'subs' => '.*'])
+ ->middleware('client');