added mail register & reset password

fixed some bugs
added simple register theme part
pull/49/head
A1Gard 2 months ago
parent 802896a135
commit 87c2184f46

@ -4,7 +4,6 @@ on:
push:
tags:
- "*"
branches: [ "master" ]
pull_request:
branches: [ "master" ]

@ -999,7 +999,7 @@ function isGuestMaxAttemptTry($action, $max = 5, $minutes = 60)
{
if (\App\Models\GuestLog::where('ip', request()->ip())
->where('action', $action)
->where('created_at', '<', time() - ($minutes * 60))->count() >= $max) {
->where('created_at', '>', time() - ($minutes * 60))->count() >= $max) {
return true;
} else {
return false;

@ -0,0 +1,108 @@
<?php
namespace App\Http\Controllers\Admin;
use App\Http\Controllers\Controller;
use App\Http\Controllers\XController;
use App\Http\Requests\GuestLogSaveRequest;
use App\Models\Access;
use App\Models\GuestLog;
use Illuminate\Http\Request;
use App\Helper;
use function App\Helpers\hasCreateRoute;
class GuestLogController extends XController
{
// protected $_MODEL_ = GuestLog::class;
// protected $SAVE_REQUEST = GuestLogSaveRequest::class;
protected $cols = ['ip','action','created_at','loggable_type','loggable_id'];
protected $extra_cols = ['id'];
protected $searchable = ['action','ip'];
protected $listView = 'admin.guestlogs.guestlog-list';
protected $formView = 'admin.guestlogs.guestlog-form';
protected $buttons = [
// 'edit' =>
// ['title' => "Edit", 'class' => 'btn-outline-primary', 'icon' => 'ri-edit-2-line'],
// 'show' =>
// ['title' => "Detail", 'class' => 'btn-outline-light', 'icon' => 'ri-eye-line'],
// 'destroy' =>
// ['title' => "Remove", 'class' => 'btn-outline-danger delete-confirm', 'icon' => 'ri-close-line'],
];
public function __construct()
{
parent::__construct(GuestLog::class, GuestLogSaveRequest::class);
}
/**
* @param $guestlog GuestLog
* @param $request GuestLogSaveRequest
* @return GuestLog
*/
public function save($guestlog, $request)
{
$guestlog->save();
return $guestlog;
}
/**
* Show the form for creating a new resource.
*/
public function create()
{
//
return view($this->formView);
}
/**
* Show the form for editing the specified resource.
*/
public function edit(GuestLog $item)
{
//
return view($this->formView, compact('item'));
}
public function bulk(Request $request)
{
// dd($request->all());
$data = explode('.', $request->input('action'));
$action = $data[0];
$ids = $request->input('id');
switch ($action) {
case 'delete':
$msg = __(':COUNT items deleted successfully', ['COUNT' => count($ids)]);
$this->_MODEL_::destroy($ids);
break;
default:
$msg = __('Unknown bulk action : :ACTION', ["ACTION" => $action]);
}
return $this->do_bulk($msg, $action, $ids);
}
public function destroy(GuestLog $item)
{
return parent::delete($item);
}
public function update(Request $request, GuestLog $item)
{
return $this->bringUp($request, $item);
}
}

@ -4,6 +4,7 @@ namespace App\Http\Controllers;
use App\Contracts\Payment;
use App\Http\Requests\ContactSubmitRequest;
use App\Mail\AuthMail;
use App\Models\Attachment;
use App\Models\Category;
use App\Models\Clip;
@ -20,6 +21,7 @@ use App\Models\Rate;
use App\Models\User;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Mail;
use Illuminate\Support\Facades\Route;
use Plank\Metable\Meta;
use Spatie\Tags\Tag;
@ -231,6 +233,14 @@ class ClientController extends Controller
public function search(Request $request)
{
if (isGuestMaxAttemptTry('search', 5, 1)) {
return abort(403);
}
guestLog('search');
$q = trim($request->input('q'));
if (mb_strlen($q) < 3) {
return abort(403, __('Search word is too short'));
@ -476,7 +486,45 @@ class ClientController extends Controller
public function signUp()
{
if (config('app.sms.sign')){
return abort(403);
}
$area = 'register';
$title = __("sign up");
$subtitle = __('Sign up as customer');
return view('client.default-list', compact('area', 'title', 'subtitle'));
}
public function signUpNow(Request $request)
{
if (config('app.sms.sign')){
return abort(403);
}
$request->validate([
'email' => ['required','email']
]);
if (isGuestMaxAttemptTry('email', 1, 5)) {
return redirect()->back()->withErrors( __('You try attempts, Try it a few minutes'));
}
guestLog('email');
$passwd = generateUniqueID(12);
Mail::to($request->input('email'))->send(new AuthMail($passwd));
$c = Customer::where('email', $request->email);
if ($c->count() > 0) {
$customer = $c->first();
$msg = __('Your account password has been changed successfully.');
}else{
$customer = new Customer();
$customer->email = $request->email;
$msg = __('Your account has been created successfully.');
}
$customer->password = bcrypt($passwd);
$customer->save();
return redirect()->back()->with(['message' => $msg]);
}
public function singInDo(Request $request)

@ -0,0 +1,28 @@
<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class GuestLogSaveRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*/
public function authorize(): bool
{
return false;
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
return [
//
];
}
}

@ -0,0 +1,60 @@
<?php
namespace App\Mail;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Mail\Mailable;
use Illuminate\Mail\Mailables\Address;
use Illuminate\Mail\Mailables\Content;
use Illuminate\Mail\Mailables\Envelope;
use Illuminate\Queue\SerializesModels;
class AuthMail extends Mailable
{
use Queueable, SerializesModels;
/**
* Create a new message instance.
*/
public function __construct(
protected string $code,
)
{
//
}
/**
* Get the message envelope.
*/
public function envelope(): Envelope
{
return new Envelope(
from: new Address(getSetting('email'),config('app.name')),
subject: __('Authentication Mail').' - '. config('app.name'),
);
}
/**
* Get the message content definition.
*/
public function content(): Content
{
return new Content(
view: 'website.auth-mail',
with:[
'code' => $this->code
],
);
}
/**
* Get the attachments for the message.
*
* @return array<int, \Illuminate\Mail\Mailables\Attachment>
*/
public function attachments(): array
{
return [];
}
}

@ -15,8 +15,8 @@ return [
|
*/
'name' => env('APP_NAME', 'Laravel'),
'version' => env('APP_VERSION', '2.0.0-beta-3'),
'name' => env('APP_NAME', 'xShop'),
'version' => env('APP_VERSION', '2.0.0'),
'demo' => env('APP_DEMO', false),
/*
|--------------------------------------------------------------------------

@ -263,6 +263,15 @@ class PartSeeder extends Seeder
// -------------------------------------------------------------
$part = new Part();
$part->segment = 'register';
$part->part = 'SimpleRegister';
$part->area_id = Area::where('name', 'register')->first()->id;
$part->sort = 1;
$part->save();
// -------------------------------------------------------------
$part = new Part();
$part->segment = 'customer';
$part->part = 'AvisaCustomer';

@ -37,6 +37,7 @@ import "../views/segments/galleries_page/GalleriesList/GalleriesList.js";
import "../views/segments/gallery/GallaryGrid/GallaryGrid.js";
import "../views/segments/compare/CompareProducts/CompareProducts.js";
import "../views/segments/login/LoginPatternBg/LoginPatternBg.js";
import "../views/segments/register/SimpleRegister/SimpleRegister.js";
import "../views/segments/customer/AvisaCustomer/AvisaCustomer.js";
import "../views/segments/attachments_page/DenaAttachList/DenaAttachList.js";
import "../views/segments/attachment/AttachmentWithPreview/AttachmentWithPreview.js";

@ -48,6 +48,7 @@ $xshop-shadow:2px 2px 4px #777777;
@import "../views/segments/gallery/GallaryGrid/GallaryGrid";
@import "../views/segments/compare/CompareProducts/CompareProducts";
@import "../views/segments/login/LoginPatternBg/LoginPatternBg";
@import "../views/segments/register/SimpleRegister/SimpleRegister";
@import "../views/segments/customer/AvisaCustomer/AvisaCustomer";
@import "../views/segments/attachments_page/DenaAttachList/DenaAttachList";
@import "../views/segments/attachment/AttachmentWithPreview/AttachmentWithPreview";

@ -0,0 +1,42 @@
@extends('admin.templates.panel-form-template')
@section('title')
@if(isset($item))
{{__("Edit guestlog")}} [{{$item->id}}]
@else
{{__("Add new guestlog")}}
@endif -
@endsection
@section('form')
<div class="row">
<div class="col-lg-3">
@include('components.err')
<div class="item-list mb-3">
<h3 class="p-3">
<i class="ri-message-3-line"></i>
{{__("Tips")}}
</h3>
<ul>
<li>
{{__("Recommends")}}
</li>
</ul>
</div>
</div>
<div class="col-lg-9 ps-xl-1 ps-xxl-1">
<div class="general-form ">
<h1>
@if(isset($item))
{{__("Edit guestlog")}} [{{$item->id}}]
@else
{{__("Add new guestlog")}}
@endif
</h1>
</div>
</div>
</div>
@endsection

@ -0,0 +1,15 @@
@extends('admin.templates.panel-list-template')
@section('list-title')
<i class="ri-user-3-line"></i>
{{__("GuestLogs list")}}
@endsection
@section('title')
{{__("GuestLogs list")}} -
@endsection
@section('filter')
{{-- Other filters --}}
@endsection
@section('bulk')
{{-- <option value="-"> - </option> --}}
@endsection

@ -6,7 +6,13 @@
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<meta name="description" content="xShop control panel - {{config('app.name')}}">
<meta name="generator" content="xShop; version={{config('app.version')}}">
{{-- open graph --}}
<meta property="og:site_name" content="{{config('app.name')}}" />
<meta property="og:locale" content="{{config('app.locale')}}">
<meta property="og:title" content="{{config('app.name')}}" />
<meta property="og:image" content="{{asset('upload/images/logo.svg')}}" />
<!-- CSRF Token -->
<meta name="csrf-token" content="{{ csrf_token() }}">

@ -301,7 +301,7 @@
@endif
@if( auth()->user()->hasAnyAccess( 'guestlog' ))
<li>
<a href="">
<a href="{{route('admin.guestlog.index')}}">
<i class="ri-list-check-3"></i>
{{__('Logs of guests')}}
</a>

@ -78,6 +78,34 @@
<div class="mt-lg-5 mb-lg-5"> &nbsp;</div>
<div class="mt-lg-5 mb-lg-5"> &nbsp;</div>
@include('components.err')
@if(cardCount() > 0)
<div class="alert alert-info mt-4">
<a href="{{ route('client.card') }}" class="btn btn-primary float-end">
{{__("Continue")}}
</a>
<h5 class="alert-heading">
{{__("System notification")}}
</h5>
{{__("You have some products in your shopping card.")}}
<br>
</div>
@endif
@if( auth('customer')->user()->name == null || trim(auth('customer')->user()->name) == '')
<div class="alert alert-danger mt-4">
<h5 class="alert-heading">
{{__("System notification")}}
</h5>
{{__("Your information is insufficient, Please complete your information")}}
</div>
@endif
@if( auth('customer')->user()->addresses()->count() == 0)
<div class="alert alert-danger mt-4">
<h5 class="alert-heading">
{{__("System notification")}}
</h5>
{{__("You need at least one address to order, Please add address")}}
</div>
@endif
<div class="tab active" id="summary">
<div class="row">
<div class="avisa-grid col-lg-3 col-md-6">
@ -148,34 +176,6 @@
</div>
</div>
</div>
@if(cardCount() > 0)
<div class="alert alert-info mt-4">
<a href="{{ route('client.card') }}" class="btn btn-primary float-end">
{{__("Continue")}}
</a>
<h5 class="alert-heading">
{{__("System notification")}}
</h5>
{{__("You have some products in your shopping card.")}}
<br>
</div>
@endif
@if( auth('customer')->user()->name == null || trim(auth('customer')->user()->name) == '')
<div class="alert alert-danger mt-4">
<h5 class="alert-heading">
{{__("System notification")}}
</h5>
{{__("Your information is insufficient, Please complete your information")}}
</div>
@endif
@if( auth('customer')->user()->addresses()->count() == 0)
<div class="alert alert-danger mt-4">
<h5 class="alert-heading">
{{__("System notification")}}
</h5>
{{__("You need at least one address to order, Please add address")}}
</div>
@endif
</div>
<div class="tab" id="invoices">
<table class="table table-striped text-center">

@ -0,0 +1,23 @@
<section class='SimpleRegister'>
<div class="{{gfx()['container']}}">
<form action="/blah" method="post" class="safe-form" id="email-register">
@csrf
@include('components.err')
<input type="hidden" class="safe-url" data-url="{{route('client.sign-up-now')}}">
<h5 class="text-center">
{{__("Register or Reset password")}}
</h5>
<div class="form-group my-2">
<label for="email">
{{__("Email")}}
</label>
<input type="email" id="email" required name="email" value="{{old('email')}}" placeholder="{{__("Email")}}" class="form-control">
</div>
<button class="btn btn-secondary w-100">
<i class="ri-user-add-line"></i>
{{__("Sign-up")}}
</button>
</form>
</div>
</section>

@ -0,0 +1,10 @@
{
"name": "SimpleRegister",
"version": "1.0",
"author": "xStack",
"email": "xshop@xstack.ir",
"license": "GPL-3.0-or-later",
"url": "https:\/\/xstack.ir",
"author_url": "https:\/\/4xmen.ir",
"packages": []
}

@ -0,0 +1,21 @@
<?php
namespace Resources\Views\Segments;
use App\Models\Part;
class SimpleRegister
{
public static function onAdd(Part $part = null)
{
}
public static function onRemove(Part $part = null)
{
}
public static function onMount(Part $part = null)
{
return $part;
}
}

@ -0,0 +1,16 @@
.SimpleRegister {
// scss
min-height: 64vh;
display: flex;
justify-content: center;
align-items: center;
#email-register{
margin: auto;
max-width: 450px;
background: var(--xshop-primary);
color: var(--xshop-diff);
padding: 1rem;
border-radius: var(--xshop-border-radius);
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

@ -0,0 +1,6 @@
<h4>
{{__("Your Authentication Mail")}}
</h4>
<p>
{{__("Password or new password is:")}} {{$code}}
</p>

@ -6,7 +6,9 @@
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<meta name="theme-color" content="{{gfx()['primary']}}"/>
<meta name="robots" content="follow,index">
@if(! config('app.demo'))
<meta name="robots" content="follow,index">
@endif
<meta name="generator" content="xShop; version={{config('app.version')}}">
{{-- Please don't modify or remove generator --}}
@ -15,7 +17,7 @@
@yield('title')
</title>
@if(langIsRTL(config('app.locale')))
@if(langIsRTL(app()->getLocale()))
<link rel="stylesheet" href="{{asset('assets/vendor/bootstrap/dist/css/bootstrap.rtl.min.css')}}">
@else
<link rel="stylesheet" href="{{asset('assets/vendor/bootstrap/dist/css/bootstrap.min.css')}}">
@ -30,7 +32,7 @@
{{-- seo --}}
<meta property="og:site_name" content="{{config('app.name')}}" />
<meta property="og:locale" content="{{config('app.locale')}}">
<meta property="og:locale" content="{{app()->getLocale()}}">
@if(isset($breadcrumb))
{!! markUpBreadcrumbList($breadcrumb) !!}
@endif

@ -20,6 +20,7 @@ Route::prefix(config('app.panel.prefix'))->name('admin.')->group(
Route::post('ckeditor/upload', [\App\Http\Controllers\Admin\CkeditorController::class, 'upload'])->name('ckeditor.upload');
Route::get('adminlogs', [\App\Http\Controllers\Admin\AdminLogController::class, 'index'])->name('adminlog.index');
Route::get('guestlog', [\App\Http\Controllers\Admin\GuestLogController::class, 'index'])->name('guestlog.index');
Route::get('rates', [\App\Http\Controllers\Admin\RateController::class, 'index'])->name('rate.index');
Route::get('adminlogs/{user}', [\App\Http\Controllers\Admin\AdminLogController::class, 'log'])->name('adminlog.show');
Route::post('images/store/{gallery}', [\App\Http\Controllers\Admin\ImageController::class, 'store'])->name('image.store');
@ -396,6 +397,7 @@ Route::middleware([\App\Http\Middleware\VisitorCounter::class])
Route::post('/customer/sign-in/do', [ClientController::class, 'singInDo'])->name('sign-in-do');
Route::get('/customer/sign-in', [ClientController::class, 'signIn'])->name('sign-in');
Route::get('/customer/sign-up', [ClientController::class, 'signUp'])->name('sign-up');
Route::post('/customer/sign-up/now', [ClientController::class, 'signUpNow'])->name('sign-up-now');
Route::get('/customer/send/auth-code', [ClientController::class, 'sendSms'])->name('send-sms');
Route::get('/customer/check/auth-code', [ClientController::class, 'checkAuth'])->name('check-auth');
Route::get('/customer/profile', [ClientController::class, 'profile'])->name('profile');

Loading…
Cancel
Save