use Illuminate\Http\Request;
use Illuminate\Support\Facades\Mail;
use Illuminate\Support\Facades\Validator;
-use Illuminate\Validation\Rules\Password;
+use Illuminate\Support\Facades\Hash;
+use Illuminate\Http\RedirectResponse;
+use Illuminate\Support\Facades\Auth;
class AjaxController extends CubistFrontController
{
return $email;
}
- public function signin(Request $request) {
- $this->check_email_exist($request);
+ public function signin(Request $request)
+ {
+ $validation = [
+ 'email' => 'required|email',
+ 'password' => 'required',
+ ];
+
+ $validator = Validator::make($request->all(), $validation);
+
+ if ($validator->fails()) {
+ throw new ValidationException($validator);
+ }
+
+ $validator->validate();
+ $data = $validator->validated();
+
+ if (Auth::guard('web-clients')->attempt($data)) {
+ $request->session()->regenerate();
+
+ var_dump(Auth::user());
+ }else{
+ return 'pas ok';
+ }
}
public function signup(Request $request) {
'password_confirmation' => 'required',
'lastname' => 'required|alpha|max:255',
'firstname' => 'required|alpha|max:255',
- 'phone' => 'required|numeric|min:10',
+ 'phone' => 'required|numeric',
'company' => 'required|string',
'vat' => 'required|alpha_num|min:13',
'siren' => 'required|numeric',
'address.*.address' => 'required|string|max:255',
- 'address.*.zipcode' => 'required|numeric|min:5',
+ 'address.*.zipcode' => 'required|numeric',
'address.*.city' => 'required|string|max:255',
'address.*.billing_address' => 'nullable',
- 'address.*.delivery_address' => 'nullable'
+ 'address.*.delivery_address' => 'nullable',
+ 'confirm_condition' => 'required'
];
$validator = Validator::make($request->all(), $validation);
$validator->validate();
$data = $validator->validated();
$data['status'] = 0;
+ $data['password'] = Hash::make($data['password']);
$client = new Clients($data);
$client->save();
+
+ return $data;
}
}
--- /dev/null
+<?php
+namespace App\Http\Controllers;
+
+use Illuminate\Http\Request;
+use App\Models\BackpackClient;
+use Illuminate\Support\Facades\Auth;
+use Cubist\Backpack\app\Http\Controllers\CubistFrontController;
+
+class ClientController extends CubistFrontController
+{
+ public function view(Request $request) {
+ return $request->user();
+ }
+}
--- /dev/null
+<?php
+
+
+namespace App\Http\Controllers;
+
+//use App\Models\Product;
+use App\Models\ProductType;
+use Cubist\Backpack\app\Http\Controllers\CubistFrontController;
+use Illuminate\Http\Request;
+
+class SignInController extends CubistFrontController
+{
+ public function view(Request $request, $id)
+ {
+ return view('pages.signin');
+ }
+}
--- /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';
+}
'provider' => 'users',
],
+ 'web-clients' => [
+ 'driver' => 'session',
+ 'provider' => 'clients'
+ ],
+
'api' => [
'driver' => 'token',
'provider' => 'users',
'model' => App\User::class,
],
+ 'clients' => [
+ 'driver' => 'eloquent',
+ 'model' => App\Models\BackpackClient::class,
+ ]
+
// 'users' => [
// 'driver' => 'database',
// 'table' => 'users',
emailExist: false,
validateEmail: false,
address_choice: true,
- savingUser: false
+ validateRegister: false
},
beforeMount() {
toggleType() {
this.type = this.type === "password" ? "text" : "password"
},
- showForm(el) {
- document.querySelector(el).classList.remove('hidden')
+ removeErrors() {
+ let errorMessage = document.querySelectorAll('.form-error')
+ for (var i = 0; i < errorMessage.length; i++) {
+ errorMessage[i].remove();
+ }
},
- checkEmailExist(){
+ checkEmailExist() {
let root = this,
data = {
email: root.email_signin
.then(function (response) {
//do the verification before to set validateEmail true
root.validateEmail = true
- if(response.data.length > 0) {
+ if (response.data.length > 0) {
root.emailExist = true
}
})
.catch(function (error) {
- console.log('error',error)
+ console.log('error', error)
})
},
signin() {
let root = this,
- data = {
- email: root.email_signin,
- password: root.password_signin
- }
+ 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 homeUrl = window.location.origin;
+
+ if(lastVisitedUrl){
+ if(lastVisitedUrl.includes('pm-instrumentation')){
+ history.back()
+ }else{
+ window.location.replace(homeUrl)
+ }
+ }else{
+ window.location.replace(homeUrl)
+ }
})
.catch(function (error) {
console.log(error)
},
signup() {
let root = this,
- el = document.getElementById('signup-form'),
- data = new FormData(el)
+ form = document.getElementById('signup-form'),
+ data = new FormData(form)
axios.post('/ajax/signup', data)
.then(function (response) {
//
- this.savingUser = true
+ root.removeErrors()
+ form.reset()
+
+ window.scrollTo({
+ top: 0,
+ behavior: "smooth"
+ })
+ root.validateRegister = true
})
.catch(function (error) {
if (error.response) {
let errors = error.response.data.errors
- let form = document.querySelector('.form-input')
- let errorMessage = document.querySelectorAll('.form-error')
- for (var i = 0; i < errorMessage.length; i++) {
- errorMessage[i].remove();
- }
+ root.removeErrors()
- for(let k in errors){
- let el = document.querySelector('[name='+k+']')
+ for (let k in errors) {
+ let el = document.querySelector('[name=' + k + ']')
let span = document.createElement("span")
span.classList.add('form-error')
span.innerText = errors[k]
--- /dev/null
+//
+.page-signin main
+ position: relative
+
+//
+.modal-confirm
+ width: 100%
+ height: 100vh
+ padding: 0 25px
+ z-index: 99
+ top: -120px
+ &-text
+ width: 100%
+ max-width: 744px
+ opacity: 0
+ animation-name: opacity, top
+ animation-duration: .3s, 1s
+ animation-delay: .6s, .6s
+ animation-fill-mode: forwards, forwards
+ z-index: 1
+ box-shadow: 0 30px 60px rgba(24,47,76,.2)
+ font-family: 'Barlow',sans-serif
+ .mb-4
+ margin-bottom: 1rem !important
+ &-close
+ top: 24px
+ right: 24px
+ &:after
+ content: ""
+ width: 100%
+ height: 100vh
+ position: fixed
+ top: 0
+ left: 0
+ background-color: rgba(21,47,78,.25)
+ animation-name: opacity
+ animation-duration: .5s
+ animation-timing-function: ease-in
+ animation-fill-mode: forwards
+
+ @keyframes opacity
+ 0%
+ opacity: 0
+
+ 100%
+ opacity: 1
+
+ @keyframes top
+ 0%
+ top: 62px
+
+ 100%
+ top: 92px
padding: 0 !important
[type="checkbox"]
width: 16px !important
- height: 16px
+ height: 24px
margin: 0
- border: 1px solid #EEF1F7
- border-radius: 2px
+ border: 0
display: grid
place-content: center
padding: 0
position: relative
- top: 7px
&:before
content: ""
width: 16px
height: 16px
background-color: #F7F8FC
+ border: 1px solid #EEF1F7
+ border-radius: 2px
&:checked:before
content: ""
border-color: #0EAADA
</form>
</div>
</div>
- <div class="signin-form" v-if="emailExist">
+ <div class="signin-form hidden" :ref="(signin) => signin.classList.remove('hidden')" v-if="emailExist">
<div class="ajax-form flex flex-col max-w-half">
<div class="form-info text-navy mb-10">
<h1 class="text-4xl m-0">Se connecter</h1>
</div>
- <form class="form-portal">
+ <form id="signin-form" class="form-portal" @submit.prevent="signin">
@csrf
<div class="form-group mb-6">
<label class="form-input text-navy">
<span class="form-required-legend inline-block my-4 mr-3 text-grey-dark xs:self-start xs:mt-5">
*{{ __('Champs obligatoires')}}
</span>
- <button id="checkemail" class="form-submit-button btn btn-custom xs:w-full" @click.prevent="signin">
+ <button id="checkemail" class="form-submit-button btn btn-custom xs:w-full">
{{ __('Connexion') }}
</button>
</div>
</form>
</div>
</div>
- <div class="signup-form" v-if="!emailExist && validateEmail">
+ <div class="signup-form hidden" :ref="(signup) => signup.classList.remove('hidden')" v-if="!emailExist && validateEmail">
<div class="ajax-form flex flex-col max-w-half">
<div class="form-info text-navy mb-10">
<h1 class="text-4xl m-0">Créer un compte</h1>
</div>
</div>
</div>
+ @include('partials.modal-confirm')
@endsection
</nav>
@php
- //var_dump($nav);
+ var_dump(Auth::user());
@endphp
+ @guest
<a href="{{ $nav->getHrefByName('signin') }}"
- class="text-right flex items-center cursor-pointer text-white hover:text-primary">
+ class="text-right flex items-center cursor-pointer text-white hover:text-primary"
+ >
@include('partials.account')
</a>
+ @endguest
@if (config('features.quote'))
<a href="{{ $nav->getHrefByName('cart') }}"
--- /dev/null
+<div class="modal-confirm absolute left-0 hidden" :ref="(modalconfirm) => modalconfirm.classList.remove('hidden')" v-if="validateRegister">
+ <div class="modal-confirm-text relative text-2xl bg-white p-24 text-center mx-auto">
+ <button class="modal-confirm-close absolute" @click.prevent="validateRegister = false">
+ @svg('icon-close-thin', 'w-4')
+ </button>
+ <p class="mb-4">Nous avons bien reçu votre demande d’inscription.</p>
+ <p>Vous recevrez un mail de confirmation une fois votre compte validé.</p>
+ </div>
+</div>