This commit is contained in:
vedatakd 2019-10-18 11:34:42 +03:00
commit 5619a5e85f
3 changed files with 48 additions and 23 deletions

View File

@ -2,7 +2,9 @@
OpenClassify is the extensible and most advanced open source classified app build with Laravel and Pyrocms. OpenClassify is the extensible and most advanced open source classified app build with Laravel and Pyrocms.
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/openclassify/openclassify/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/openclassify/openclassify/?branch=master)
[![Build Status](https://scrutinizer-ci.com/g/openclassify/openclassify/badges/build.png?b=master)](https://scrutinizer-ci.com/g/openclassify/openclassify/build-status/master)
[![Code Intelligence Status](https://scrutinizer-ci.com/g/openclassify/openclassify/badges/code-intelligence.svg?b=master)](https://scrutinizer-ci.com/code-intelligence)
# Installation # Installation

View File

@ -217,7 +217,7 @@ class AdvRepository extends EntryRepository implements AdvRepositoryInterface
break; break;
} }
} else { } else {
$query = $query->orderBy('created_at', 'desc'); $query = $query->orderBy('advs_advs.created_at', 'desc');
} }

View File

@ -8,6 +8,7 @@ use Anomaly\UsersModule\User\Contract\UserRepositoryInterface;
use Anomaly\UsersModule\User\Event\UserWasLoggedIn; use Anomaly\UsersModule\User\Event\UserWasLoggedIn;
use Anomaly\UsersModule\User\User; use Anomaly\UsersModule\User\User;
use Anomaly\UsersModule\User\UserPassword; use Anomaly\UsersModule\User\UserPassword;
use http\Env\Response;
use Visiosoft\AdvsModule\Adv\AdvModel; use Visiosoft\AdvsModule\Adv\AdvModel;
use Visiosoft\AdvsModule\Http\Controller\AdvsController; use Visiosoft\AdvsModule\Http\Controller\AdvsController;
use Visiosoft\CartsModule\Saleitem\Command\ProcessSaleitem; use Visiosoft\CartsModule\Saleitem\Command\ProcessSaleitem;
@ -102,12 +103,10 @@ class UserAuthenticator
if ($response = $this->authenticate($credentials)) { if ($response = $this->authenticate($credentials)) {
if ($response instanceof UserInterface) { if ($response instanceof UserInterface) {
$this->login($response, $remember); $this->login($response, $remember);
if(isset($_COOKIE['cart'])) if (isset($_COOKIE['cart'])) {
{ foreach ($_COOKIE['cart'] as $adv => $quantity) {
foreach ($_COOKIE['cart'] as $adv => $quantity)
{
$advs = new AdvsController(); $advs = new AdvsController();
$advs->advAddCart($adv,$quantity); $advs->advAddCart($adv, $quantity);
setcookie("cart[" . $adv . "]", null, -1, '/'); setcookie("cart[" . $adv . "]", null, -1, '/');
} }
} }
@ -162,6 +161,17 @@ class UserAuthenticator
public function registerAjax(UserRepositoryInterface $users, Request $request) public function registerAjax(UserRepositoryInterface $users, Request $request)
{ {
$required_field = ['first_name', 'last_name', 'email', 'subdomain'];
foreach ($required_field as $field) {
if (!isset($request->$field) or $request->$field == "") {
return $this->responseJSON('error', $field . ' field is required!');
die;
}
}
$siteModel = new SiteModel();
$userPlan = new UserModel();
$all = $request->all(); $all = $request->all();
$email = explode('@', $all['email']); $email = explode('@', $all['email']);
@ -171,41 +181,54 @@ class UserAuthenticator
$all['activated'] = 1; //Activated User $all['activated'] = 1; //Activated User
$all['str_id'] = str_random(24); //User random key $all['str_id'] = str_random(24); //User random key
$planParams['plan'] = 24; $planParams['plan'] = 24;
if(isset($all['plan_id']))
{ //find plan id for request
if (isset($all['plan_id'])) {
$planParams['plan'] = $all['plan_id']; $planParams['plan'] = $all['plan_id'];
unset($all['plan_id']);//Demo Plan id unset($all['plan_id']);//Demo Plan id
} }
//find subdomain in allready exit
if (User::withTrashed()->where('email',$all['email'])->first() or User::withTrashed()->where('username',$all['username'])->first()) { $isSubdomain = $siteModel->getSitesBySubdomain($all['subdomain']);
return response()->json(['status' => 'error', 'message' => 'This Username or Email Registered!']); if ($this->advModel->is_enabled('cloudsite') and !is_null($isSubdomain)) {
return $this->responseJSON('error', 'This subdomain is already exists!');
} }
if (User::withTrashed()->where('email', $all['email'])->first() or User::withTrashed()->where('username', $all['username'])->first()) {
return $this->responseJSON('error', 'This Username or Email Registered!');
}
//create random password
$opassword = str_random(8); $opassword = str_random(8);
$user = User::query()->create($all);
$user_params = $all;
unset($user_params['subdomain']);
//create user
$user = User::query()->create($user_params);
$user->setAttribute('password', $opassword); $user->setAttribute('password', $opassword);
$users->save($user); $users->save($user);
$all['password'] = $opassword; //Register Password Original $all['password'] = $opassword; //Register Password Original
if(!isset($all['subdomain']))
{
$all['subdomain'] = $all['username'];
}
$all['user'] = $user; $all['user'] = $user;
$planParams['user'] = $user->id; //Register User id $planParams['user'] = $user->id; //Register User id
$planParams['name'] = $all['subdomain']; //Subscription Saved Name $planParams['name'] = $all['subdomain']; //Subscription Saved Name
if($this->advModel->is_enabled('cloudsite')) if ($this->advModel->is_enabled('cloudsite')) {
{
$userPlan = new UserModel();
$plan = $userPlan->addPlanAjaxUser($planParams); $plan = $userPlan->addPlanAjaxUser($planParams);
$siteModel = new SiteModel();
$siteModel->createSite($all['subdomain'], $user->id, $opassword, $plan->id); //Create Site $siteModel->createSite($all['subdomain'], $user->id, $opassword, $plan->id); //Create Site
$this->events->dispatch(new CreateSite($all, $this->settings)); //$this->events->dispatch(new CreateSite($all, $this->settings));
} }
return response()->json(['status' => 'success', 'message' => 'Thank you for Registering!']); return $this->responseJSON('success', 'Thank you for Registering!');
} }
public function responseJSON($type, $message)
{
return response()->json(['status' => $type, 'message' => $message]);
}
} }