¨4.0.1¨
This commit is contained in:
@@ -20,6 +20,7 @@ class ProfileTabs extends Tabs
|
||||
->add($this->newPassword());
|
||||
}
|
||||
|
||||
|
||||
private function account()
|
||||
{
|
||||
return tap(new Tab('account', trans('user::users.tabs.account')), function (Tab $tab) {
|
||||
@@ -30,6 +31,7 @@ class ProfileTabs extends Tabs
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
private function newPassword()
|
||||
{
|
||||
return tap(new Tab('newPassword', trans('user::users.tabs.new_password')), function (Tab $tab) {
|
||||
|
||||
@@ -16,6 +16,7 @@ class RoleTabs extends Tabs
|
||||
->add($this->permissions());
|
||||
}
|
||||
|
||||
|
||||
private function general()
|
||||
{
|
||||
return tap(new Tab('general', trans('user::roles.tabs.general')), function (Tab $tab) {
|
||||
@@ -26,6 +27,7 @@ class RoleTabs extends Tabs
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
private function permissions()
|
||||
{
|
||||
return tap(new Tab('permissions', trans('user::roles.tabs.permissions')), function (Tab $tab) {
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace Modules\User\Admin;
|
||||
|
||||
use Modules\Admin\Ui\AdminTable;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
|
||||
class UserTable extends AdminTable
|
||||
{
|
||||
@@ -11,12 +12,13 @@ class UserTable extends AdminTable
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $rawColumns = ['last_login'];
|
||||
protected array $rawColumns = ['last_login'];
|
||||
|
||||
|
||||
/**
|
||||
* Make table response for the resource.
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function make()
|
||||
{
|
||||
|
||||
@@ -18,6 +18,7 @@ class UserTabs extends Tabs
|
||||
->add($this->newPassword());
|
||||
}
|
||||
|
||||
|
||||
private function account()
|
||||
{
|
||||
return tap(new Tab('account', trans('user::users.tabs.account')), function (Tab $tab) {
|
||||
@@ -39,6 +40,7 @@ class UserTabs extends Tabs
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
private function permissions()
|
||||
{
|
||||
return tap(new Tab('permissions', trans('user::users.tabs.permissions')), function (Tab $tab) {
|
||||
@@ -53,9 +55,10 @@ class UserTabs extends Tabs
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
private function newPassword()
|
||||
{
|
||||
if (! request()->routeIs('admin.users.edit')) {
|
||||
if (!request()->routeIs('admin.users.edit')) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ namespace Modules\User\Contracts;
|
||||
|
||||
use Modules\User\Entities\Role;
|
||||
use Modules\User\Entities\User;
|
||||
use Cartalyst\Sentinel\Activations\ActivationInterface;
|
||||
|
||||
interface Authentication
|
||||
{
|
||||
@@ -12,44 +13,54 @@ interface Authentication
|
||||
*
|
||||
* @param array $credentials
|
||||
* @param bool $remember
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function login($credentials, $remember = false);
|
||||
|
||||
|
||||
/**
|
||||
* Register a new user.
|
||||
*
|
||||
* @param array $data
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function register($data);
|
||||
|
||||
|
||||
/**
|
||||
* Register and activate a new user.
|
||||
*
|
||||
* @param array $data
|
||||
* @return \Modules\User\Entities\User
|
||||
*
|
||||
* @return User
|
||||
*/
|
||||
public function registerAndActivate($data);
|
||||
|
||||
|
||||
/**
|
||||
* Activate the given used id.
|
||||
*
|
||||
* @param int $userId
|
||||
* @param string $code
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function activate($userId, $code);
|
||||
|
||||
|
||||
/**
|
||||
* Assign a role to the given user.
|
||||
*
|
||||
* @param \Modules\User\Entities\User $user
|
||||
* @param \Modules\User\Entities\Role $role
|
||||
* @param User $user
|
||||
* @param Role $role
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function assignRole(User $user, Role $role);
|
||||
|
||||
|
||||
/**
|
||||
* Log the user out of the application.
|
||||
*
|
||||
@@ -57,48 +68,59 @@ interface Authentication
|
||||
*/
|
||||
public function logout();
|
||||
|
||||
|
||||
/**
|
||||
* Create an activation code for the given user.
|
||||
*
|
||||
* @param \Modules\User\Entities\User $user
|
||||
* @return \Cartalyst\Sentinel\Activations\ActivationInterface
|
||||
* @param User $user
|
||||
*
|
||||
* @return ActivationInterface
|
||||
*/
|
||||
public function createActivation(User $user);
|
||||
|
||||
|
||||
/**
|
||||
* Create a reminders code for the given user.
|
||||
*
|
||||
* @param \Modules\User\Entities\User $user
|
||||
* @param User $user
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function createReminderCode(User $user);
|
||||
|
||||
|
||||
/**
|
||||
* Completes the reset password process.
|
||||
*
|
||||
* @param \Modules\User\Entities\User $user
|
||||
* @param User $user
|
||||
* @param string $code
|
||||
* @param string $password
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function completeResetPassword(User $user, $code, $password);
|
||||
|
||||
|
||||
/**
|
||||
* Determines if the current user has access to the given permissions.
|
||||
*
|
||||
* @param array|string $permissions
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function hasAccess($permissions);
|
||||
|
||||
|
||||
/**
|
||||
* Determine if the user has access to the any given permissions
|
||||
* Determine if the user has access to any given permissions
|
||||
*
|
||||
* @param array|string $permissions
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function hasAnyAccess($permissions);
|
||||
|
||||
|
||||
/**
|
||||
* Check if the user is logged in.
|
||||
*
|
||||
@@ -106,13 +128,15 @@ interface Authentication
|
||||
*/
|
||||
public function check();
|
||||
|
||||
|
||||
/**
|
||||
* Get the currently logged in user.
|
||||
* Get the currently logged-in user.
|
||||
*
|
||||
* @return \Modules\User\Entities\User
|
||||
* @return User
|
||||
*/
|
||||
public function user();
|
||||
|
||||
|
||||
/**
|
||||
* Get the ID for the currently authenticated user.
|
||||
*
|
||||
|
||||
@@ -10,13 +10,14 @@
|
||||
* This source file is subject to the 3-clause BSD License that is
|
||||
* bundled with this package in the LICENSE file.
|
||||
*
|
||||
* @package Sentinel
|
||||
* @version 2.0.12
|
||||
* @author Cartalyst LLC
|
||||
* @license BSD License (3-clause)
|
||||
* @package Sentinel
|
||||
* @version 2.0.12
|
||||
* @author Cartalyst LLC
|
||||
* @license BSD License (3-clause)
|
||||
* @copyright (c) 2011-2015, Cartalyst LLC
|
||||
* @link http://cartalyst.com
|
||||
* @link http://cartalyst.com
|
||||
*/
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
@@ -109,6 +110,7 @@ class MigrationCartalystSentinel extends Migration
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
|
||||
@@ -18,6 +18,7 @@ class AddPhoneColumnToUsersTable extends Migration
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
|
||||
@@ -19,6 +19,7 @@ class RolesTableSeeder extends Seeder
|
||||
Role::create(['name' => 'Customer']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get admin role permissions.
|
||||
*
|
||||
@@ -27,78 +28,83 @@ class RolesTableSeeder extends Seeder
|
||||
private function getAdminRolePermissions()
|
||||
{
|
||||
return [
|
||||
// users
|
||||
# users
|
||||
'admin.users.index' => true,
|
||||
'admin.users.create' => true,
|
||||
'admin.users.edit' => true,
|
||||
'admin.users.destroy' => true,
|
||||
// roles
|
||||
# roles
|
||||
'admin.roles.index' => true,
|
||||
'admin.roles.create' => true,
|
||||
'admin.roles.edit' => true,
|
||||
'admin.roles.destroy' => true,
|
||||
// products
|
||||
# products
|
||||
'admin.products.index' => true,
|
||||
'admin.products.create' => true,
|
||||
'admin.products.edit' => true,
|
||||
'admin.products.destroy' => true,
|
||||
// brands
|
||||
# brands
|
||||
'admin.brands.index' => true,
|
||||
'admin.brands.create' => true,
|
||||
'admin.brands.edit' => true,
|
||||
'admin.brands.destroy' => true,
|
||||
// attributes
|
||||
# attributes
|
||||
'admin.attributes.index' => true,
|
||||
'admin.attributes.create' => true,
|
||||
'admin.attributes.edit' => true,
|
||||
'admin.attributes.destroy' => true,
|
||||
// attribute sets
|
||||
# attribute sets
|
||||
'admin.attribute_sets.index' => true,
|
||||
'admin.attribute_sets.create' => true,
|
||||
'admin.attribute_sets.edit' => true,
|
||||
'admin.attribute_sets.destroy' => true,
|
||||
// options
|
||||
#variations
|
||||
'admin.variations.index' => true,
|
||||
'admin.variations.create' => true,
|
||||
'admin.variations.edit' => true,
|
||||
'admin.variations.destroy' => true,
|
||||
# options
|
||||
'admin.options.index' => true,
|
||||
'admin.options.create' => true,
|
||||
'admin.options.edit' => true,
|
||||
'admin.options.destroy' => true,
|
||||
// filters
|
||||
# filters
|
||||
'admin.filters.index' => true,
|
||||
'admin.filters.create' => true,
|
||||
'admin.filters.edit' => true,
|
||||
'admin.filters.destroy' => true,
|
||||
// reviews
|
||||
# reviews
|
||||
'admin.reviews.index' => true,
|
||||
'admin.reviews.create' => true,
|
||||
'admin.reviews.edit' => true,
|
||||
'admin.reviews.destroy' => true,
|
||||
// categories
|
||||
# categories
|
||||
'admin.categories.index' => true,
|
||||
'admin.categories.create' => true,
|
||||
'admin.categories.edit' => true,
|
||||
'admin.categories.destroy' => true,
|
||||
// tags
|
||||
# tags
|
||||
'admin.tags.index' => true,
|
||||
'admin.tags.create' => true,
|
||||
'admin.tags.edit' => true,
|
||||
'admin.tags.destroy' => true,
|
||||
// orders
|
||||
# orders
|
||||
'admin.orders.index' => true,
|
||||
'admin.orders.show' => true,
|
||||
'admin.orders.edit' => true,
|
||||
// flash sales
|
||||
# flash sales
|
||||
'admin.flash_sales.index' => true,
|
||||
'admin.flash_sales.create' => true,
|
||||
'admin.flash_sales.edit' => true,
|
||||
'admin.flash_sales.destroy' => true,
|
||||
// transactions
|
||||
# transactions
|
||||
'admin.transactions.index' => true,
|
||||
// coupons
|
||||
# coupons
|
||||
'admin.coupons.index' => true,
|
||||
'admin.coupons.create' => true,
|
||||
'admin.coupons.edit' => true,
|
||||
'admin.coupons.destroy' => true,
|
||||
// menus
|
||||
# menus
|
||||
'admin.menus.index' => true,
|
||||
'admin.menus.create' => true,
|
||||
'admin.menus.edit' => true,
|
||||
@@ -107,39 +113,39 @@ class RolesTableSeeder extends Seeder
|
||||
'admin.menu_items.create' => true,
|
||||
'admin.menu_items.edit' => true,
|
||||
'admin.menu_items.destroy' => true,
|
||||
// Media
|
||||
# Media
|
||||
'admin.media.index' => true,
|
||||
'admin.media.create' => true,
|
||||
'admin.media.destroy' => true,
|
||||
// pages
|
||||
# pages
|
||||
'admin.pages.index' => true,
|
||||
'admin.pages.create' => true,
|
||||
'admin.pages.edit' => true,
|
||||
'admin.pages.destroy' => true,
|
||||
// currency rates
|
||||
# currency rates
|
||||
'admin.currency_rates.index' => true,
|
||||
'admin.currency_rates.edit' => true,
|
||||
// tax
|
||||
# tax
|
||||
'admin.taxes.index' => true,
|
||||
'admin.taxes.create' => true,
|
||||
'admin.taxes.edit' => true,
|
||||
'admin.taxes.destroy' => true,
|
||||
// translations
|
||||
# translations
|
||||
'admin.translations.index' => true,
|
||||
'admin.translations.edit' => true,
|
||||
// appearance
|
||||
# appearance
|
||||
'admin.sliders.index' => true,
|
||||
'admin.sliders.create' => true,
|
||||
'admin.sliders.edit' => true,
|
||||
'admin.sliders.destroy' => true,
|
||||
// import
|
||||
# import
|
||||
'admin.importer.index' => true,
|
||||
'admin.importer.create' => true,
|
||||
// reports
|
||||
# reports
|
||||
'admin.reports.index' => true,
|
||||
// settings
|
||||
# settings
|
||||
'admin.settings.edit' => true,
|
||||
// storefront
|
||||
# storefront
|
||||
'admin.storefront.edit' => true,
|
||||
];
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace Modules\User\Entities;
|
||||
|
||||
use Modules\Admin\Ui\AdminTable;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Modules\User\Repositories\Permission;
|
||||
use Cartalyst\Sentinel\Roles\EloquentRole;
|
||||
use Modules\Support\Eloquent\Translatable;
|
||||
@@ -26,6 +27,7 @@ class Role extends EloquentRole
|
||||
*/
|
||||
protected $translatedAttributes = ['name'];
|
||||
|
||||
|
||||
/**
|
||||
* Get a list of all roles.
|
||||
*
|
||||
@@ -36,20 +38,23 @@ class Role extends EloquentRole
|
||||
return static::select('id')->get()->pluck('name', 'id');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The Users relationship.
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
||||
* @return BelongsToMany
|
||||
*/
|
||||
public function users(): BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(User::class, 'user_roles', 'role_id', 'user_id')->withTimestamps();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set role's permissions.
|
||||
*
|
||||
* @param array $permissions
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setPermissionsAttribute(array $permissions)
|
||||
@@ -57,10 +62,11 @@ class Role extends EloquentRole
|
||||
$this->attributes['permissions'] = Permission::prepare($permissions);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get table data for the resource
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function table()
|
||||
{
|
||||
|
||||
@@ -4,6 +4,7 @@ namespace Modules\User\Entities;
|
||||
|
||||
use Modules\Order\Entities\Order;
|
||||
use Modules\User\Admin\UserTable;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Modules\Review\Entities\Review;
|
||||
use Illuminate\Auth\Authenticatable;
|
||||
use Modules\Address\Entities\Address;
|
||||
@@ -11,7 +12,9 @@ use Modules\Product\Entities\Product;
|
||||
use Modules\User\Repositories\Permission;
|
||||
use Cartalyst\Sentinel\Users\EloquentUser;
|
||||
use Modules\Address\Entities\DefaultAddress;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Cartalyst\Sentinel\Laravel\Facades\Activation;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
|
||||
|
||||
@@ -40,21 +43,25 @@ class User extends EloquentUser implements AuthenticatableContract
|
||||
*/
|
||||
protected $dates = ['last_login'];
|
||||
|
||||
|
||||
public static function registered($email)
|
||||
{
|
||||
return static::where('email', $email)->exists();
|
||||
}
|
||||
|
||||
|
||||
public static function findByEmail($email)
|
||||
{
|
||||
return static::where('email', $email)->first();
|
||||
}
|
||||
|
||||
|
||||
public static function totalCustomers()
|
||||
{
|
||||
return Role::findOrNew(setting('customer_role'))->users()->count();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Login the user.
|
||||
*
|
||||
@@ -65,6 +72,7 @@ class User extends EloquentUser implements AuthenticatableContract
|
||||
return auth()->login($this);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Determine if the user is a customer.
|
||||
*
|
||||
@@ -79,10 +87,36 @@ class User extends EloquentUser implements AuthenticatableContract
|
||||
return $this->hasRoleId(setting('customer_role'));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Checks if a user belongs to the given Role Name.
|
||||
*
|
||||
* @param string $name
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function hasRoleName($name)
|
||||
{
|
||||
return $this->roles()->whereTranslation('name', $name)->count() !== 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the roles of the user.
|
||||
*
|
||||
* @return BelongsToMany
|
||||
*/
|
||||
public function roles(): BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(Role::class, 'user_roles')->withTimestamps();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Checks if a user belongs to the given Role ID.
|
||||
*
|
||||
* @param int $roleId
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function hasRoleId($roleId)
|
||||
@@ -90,16 +124,6 @@ class User extends EloquentUser implements AuthenticatableContract
|
||||
return $this->roles()->whereId($roleId)->count() !== 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a user belongs to the given Role Name.
|
||||
*
|
||||
* @param string $name
|
||||
* @return bool
|
||||
*/
|
||||
public function hasRoleName($name)
|
||||
{
|
||||
return $this->roles()->whereTranslation('name', $name)->count() !== 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the current user is activated.
|
||||
@@ -111,77 +135,64 @@ class User extends EloquentUser implements AuthenticatableContract
|
||||
return Activation::completed($this);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the recent orders of the user.
|
||||
*
|
||||
* @param int $take
|
||||
* @return \Illuminate\Database\Eloquent\Collection
|
||||
*
|
||||
* @return Collection
|
||||
*/
|
||||
public function recentOrders($take)
|
||||
{
|
||||
return $this->orders()->latest()->take($take)->get();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the roles of the user.
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
||||
*/
|
||||
public function roles(): BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(Role::class, 'user_roles')->withTimestamps();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the orders of the user.
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
||||
* @return HasMany
|
||||
*/
|
||||
public function orders()
|
||||
{
|
||||
return $this->hasMany(Order::class, 'customer_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the wishlist of the user.
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
||||
*/
|
||||
public function wishlist()
|
||||
{
|
||||
return $this->belongsToMany(Product::class, 'wish_lists')->withTimestamps();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the default address of the user.
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
||||
* @return HasMany
|
||||
*/
|
||||
public function defaultAddress()
|
||||
{
|
||||
return $this->hasOne(DefaultAddress::class, 'customer_id')->withDefault();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the addresses of the user.
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
||||
* @return HasMany
|
||||
*/
|
||||
public function addresses()
|
||||
{
|
||||
return $this->hasMany(Address::class, 'customer_id');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the reviews of the user.
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
||||
* @return HasMany
|
||||
*/
|
||||
public function reviews()
|
||||
{
|
||||
return $this->hasMany(Review::class, 'reviewer_id');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the full name of the user.
|
||||
*
|
||||
@@ -192,10 +203,12 @@ class User extends EloquentUser implements AuthenticatableContract
|
||||
return "{$this->first_name} {$this->last_name}";
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set user's permissions.
|
||||
*
|
||||
* @param array $permissions
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setPermissionsAttribute(array $permissions)
|
||||
@@ -203,10 +216,12 @@ class User extends EloquentUser implements AuthenticatableContract
|
||||
$this->attributes['permissions'] = Permission::prepare($permissions);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Determine if the user has access to the given permissions.
|
||||
*
|
||||
* @param array|string $permissions
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function hasAccess($permissions)
|
||||
@@ -216,10 +231,12 @@ class User extends EloquentUser implements AuthenticatableContract
|
||||
return $this->getPermissionsInstance()->hasAccess($permissions);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Determine if the user has access to the any given permissions
|
||||
* Determine if the user has access to any given permissions
|
||||
*
|
||||
* @param array|string $permissions
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function hasAnyAccess($permissions)
|
||||
@@ -229,15 +246,28 @@ class User extends EloquentUser implements AuthenticatableContract
|
||||
return $this->getPermissionsInstance()->hasAnyAccess($permissions);
|
||||
}
|
||||
|
||||
|
||||
public function wishlistHas($productId)
|
||||
{
|
||||
return self::wishlist()->where('product_id', $productId)->exists();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the wishlist of the user.
|
||||
*
|
||||
* @return BelongsToMany
|
||||
*/
|
||||
public function wishlist()
|
||||
{
|
||||
return $this->belongsToMany(Product::class, 'wish_lists')->withTimestamps();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get table data for the resource
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function table()
|
||||
{
|
||||
|
||||
@@ -12,14 +12,16 @@ class CustomerRegistered
|
||||
/**
|
||||
* The instance of user.
|
||||
*
|
||||
* @var \Modules\User\Entities\User
|
||||
* @var User
|
||||
*/
|
||||
public $user;
|
||||
|
||||
|
||||
/**
|
||||
* Create a new event instance.
|
||||
*
|
||||
* @param \Modules\User\Entities\User $user
|
||||
* @param User $user
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(User $user)
|
||||
|
||||
@@ -12,14 +12,15 @@ class UserHasActivatedAccount
|
||||
/**
|
||||
* The user instance.
|
||||
*
|
||||
* @var \Modules\User\Entities\User
|
||||
* @var User
|
||||
*/
|
||||
public $user;
|
||||
|
||||
|
||||
/**
|
||||
* Create a new event instance.
|
||||
*
|
||||
* @param \Modules\User\Entities\User $user
|
||||
* @param User $user
|
||||
*/
|
||||
public function __construct(User $user)
|
||||
{
|
||||
|
||||
@@ -12,14 +12,15 @@ class UserHasRegistered
|
||||
/**
|
||||
* The user instance.
|
||||
*
|
||||
* @var \Modules\User\Entities\User
|
||||
* @var User
|
||||
*/
|
||||
public $user;
|
||||
|
||||
|
||||
/**
|
||||
* Create a new event instance.
|
||||
*
|
||||
* @param \Modules\User\Entities\User $user
|
||||
* @param User $user
|
||||
*/
|
||||
public function __construct(User $user)
|
||||
{
|
||||
|
||||
@@ -9,36 +9,28 @@ use Cartalyst\Sentinel\Laravel\Facades\Sentinel as SentinelFacade;
|
||||
|
||||
class Sentinel implements Guard
|
||||
{
|
||||
/**
|
||||
* Determine if the current user is authenticated.
|
||||
*
|
||||
* @return \Modules\User\Entities\User|bool
|
||||
*/
|
||||
public function check()
|
||||
{
|
||||
return SentinelFacade::check();
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the current user is a guest.
|
||||
*
|
||||
* @return \Modules\User\Entities\User|bool
|
||||
* @return User|bool
|
||||
*/
|
||||
public function guest()
|
||||
{
|
||||
return SentinelFacade::guest();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the currently authenticated user.
|
||||
*
|
||||
* @return \Illuminate\Contracts\Auth\Authenticatable|null
|
||||
* @return Authenticatable|null
|
||||
*/
|
||||
public function user()
|
||||
{
|
||||
return SentinelFacade::getUser();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the ID for the currently authenticated user.
|
||||
*
|
||||
@@ -53,10 +45,23 @@ class Sentinel implements Guard
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Determine if the current user is authenticated.
|
||||
*
|
||||
* @return User|bool
|
||||
*/
|
||||
public function check()
|
||||
{
|
||||
return SentinelFacade::check();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Validate a user's credentials.
|
||||
*
|
||||
* @param array $credentials
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function validate(array $credentials = [])
|
||||
@@ -64,40 +69,46 @@ class Sentinel implements Guard
|
||||
return SentinelFacade::validForCreation($credentials);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the current user.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Auth\Authenticatable $user
|
||||
* @param \Modules\User\Entities\User|bool
|
||||
* @param Authenticatable $user
|
||||
* @param User|bool
|
||||
*/
|
||||
public function setUser(Authenticatable $user)
|
||||
{
|
||||
return SentinelFacade::login($user);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Alias to set the current user.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Auth\Authenticatable $user
|
||||
* @return \Modules\User\Entities\User|bool
|
||||
* @param Authenticatable $user
|
||||
*
|
||||
* @return User|bool
|
||||
*/
|
||||
public function login(Authenticatable $user)
|
||||
{
|
||||
return $this->setUser($user);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Attempt to logging in user.
|
||||
*
|
||||
* @param array $credentials
|
||||
* @param bool $remember
|
||||
* @return \Modules\User\Entities\User|bool
|
||||
*
|
||||
* @return User|bool
|
||||
*/
|
||||
public function attempt(array $credentials, $remember = false)
|
||||
{
|
||||
return SentinelFacade::authenticate($credentials, $remember);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Logout user.
|
||||
*
|
||||
@@ -108,11 +119,13 @@ class Sentinel implements Guard
|
||||
return SentinelFacade::logout();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Login using user id.
|
||||
*
|
||||
* @param int $userId
|
||||
* @return \Modules\User\Entities\User|bool
|
||||
*
|
||||
* @return User|bool
|
||||
*/
|
||||
public function loginUsingId($userId)
|
||||
{
|
||||
|
||||
@@ -2,12 +2,36 @@
|
||||
|
||||
namespace Modules\User\Http\Controllers\Admin;
|
||||
|
||||
use Illuminate\Http\Response;
|
||||
use Modules\User\Entities\User;
|
||||
use Modules\User\Http\Controllers\BaseAuthController;
|
||||
|
||||
class AuthController extends BaseAuthController
|
||||
{
|
||||
/**
|
||||
* Where to redirect users after login..
|
||||
* Show login form.
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function getLogin()
|
||||
{
|
||||
return view('user::admin.auth.login');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Show reset password form.
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function getReset()
|
||||
{
|
||||
return view('user::admin.auth.reset.begin');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Where to redirect users after login.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
@@ -16,6 +40,7 @@ class AuthController extends BaseAuthController
|
||||
return route('admin.dashboard.index');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The login URL.
|
||||
*
|
||||
@@ -26,31 +51,13 @@ class AuthController extends BaseAuthController
|
||||
return route('admin.login');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show login form.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function getLogin()
|
||||
{
|
||||
return view('user::admin.auth.login');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show reset password form.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function getReset()
|
||||
{
|
||||
return view('user::admin.auth.reset.begin');
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset complete form route.
|
||||
*
|
||||
* @param \Modules\User\Entities\User $user
|
||||
* @param User $user
|
||||
* @param string $code
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function resetCompleteRoute($user, $code)
|
||||
@@ -58,6 +65,7 @@ class AuthController extends BaseAuthController
|
||||
return route('admin.reset.complete', [$user->email, $code]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Password reset complete view.
|
||||
*
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
namespace Modules\User\Http\Controllers\Admin;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
use Modules\Admin\Ui\Facades\TabManager;
|
||||
use Modules\User\Http\Requests\UpdateProfileRequest;
|
||||
|
||||
@@ -10,8 +12,9 @@ class ProfileController
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
* @param int $id
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function edit()
|
||||
{
|
||||
@@ -20,11 +23,13 @@ class ProfileController
|
||||
return view('user::admin.profile.edit', compact('tabs'));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \Modules\User\Http\Requests\UpdateProfileRequest $request
|
||||
* @return \Illuminate\Http\Response
|
||||
* @param UpdateProfileRequest $request
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function update(UpdateProfileRequest $request)
|
||||
{
|
||||
@@ -32,15 +37,17 @@ class ProfileController
|
||||
|
||||
auth()->user()->update($request->all());
|
||||
|
||||
return back()->withSuccess(trans('admin::messages.resource_saved', [
|
||||
return back()->withSuccess(trans('admin::messages.resource_updated', [
|
||||
'resource' => trans('user::users.profile'),
|
||||
]));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Bcrypt user password.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param Request $request
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function bcryptPassword($request)
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace Modules\User\Http\Controllers\Admin;
|
||||
|
||||
use Illuminate\Http\Response;
|
||||
use Modules\User\Entities\User;
|
||||
use Modules\Admin\Traits\HasCrudActions;
|
||||
use Modules\User\Http\Requests\SaveUserRequest;
|
||||
@@ -39,11 +40,13 @@ class UserController
|
||||
*/
|
||||
protected $validation = SaveUserRequest::class;
|
||||
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param \Modules\User\Http\Requests\SaveUserRequest $request
|
||||
* @return \Illuminate\Http\Response
|
||||
* @param SaveUserRequest $request
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function store(SaveUserRequest $request)
|
||||
{
|
||||
@@ -56,15 +59,17 @@ class UserController
|
||||
Activation::complete($user, Activation::create($user)->code);
|
||||
|
||||
return redirect()->route('admin.users.index')
|
||||
->withSuccess(trans('admin::messages.resource_saved', ['resource' => trans('user::users.user')]));
|
||||
->withSuccess(trans('admin::messages.resource_created', ['resource' => trans('user::users.user')]));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param int $id
|
||||
* @param \Modules\User\Http\Requests\SaveUserRequest $request
|
||||
* @return \Illuminate\Http\Response
|
||||
* @param SaveUserRequest $request
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function update($id, SaveUserRequest $request)
|
||||
{
|
||||
@@ -80,7 +85,7 @@ class UserController
|
||||
|
||||
$user->roles()->sync($request->roles);
|
||||
|
||||
if (! Activation::completed($user) && $request->activated === '1') {
|
||||
if (!Activation::completed($user) && $request->activated === '1') {
|
||||
Activation::complete($user, Activation::create($user)->code);
|
||||
}
|
||||
|
||||
@@ -89,6 +94,6 @@ class UserController
|
||||
}
|
||||
|
||||
return redirect()->route('admin.users.index')
|
||||
->withSuccess(trans('admin::messages.resource_saved', ['resource' => trans('user::users.user')]));
|
||||
->withSuccess(trans('admin::messages.resource_updated', ['resource' => trans('user::users.user')]));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
namespace Modules\User\Http\Controllers\Admin;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
use Modules\User\Entities\User;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use Modules\User\Mail\ResetPasswordEmail;
|
||||
@@ -12,8 +14,9 @@ class UserResetPasswordController
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
* @param Request $request
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function store($id, Authentication $auth)
|
||||
{
|
||||
@@ -28,6 +31,7 @@ class UserResetPasswordController
|
||||
->withSuccess(trans('user::messages.users.reset_password_email_sent'));
|
||||
}
|
||||
|
||||
|
||||
private function getResetCompleteURL($user, $code)
|
||||
{
|
||||
return route('admin.reset.complete', [$user->email, $code]);
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace Modules\User\Http\Controllers;
|
||||
|
||||
use Exception;
|
||||
use Illuminate\Http\Response;
|
||||
use Modules\Page\Entities\Page;
|
||||
use Modules\User\Entities\User;
|
||||
use Modules\User\LoginProvider;
|
||||
@@ -11,30 +12,10 @@ use Laravel\Socialite\Facades\Socialite;
|
||||
|
||||
class AuthController extends BaseAuthController
|
||||
{
|
||||
/**
|
||||
* Where to redirect users after login..
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function redirectTo()
|
||||
{
|
||||
return route('account.dashboard.index');
|
||||
}
|
||||
|
||||
/**
|
||||
* The login URL.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function loginUrl()
|
||||
{
|
||||
return route('login');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show login form.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
* @return Response
|
||||
*/
|
||||
public function getLogin()
|
||||
{
|
||||
@@ -43,30 +24,34 @@ class AuthController extends BaseAuthController
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Redirect the user to the given provider authentication page.
|
||||
*
|
||||
* @param string $provider
|
||||
* @return \Illuminate\Http\Response
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function redirectToProvider($provider)
|
||||
{
|
||||
if (! LoginProvider::isEnable($provider)) {
|
||||
if (!LoginProvider::isEnable($provider)) {
|
||||
abort(404);
|
||||
}
|
||||
|
||||
return Socialite::driver($provider)->redirect();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Obtain the user information from the given provider.
|
||||
*
|
||||
* @param string $provider
|
||||
* @return \Illuminate\Http\Response
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function handleProviderCallback($provider)
|
||||
{
|
||||
if (! LoginProvider::isEnable($provider)) {
|
||||
if (!LoginProvider::isEnable($provider)) {
|
||||
abort(404);
|
||||
}
|
||||
|
||||
@@ -101,15 +86,11 @@ class AuthController extends BaseAuthController
|
||||
return redirect($this->redirectTo());
|
||||
}
|
||||
|
||||
private function extractName($name)
|
||||
{
|
||||
return explode(' ', $name, 2);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show registrations form.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
* @return Response
|
||||
*/
|
||||
public function getRegister()
|
||||
{
|
||||
@@ -119,6 +100,71 @@ class AuthController extends BaseAuthController
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Show reset password form.
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function getReset()
|
||||
{
|
||||
return view('public.auth.reset.begin');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Where to redirect users after login.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function redirectTo()
|
||||
{
|
||||
return route('account.dashboard.index');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The login URL.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function loginUrl()
|
||||
{
|
||||
return route('login');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Reset complete form route.
|
||||
*
|
||||
* @param User $user
|
||||
* @param string $code
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function resetCompleteRoute($user, $code)
|
||||
{
|
||||
return route('reset.complete', [$user->email, $code]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Password reset complete view.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function resetCompleteView()
|
||||
{
|
||||
return view('public.auth.reset.complete');
|
||||
}
|
||||
|
||||
|
||||
private function extractName($name)
|
||||
{
|
||||
return explode(' ', $name, 2);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get privacy page url.
|
||||
*
|
||||
@@ -130,36 +176,4 @@ class AuthController extends BaseAuthController
|
||||
return Page::urlForPage(setting('storefront_privacy_page'));
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Show reset password form.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function getReset()
|
||||
{
|
||||
return view('public.auth.reset.begin');
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset complete form route.
|
||||
*
|
||||
* @param \Modules\User\Entities\User $user
|
||||
* @param string $code
|
||||
* @return string
|
||||
*/
|
||||
protected function resetCompleteRoute($user, $code)
|
||||
{
|
||||
return route('reset.complete', [$user->email, $code]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Password reset complete view.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function resetCompleteView()
|
||||
{
|
||||
return view('public.auth.reset.complete');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace Modules\User\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Response;
|
||||
use Modules\User\Entities\Role;
|
||||
use Modules\User\Entities\User;
|
||||
use Illuminate\Routing\Controller;
|
||||
@@ -21,12 +22,13 @@ abstract class BaseAuthController extends Controller
|
||||
/**
|
||||
* The Authentication instance.
|
||||
*
|
||||
* @var \Modules\User\Contracts\Authentication
|
||||
* @var Authentication
|
||||
*/
|
||||
protected $auth;
|
||||
|
||||
|
||||
/**
|
||||
* @param \Modules\User\Contracts\Authentication $auth
|
||||
* @param Authentication $auth
|
||||
*/
|
||||
public function __construct(Authentication $auth)
|
||||
{
|
||||
@@ -35,39 +37,29 @@ abstract class BaseAuthController extends Controller
|
||||
$this->middleware('guest')->except('getLogout');
|
||||
}
|
||||
|
||||
/**
|
||||
* Where to redirect users after login..
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
abstract protected function redirectTo();
|
||||
|
||||
/**
|
||||
* The login route.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
abstract protected function loginUrl();
|
||||
|
||||
/**
|
||||
* Show login form.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
* @return Response
|
||||
*/
|
||||
abstract public function getLogin();
|
||||
|
||||
|
||||
/**
|
||||
* Show reset password form.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
* @return Response
|
||||
*/
|
||||
abstract public function getReset();
|
||||
|
||||
|
||||
/**
|
||||
* Login a user.
|
||||
*
|
||||
* @param \Modules\User\Http\Requests\LoginRequest $request
|
||||
* @return \Illuminate\Http\Response
|
||||
* @param LoginRequest $request
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function postLogin(LoginRequest $request)
|
||||
{
|
||||
@@ -75,9 +67,9 @@ abstract class BaseAuthController extends Controller
|
||||
$loggedIn = $this->auth->login([
|
||||
'email' => $request->email,
|
||||
'password' => $request->password,
|
||||
], (bool) $request->get('remember_me', false));
|
||||
], (bool)$request->get('remember_me', false));
|
||||
|
||||
if (! $loggedIn) {
|
||||
if (!$loggedIn) {
|
||||
return back()->withInput()
|
||||
->withError(trans('user::messages.users.invalid_credentials'));
|
||||
}
|
||||
@@ -92,6 +84,7 @@ abstract class BaseAuthController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Logout current user.
|
||||
*
|
||||
@@ -104,11 +97,13 @@ abstract class BaseAuthController extends Controller
|
||||
return redirect($this->loginUrl());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Register a user.
|
||||
*
|
||||
* @param \Modules\User\Http\Requests\RegisterRequest $request
|
||||
* @return \Illuminate\Http\Response
|
||||
* @param RegisterRequest $request
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function postRegister(RegisterRequest $request)
|
||||
{
|
||||
@@ -128,20 +123,13 @@ abstract class BaseAuthController extends Controller
|
||||
->withSuccess(trans('user::messages.users.account_created'));
|
||||
}
|
||||
|
||||
protected function assignCustomerRole($user)
|
||||
{
|
||||
$role = Role::findOrNew(setting('customer_role'));
|
||||
|
||||
if ($role->exists) {
|
||||
$this->auth->assignRole($user, $role);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Start the reset password process.
|
||||
*
|
||||
* @param \Modules\User\Http\Requests\PasswordResetRequest $request
|
||||
* @return \Illuminate\Http\Response
|
||||
* @param PasswordResetRequest $request
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function postReset(PasswordResetRequest $request)
|
||||
{
|
||||
@@ -160,28 +148,14 @@ abstract class BaseAuthController extends Controller
|
||||
return back()->withSuccess(trans('user::messages.users.check_email_to_reset_password'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset complete form route.
|
||||
*
|
||||
* @param \Modules\User\Entities\User $user
|
||||
* @param string $code
|
||||
* @return string
|
||||
*/
|
||||
abstract protected function resetCompleteRoute($user, $code);
|
||||
|
||||
/**
|
||||
* Password reset complete view.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
abstract protected function resetCompleteView();
|
||||
|
||||
/**
|
||||
* Show reset password complete form.
|
||||
*
|
||||
* @param string $email
|
||||
* @param string $code
|
||||
* @return \Illuminate\Http\Response
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function getResetComplete($email, $code)
|
||||
{
|
||||
@@ -195,25 +169,15 @@ abstract class BaseAuthController extends Controller
|
||||
return $this->resetCompleteView()->with(compact('user', 'code'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine the given reset code is invalid.
|
||||
*
|
||||
* @param \Modules\User\Entities\User $user
|
||||
* @param string $code
|
||||
* @return bool
|
||||
*/
|
||||
private function invalidResetCode($user, $code)
|
||||
{
|
||||
return $user->reminders()->where('code', $code)->doesntExist();
|
||||
}
|
||||
|
||||
/**
|
||||
* Complete the reset password process.
|
||||
*
|
||||
* @param string $email
|
||||
* @param string $code
|
||||
* @param \Modules\User\Http\Requests\ResetCompleteRequest $request
|
||||
* @return \Illuminate\Http\Response
|
||||
* @param ResetCompleteRequest $request
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function postResetComplete($email, $code, ResetCompleteRequest $request)
|
||||
{
|
||||
@@ -221,7 +185,7 @@ abstract class BaseAuthController extends Controller
|
||||
|
||||
$completed = $this->auth->completeResetPassword($user, $code, $request->new_password);
|
||||
|
||||
if (! $completed) {
|
||||
if (!$completed) {
|
||||
return back()->withInput()
|
||||
->withError(trans('user::messages.users.invalid_reset_code'));
|
||||
}
|
||||
@@ -229,4 +193,63 @@ abstract class BaseAuthController extends Controller
|
||||
return redirect($this->loginUrl())
|
||||
->withSuccess(trans('user::messages.users.password_has_been_reset'));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Where to redirect users after login.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
abstract protected function redirectTo();
|
||||
|
||||
|
||||
/**
|
||||
* The login route.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
abstract protected function loginUrl();
|
||||
|
||||
|
||||
protected function assignCustomerRole($user)
|
||||
{
|
||||
$role = Role::findOrNew(setting('customer_role'));
|
||||
|
||||
if ($role->exists) {
|
||||
$this->auth->assignRole($user, $role);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Reset complete form route.
|
||||
*
|
||||
* @param User $user
|
||||
* @param string $code
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
abstract protected function resetCompleteRoute($user, $code);
|
||||
|
||||
|
||||
/**
|
||||
* Password reset complete view.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
abstract protected function resetCompleteView();
|
||||
|
||||
|
||||
/**
|
||||
* Determine the given reset code is invalid.
|
||||
*
|
||||
* @param User $user
|
||||
* @param string $code
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
private function invalidResetCode($user, $code)
|
||||
{
|
||||
return $user->reminders()->where('code', $code)->doesntExist();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ class LoginRequest extends Request
|
||||
*/
|
||||
protected $availableAttributes = 'user::attributes.users';
|
||||
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
|
||||
@@ -13,6 +13,7 @@ class PasswordResetRequest extends Request
|
||||
*/
|
||||
protected $availableAttributes = 'user::attributes.users';
|
||||
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
|
||||
@@ -13,6 +13,7 @@ class RegisterRequest extends Request
|
||||
*/
|
||||
protected $availableAttributes = 'user::attributes.users';
|
||||
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
|
||||
@@ -13,6 +13,7 @@ class ResetCompleteRequest extends Request
|
||||
*/
|
||||
protected $availableAttributes = 'user::attributes.users';
|
||||
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
|
||||
@@ -13,6 +13,7 @@ class SaveRoleRequest extends Request
|
||||
*/
|
||||
protected $availableAttributes = 'user::attributes.roles';
|
||||
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
|
||||
@@ -14,6 +14,7 @@ class SaveUserRequest extends Request
|
||||
*/
|
||||
protected $availableAttributes = 'user::attributes.users';
|
||||
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
@@ -31,6 +32,7 @@ class SaveUserRequest extends Request
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
private function emailUniqueRule()
|
||||
{
|
||||
$rule = Rule::unique('users');
|
||||
|
||||
@@ -14,6 +14,7 @@ class UpdateProfileRequest extends Request
|
||||
*/
|
||||
protected $availableAttributes = 'user::attributes.users';
|
||||
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
@@ -30,6 +31,7 @@ class UpdateProfileRequest extends Request
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Hash the user password against the bcrypt algorithm.
|
||||
*
|
||||
|
||||
@@ -2,12 +2,15 @@
|
||||
|
||||
namespace Modules\User\Http\ViewComposers;
|
||||
|
||||
use Illuminate\View\View;
|
||||
|
||||
class CurrentUserComposer
|
||||
{
|
||||
/**
|
||||
* Bind data to the view.
|
||||
*
|
||||
* @param \Illuminate\View\View $view
|
||||
* @param View $view
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function compose($view)
|
||||
|
||||
@@ -12,13 +12,14 @@ class SendWelcomeEmail
|
||||
/**
|
||||
* Handle the event.
|
||||
*
|
||||
* @param \Modules\User\Events\CustomerRegistered $event
|
||||
* @param CustomerRegistered $event
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle(CustomerRegistered $event)
|
||||
{
|
||||
try {
|
||||
if (! setting('welcome_email')) {
|
||||
if (!setting('welcome_email')) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -12,13 +12,14 @@ class SendWelcomeSms
|
||||
/**
|
||||
* Handle the event.
|
||||
*
|
||||
* @param \Modules\User\Events\CustomerRegistered $event
|
||||
* @param CustomerRegistered $event
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle(CustomerRegistered $event)
|
||||
{
|
||||
try {
|
||||
if (! setting('welcome_sms')) {
|
||||
if (!setting('welcome_sms')) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -31,6 +32,7 @@ class SendWelcomeSms
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private function message(User $user)
|
||||
{
|
||||
return trans('sms::messages.welcome', ['first_name' => $user->first_name]);
|
||||
|
||||
@@ -6,6 +6,7 @@ class LoginProvider
|
||||
{
|
||||
private static $providers = ['facebook', 'google'];
|
||||
|
||||
|
||||
public static function add($provider)
|
||||
{
|
||||
array_push(self::$providers, $provider);
|
||||
@@ -13,20 +14,23 @@ class LoginProvider
|
||||
return self::$providers;
|
||||
}
|
||||
|
||||
|
||||
public static function all()
|
||||
{
|
||||
return self::$providers;
|
||||
}
|
||||
|
||||
|
||||
public static function isEnable($provider)
|
||||
{
|
||||
return in_array($provider, self::enabled());
|
||||
}
|
||||
|
||||
|
||||
public static function enabled()
|
||||
{
|
||||
return array_filter(self::$providers, function ($provider) {
|
||||
return setting("{$provider}_login_enabled");
|
||||
});
|
||||
}
|
||||
|
||||
public static function isEnable($provider)
|
||||
{
|
||||
return in_array($provider, self::enabled());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ namespace Modules\User\Mail;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Mail\Mailable;
|
||||
use Modules\User\Entities\User;
|
||||
use Modules\Media\Entities\File;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
@@ -15,7 +16,7 @@ class ResetPasswordEmail extends Mailable implements ShouldQueue
|
||||
/**
|
||||
* The user entity.
|
||||
*
|
||||
* @var \Modules\User\Entities\User
|
||||
* @var User
|
||||
*/
|
||||
public $user;
|
||||
|
||||
@@ -26,10 +27,11 @@ class ResetPasswordEmail extends Mailable implements ShouldQueue
|
||||
*/
|
||||
public $url;
|
||||
|
||||
|
||||
/**
|
||||
* Create a new instance.
|
||||
*
|
||||
* @param \Modules\User\Entities\User $user
|
||||
* @param User $user
|
||||
* @param string $url
|
||||
*
|
||||
* @return void
|
||||
@@ -40,6 +42,7 @@ class ResetPasswordEmail extends Mailable implements ShouldQueue
|
||||
$this->url = $url;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Build the message.
|
||||
*
|
||||
@@ -53,6 +56,7 @@ class ResetPasswordEmail extends Mailable implements ShouldQueue
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
private function getViewName()
|
||||
{
|
||||
return 'reset_password' . (is_rtl() ? '_rtl' : '');
|
||||
|
||||
@@ -12,14 +12,16 @@ class Welcome extends Mailable implements ShouldQueue
|
||||
{
|
||||
use Queueable, SerializesModels;
|
||||
|
||||
private $firstName;
|
||||
public $heading;
|
||||
public $text;
|
||||
private $firstName;
|
||||
|
||||
|
||||
/**
|
||||
* Create a new instance.
|
||||
*
|
||||
* @param string $firstName
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($firstName)
|
||||
@@ -29,6 +31,7 @@ class Welcome extends Mailable implements ShouldQueue
|
||||
$this->text = trans('user::mail.account_created');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Build the message.
|
||||
*
|
||||
@@ -42,6 +45,7 @@ class Welcome extends Mailable implements ShouldQueue
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
private function getViewName()
|
||||
{
|
||||
return 'text' . (is_rtl() ? '_rtl' : '');
|
||||
|
||||
@@ -2,6 +2,9 @@
|
||||
|
||||
namespace Modules\User\Providers;
|
||||
|
||||
use Modules\User\Listeners\SendWelcomeSms;
|
||||
use Modules\User\Events\CustomerRegistered;
|
||||
use Modules\User\Listeners\SendWelcomeEmail;
|
||||
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
|
||||
|
||||
class EventServiceProvider extends ServiceProvider
|
||||
@@ -12,9 +15,9 @@ class EventServiceProvider extends ServiceProvider
|
||||
* @var array
|
||||
*/
|
||||
protected $listen = [
|
||||
\Modules\User\Events\CustomerRegistered::class => [
|
||||
\Modules\User\Listeners\SendWelcomeEmail::class,
|
||||
\Modules\User\Listeners\SendWelcomeSms::class,
|
||||
CustomerRegistered::class => [
|
||||
SendWelcomeEmail::class,
|
||||
SendWelcomeSms::class,
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ class SocialLoginServiceProvider extends ServiceProvider
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
if (! config('app.installed')) {
|
||||
if (!config('app.installed')) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ class SocialLoginServiceProvider extends ServiceProvider
|
||||
$this->setupGoogle();
|
||||
}
|
||||
|
||||
|
||||
private function setupFacebook()
|
||||
{
|
||||
$this->app['config']->set('services.facebook', [
|
||||
@@ -30,6 +31,7 @@ class SocialLoginServiceProvider extends ServiceProvider
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
private function setupGoogle()
|
||||
{
|
||||
$this->app['config']->set('services.google', [
|
||||
|
||||
@@ -9,17 +9,14 @@ use Modules\User\Admin\ProfileTabs;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\View;
|
||||
use Illuminate\Support\Facades\Blade;
|
||||
use Modules\Support\Traits\AddsAsset;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Modules\Admin\Ui\Facades\TabManager;
|
||||
use Modules\User\Contracts\Authentication;
|
||||
use Modules\User\Sentinel\SentinelAuthentication;
|
||||
use Modules\Admin\Http\ViewComposers\AssetsComposer;
|
||||
use Modules\User\Http\ViewComposers\CurrentUserComposer;
|
||||
|
||||
class UserServiceProvider extends ServiceProvider
|
||||
{
|
||||
use AddsAsset;
|
||||
|
||||
/**
|
||||
* Bootstrap any application services.
|
||||
@@ -28,7 +25,7 @@ class UserServiceProvider extends ServiceProvider
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
if (! config('app.installed')) {
|
||||
if (!config('app.installed')) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -37,15 +34,12 @@ class UserServiceProvider extends ServiceProvider
|
||||
TabManager::register('profile', ProfileTabs::class);
|
||||
|
||||
View::composer('*', CurrentUserComposer::class);
|
||||
View::composer('user::admin.auth.layout', AssetsComposer::class);
|
||||
|
||||
$this->addAdminAssets('admin.(login|reset).*', ['admin.login.css', 'admin.login.js']);
|
||||
$this->addAdminAssets('admin.(users|roles).(create|edit)', ['admin.user.css', 'admin.user.js']);
|
||||
|
||||
$this->registerSentinelGuard();
|
||||
$this->registerBladeDirectives();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Register the service provider.
|
||||
*
|
||||
@@ -56,6 +50,7 @@ class UserServiceProvider extends ServiceProvider
|
||||
$this->app->bind(Authentication::class, SentinelAuthentication::class);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Register sentinel guard.
|
||||
*
|
||||
@@ -68,6 +63,7 @@ class UserServiceProvider extends ServiceProvider
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Register blade directives.
|
||||
*
|
||||
|
||||
@@ -16,6 +16,53 @@ class Permission
|
||||
return static::getEnabledModulePermissions() + static::getActiveThemePermissions();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Prepare given permissions.
|
||||
*
|
||||
* @param array $permissions
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function prepare(array $permissions)
|
||||
{
|
||||
$preparedPermissions = [];
|
||||
|
||||
foreach ($permissions as $name => $value) {
|
||||
if (is_null($value) || is_bool($value)) {
|
||||
$preparedPermissions[$name] = $value;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!is_null(static::value($value))) {
|
||||
$preparedPermissions[$name] = static::value($value);
|
||||
}
|
||||
}
|
||||
|
||||
return json_encode($preparedPermissions);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the permission value.
|
||||
*
|
||||
* @param $permission
|
||||
*
|
||||
* @return bool|null
|
||||
*/
|
||||
protected static function value($permission)
|
||||
{
|
||||
if ($permission === '1') {
|
||||
return true;
|
||||
}
|
||||
|
||||
if ($permission === '-1') {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get enabled module permissions.
|
||||
*
|
||||
@@ -28,7 +75,7 @@ class Permission
|
||||
foreach (Module::allEnabled() as $module) {
|
||||
$config = config('fleetcart.modules.' . strtolower($module->getName()) . '.permissions');
|
||||
|
||||
if (! is_null($config)) {
|
||||
if (!is_null($config)) {
|
||||
$permissions[$module->getName()] = $config;
|
||||
}
|
||||
}
|
||||
@@ -36,6 +83,7 @@ class Permission
|
||||
return $permissions;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get active theme permissions.
|
||||
*
|
||||
@@ -51,46 +99,4 @@ class Permission
|
||||
|
||||
return [setting('active_theme') => $permissions];
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare given permissions.
|
||||
*
|
||||
* @param array $permissions
|
||||
* @return string
|
||||
*/
|
||||
public static function prepare(array $permissions)
|
||||
{
|
||||
$preparedPermissions = [];
|
||||
|
||||
foreach ($permissions as $name => $value) {
|
||||
if (is_null($value) || is_bool($value)) {
|
||||
$preparedPermissions[$name] = $value;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if (! is_null(static::value($value))) {
|
||||
$preparedPermissions[$name] = static::value($value);
|
||||
}
|
||||
}
|
||||
|
||||
return json_encode($preparedPermissions);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the permission value.
|
||||
*
|
||||
* @param $permission
|
||||
* @return bool|null
|
||||
*/
|
||||
protected static function value($permission)
|
||||
{
|
||||
if ($permission === '1') {
|
||||
return true;
|
||||
}
|
||||
|
||||
if ($permission === '-1') {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
17
Modules/User/Resources/assets/admin/js/auth.js
Normal file
17
Modules/User/Resources/assets/admin/js/auth.js
Normal file
@@ -0,0 +1,17 @@
|
||||
import jQuery from "jquery";
|
||||
|
||||
window.$ = window.jQuery = jQuery;
|
||||
|
||||
$("[data-loading]").on("click", (e) => {
|
||||
let button = $(e.currentTarget);
|
||||
|
||||
if (button.is("i")) {
|
||||
button = button.parent();
|
||||
}
|
||||
|
||||
button
|
||||
.addClass("btn-loading")
|
||||
.attr("disabled", "disabled")
|
||||
.parents("form")
|
||||
.trigger("submit");
|
||||
});
|
||||
165
Modules/User/Resources/assets/admin/sass/auth.scss
Normal file
165
Modules/User/Resources/assets/admin/sass/auth.scss
Normal file
@@ -0,0 +1,165 @@
|
||||
/* resets */
|
||||
|
||||
h1,
|
||||
h2,
|
||||
h3,
|
||||
h4,
|
||||
h5,
|
||||
h6,
|
||||
p {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
body,
|
||||
html {
|
||||
height: 100% !important;
|
||||
width: 100% !important;
|
||||
margin: 0;
|
||||
display: table;
|
||||
}
|
||||
|
||||
body {
|
||||
font-family: "Inter", sans-serif;
|
||||
font-weight: 400;
|
||||
background: #f1f3f7;
|
||||
display: table-cell;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
/* login page */
|
||||
|
||||
.login-page {
|
||||
display: table;
|
||||
width: 360px;
|
||||
margin: auto;
|
||||
}
|
||||
|
||||
.login-wrapper {
|
||||
position: relative;
|
||||
background: #ffffff;
|
||||
border-radius: 3px;
|
||||
padding: 15px;
|
||||
box-shadow: 0 1px 8px rgba(0, 0, 0, 0.15);
|
||||
z-index: 0;
|
||||
|
||||
.bg-blue {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
top: 0;
|
||||
right: 0;
|
||||
height: 80px;
|
||||
background: #0068e1;
|
||||
overflow: hidden;
|
||||
border-top-left-radius: 3px;
|
||||
border-top-right-radius: 3px;
|
||||
z-index: -1;
|
||||
|
||||
.reflection {
|
||||
position: absolute;
|
||||
left: -100px;
|
||||
top: 0;
|
||||
height: 300px;
|
||||
width: 300px;
|
||||
background: linear-gradient(
|
||||
rgba(255, 255, 255, 0.2),
|
||||
rgba(255, 255, 255, 0)
|
||||
);
|
||||
transform: rotate(45deg);
|
||||
}
|
||||
}
|
||||
|
||||
.form-inner {
|
||||
background: #ffffff;
|
||||
border-radius: 3px;
|
||||
border: 1px solid #e9e9e9;
|
||||
margin: 15px 0 0;
|
||||
padding: 0 15px 10px;
|
||||
}
|
||||
|
||||
.reset-password {
|
||||
p {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.login-form > button {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.input-icon {
|
||||
top: 5px !important;
|
||||
}
|
||||
|
||||
> a {
|
||||
margin: 10px auto 5px;
|
||||
}
|
||||
}
|
||||
|
||||
h3 {
|
||||
margin: 15px 0;
|
||||
}
|
||||
|
||||
.form-group {
|
||||
position: relative;
|
||||
|
||||
label > span {
|
||||
color: #fc4b4b;
|
||||
margin-left: 4px;
|
||||
}
|
||||
|
||||
.form-control {
|
||||
padding-left: 36px;
|
||||
}
|
||||
}
|
||||
|
||||
button {
|
||||
display: table;
|
||||
margin: 20px auto 5px;
|
||||
padding-left: 60px;
|
||||
padding-right: 60px;
|
||||
}
|
||||
|
||||
a {
|
||||
display: table;
|
||||
margin-top: 10px;
|
||||
color: #0068e1;
|
||||
|
||||
&:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.reset-password {
|
||||
button {
|
||||
padding-left: 30px;
|
||||
padding-right: 30px;
|
||||
}
|
||||
}
|
||||
|
||||
@media screen and (max-width: 415px) {
|
||||
.login-page {
|
||||
width: 100%;
|
||||
margin: 0;
|
||||
padding: 0 15px;
|
||||
|
||||
.checkbox {
|
||||
display: table;
|
||||
margin: 10px auto 0;
|
||||
}
|
||||
|
||||
a {
|
||||
display: table;
|
||||
margin: 10px auto;
|
||||
}
|
||||
}
|
||||
|
||||
.ltr,
|
||||
.rtl {
|
||||
.login-page {
|
||||
.checkbox,
|
||||
a {
|
||||
float: none !important;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -13,7 +13,7 @@
|
||||
.permission-parent-head {
|
||||
margin-bottom: 15px;
|
||||
|
||||
h3 {
|
||||
h5 {
|
||||
border-bottom: 1px solid #d2d6de;
|
||||
padding-bottom: 5px;
|
||||
}
|
||||
@@ -23,7 +23,6 @@
|
||||
border: 1px solid #d2d6de;
|
||||
}
|
||||
|
||||
|
||||
%permission-actions-btn {
|
||||
padding: 3px 10px;
|
||||
margin-left: 0px !important;
|
||||
@@ -53,8 +52,8 @@
|
||||
|
||||
.permission-row {
|
||||
.permission-label {
|
||||
font-family: "Open Sans", sans-serif;
|
||||
font-weight: 600;
|
||||
font-family: "Inter", sans-serif;
|
||||
font-weight: 500;
|
||||
display: block;
|
||||
padding-top: 6px;
|
||||
}
|
||||
|
||||
@@ -25,5 +25,5 @@ return [
|
||||
'reset_password' => 'Reset Password',
|
||||
'enter_email' => 'Enter your account email to receive a link allowing you to reset your password.',
|
||||
'i_remembered_my_password' => 'I remembered my password',
|
||||
'submit' => 'SUBMIT',
|
||||
'submit' => 'Submit',
|
||||
];
|
||||
|
||||
@@ -2,17 +2,17 @@
|
||||
|
||||
return [
|
||||
'users' => [
|
||||
'account_created' => 'Your account has been created.',
|
||||
'no_user_found' => 'No user with that email address belongs to our system.',
|
||||
'invalid_credentials' => 'Invalid email address or password.',
|
||||
'account_not_activated' => 'Your account is not activated. Please check your email.',
|
||||
'account_is_blocked' => 'Your account is blocked for :delay seconds.',
|
||||
'check_email_to_reset_password' => 'Check your email address to reset password.',
|
||||
'invalid_reset_code' => 'Invalid or expired reset code.',
|
||||
'password_has_been_reset' => 'Your password has been reset.',
|
||||
'reset_password_email_sent' => 'Reset password email sent.',
|
||||
'account_created' => 'Your account has been created',
|
||||
'no_user_found' => 'No user with that email address belongs to our system',
|
||||
'invalid_credentials' => 'Invalid email address or password',
|
||||
'account_not_activated' => 'Your account is not activated. Please check your email',
|
||||
'account_is_blocked' => 'Your account is blocked for :delay seconds',
|
||||
'check_email_to_reset_password' => 'Check your email address to reset password',
|
||||
'invalid_reset_code' => 'Invalid or expired reset code',
|
||||
'password_has_been_reset' => 'Your password has been reset',
|
||||
'reset_password_email_sent' => 'Reset password email sent',
|
||||
],
|
||||
'email' => [
|
||||
'reset_password' => 'Reset your account password.',
|
||||
'reset_password' => 'Reset your account password',
|
||||
],
|
||||
];
|
||||
|
||||
@@ -3,31 +3,30 @@
|
||||
<head>
|
||||
<base href="{{ url('/') }}">
|
||||
<meta charset="UTF-8">
|
||||
<meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
|
||||
|
||||
<title>
|
||||
@yield('title') - FleetCart
|
||||
</title>
|
||||
|
||||
<meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
|
||||
|
||||
<link href="https://fonts.googleapis.com/css?family=Open+Sans:600|Roboto:400,500" rel="stylesheet">
|
||||
|
||||
@foreach ($assets->allCss() as $css)
|
||||
<link media="all" type="text/css" rel="stylesheet" href="{{ v($css) }}">
|
||||
@endforeach
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&display=swap" rel="stylesheet">
|
||||
|
||||
@vite([
|
||||
'Modules/Admin/Resources/assets/sass/main.scss',
|
||||
'Modules/User/Resources/assets/admin/sass/auth.scss',
|
||||
'Modules/User/Resources/assets/admin/js/auth.js',
|
||||
])
|
||||
|
||||
@include('admin::partials.globals')
|
||||
</head>
|
||||
|
||||
<body class="clearfix">
|
||||
<body class="clearfix {{ is_rtl() ? 'rtl' : 'ltr' }}">
|
||||
<div class="login-page">
|
||||
@include('admin::partials.notification')
|
||||
|
||||
@yield('content')
|
||||
</div>
|
||||
|
||||
@foreach ($assets->allJs() as $js)
|
||||
<script src="{{ v($js) }}"></script>
|
||||
@endforeach
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
<div class="col-md-12">
|
||||
<div class="row">
|
||||
<div class="permission-parent-head clearfix">
|
||||
<h3>{{ $module }}</h3>
|
||||
<h5>{{ $module }}</h5>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -28,7 +28,7 @@
|
||||
<div class="permission-group-head">
|
||||
<div class="row">
|
||||
<div class="col-md-4 col-sm-4">
|
||||
<h4>{{ $group }}</h4>
|
||||
<h6>{{ $group }}</h6>
|
||||
</div>
|
||||
|
||||
<div class="col-md-8 col-sm-8">
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
<div class="col-md-8">
|
||||
{{ Form::text('first_name', trans('user::attributes.users.first_name'), $errors, $currentUser, ['required' => true]) }}
|
||||
{{ Form::text('last_name', trans('user::attributes.users.last_name'), $errors, $currentUser, ['required' => true]) }}
|
||||
{{ Form::text('phone', trans('user::attributes.users.phone'), $errors, $currentUser, ['required' => true]) }}
|
||||
{{ Form::email('email', trans('user::attributes.users.email'), $errors, $currentUser, ['required' => true]) }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -16,3 +16,10 @@
|
||||
@endsection
|
||||
|
||||
@include('user::admin.roles.partials.shortcuts')
|
||||
|
||||
@push('globals')
|
||||
@vite([
|
||||
'Modules/User/Resources/assets/admin/sass/main.scss',
|
||||
'Modules/User/Resources/assets/admin/js/main.js'
|
||||
])
|
||||
@endpush
|
||||
@@ -18,3 +18,10 @@
|
||||
@endsection
|
||||
|
||||
@include('user::admin.roles.partials.shortcuts')
|
||||
|
||||
@push('globals')
|
||||
@vite([
|
||||
'Modules/User/Resources/assets/admin/sass/main.scss',
|
||||
'Modules/User/Resources/assets/admin/js/main.js'
|
||||
])
|
||||
@endpush
|
||||
@@ -23,7 +23,7 @@
|
||||
@endcomponent
|
||||
|
||||
@push('scripts')
|
||||
<script>
|
||||
<script type="module">
|
||||
new DataTable('#roles-table .table', {
|
||||
columns: [
|
||||
{ data: 'checkbox', orderable: false, searchable: false, width: '3%' },
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
@endpush
|
||||
|
||||
@push('scripts')
|
||||
<script>
|
||||
<script type="module">
|
||||
keypressAction([
|
||||
{ key: 'b', route: "{{ route('admin.roles.index') }}" },
|
||||
]);
|
||||
|
||||
@@ -16,3 +16,10 @@
|
||||
@endsection
|
||||
|
||||
@include('user::admin.users.partials.shortcuts')
|
||||
|
||||
@push('globals')
|
||||
@vite([
|
||||
'Modules/User/Resources/assets/admin/sass/main.scss',
|
||||
'Modules/User/Resources/assets/admin/js/main.js'
|
||||
])
|
||||
@endpush
|
||||
@@ -18,3 +18,10 @@
|
||||
@endsection
|
||||
|
||||
@include('user::admin.users.partials.shortcuts')
|
||||
|
||||
@push('globals')
|
||||
@vite([
|
||||
'Modules/User/Resources/assets/admin/sass/main.scss',
|
||||
'Modules/User/Resources/assets/admin/js/main.js'
|
||||
])
|
||||
@endpush
|
||||
@@ -26,7 +26,7 @@
|
||||
@endcomponent
|
||||
|
||||
@push('scripts')
|
||||
<script>
|
||||
<script type="module">
|
||||
new DataTable('#users-table .table', {
|
||||
columns: [
|
||||
{ data: 'checkbox', orderable: false, searchable: false, width: '3%' },
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
@endpush
|
||||
|
||||
@push('scripts')
|
||||
<script>
|
||||
<script type="module">
|
||||
keypressAction([
|
||||
{ key: 'b', route: "{{ route('admin.users.index') }}" },
|
||||
]);
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
</div>
|
||||
|
||||
<div class="col-md-4">
|
||||
<h4>{{ trans('user::users.or_reset_password') }}</h4>
|
||||
<h5>{{ trans('user::users.or_reset_password') }}</h5>
|
||||
|
||||
<a href="{{ route('admin.users.reset_password', $user) }}" class="btn btn-primary btn-reset-password" data-loading>
|
||||
{{ trans('user::users.send_reset_password_email') }}
|
||||
|
||||
@@ -48,6 +48,12 @@ Route::delete('users/{ids?}', [
|
||||
'middleware' => 'can:admin.users.destroy',
|
||||
]);
|
||||
|
||||
Route::get('users/index/table', [
|
||||
'as' => 'admin.users.table',
|
||||
'uses' => 'UserController@table',
|
||||
'middleware' => 'can:admin.users.index',
|
||||
]);
|
||||
|
||||
Route::get('users/{id}/reset-password', [
|
||||
'as' => 'admin.users.reset_password',
|
||||
'uses' => 'UserResetPasswordController@store',
|
||||
@@ -60,6 +66,12 @@ Route::get('roles', [
|
||||
'middleware' => 'can:admin.roles.index',
|
||||
]);
|
||||
|
||||
Route::get('roles/index/table', [
|
||||
'as' => 'admin.roles.table',
|
||||
'uses' => 'RoleController@table',
|
||||
'middleware' => 'can:admin.roles.index',
|
||||
]);
|
||||
|
||||
Route::get('roles/create', [
|
||||
'as' => 'admin.roles.create',
|
||||
'uses' => 'RoleController@create',
|
||||
|
||||
@@ -9,6 +9,7 @@ use Cartalyst\Sentinel\Laravel\Facades\Reminder;
|
||||
use Cartalyst\Sentinel\Laravel\Facades\Sentinel;
|
||||
use Modules\User\Events\UserHasActivatedAccount;
|
||||
use Cartalyst\Sentinel\Laravel\Facades\Activation;
|
||||
use Cartalyst\Sentinel\Activations\ActivationInterface;
|
||||
|
||||
class SentinelAuthentication implements Authentication
|
||||
{
|
||||
@@ -17,6 +18,7 @@ class SentinelAuthentication implements Authentication
|
||||
*
|
||||
* @param array $credentials
|
||||
* @param bool $remember
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function login($credentials, $remember = false)
|
||||
@@ -24,10 +26,12 @@ class SentinelAuthentication implements Authentication
|
||||
return Sentinel::authenticate($credentials, $remember);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Register a new user.
|
||||
*
|
||||
* @param array $data
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function register($data)
|
||||
@@ -35,22 +39,26 @@ class SentinelAuthentication implements Authentication
|
||||
return Sentinel::register($data);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Register and activate a new user.
|
||||
*
|
||||
* @param array $data
|
||||
* @return \Modules\User\Entities\User
|
||||
*
|
||||
* @return User
|
||||
*/
|
||||
public function registerAndActivate($data)
|
||||
{
|
||||
return Sentinel::registerAndActivate($data);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Activate the given used id.
|
||||
*
|
||||
* @param int $userId
|
||||
* @param string $code
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function activate($userId, $code)
|
||||
@@ -62,11 +70,13 @@ class SentinelAuthentication implements Authentication
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Assign a role to the given user.
|
||||
*
|
||||
* @param \Modules\User\Entities\User $user
|
||||
* @param \Modules\User\Entities\Role $role
|
||||
* @param User $user
|
||||
* @param Role $role
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function assignRole(User $user, Role $role)
|
||||
@@ -74,6 +84,7 @@ class SentinelAuthentication implements Authentication
|
||||
$role->users()->attach($user);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Log the user out of the application.
|
||||
*
|
||||
@@ -84,21 +95,25 @@ class SentinelAuthentication implements Authentication
|
||||
return Sentinel::logout();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create an activation code for the given user.
|
||||
*
|
||||
* @param \Modules\User\Entities\User $user
|
||||
* @return \Cartalyst\Sentinel\Activations\ActivationInterface
|
||||
* @param User $user
|
||||
*
|
||||
* @return ActivationInterface
|
||||
*/
|
||||
public function createActivation(User $user)
|
||||
{
|
||||
return Activation::create($user)->code;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create a reminders code for the given user.
|
||||
*
|
||||
* @param \Modules\User\Entities\User $user
|
||||
* @param User $user
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function createReminderCode(User $user)
|
||||
@@ -106,12 +121,14 @@ class SentinelAuthentication implements Authentication
|
||||
return Reminder::create($user)->code;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Completes the reset password process.
|
||||
*
|
||||
* @param \Modules\User\Entities\User $user
|
||||
* @param User $user
|
||||
* @param string $code
|
||||
* @param string $password
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function completeResetPassword(User $user, $code, $password)
|
||||
@@ -119,10 +136,12 @@ class SentinelAuthentication implements Authentication
|
||||
return Reminder::complete($user, $code, $password);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Determines if the current user has access to the given permissions.
|
||||
*
|
||||
* @param array|string $permissions
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function hasAccess($permissions)
|
||||
@@ -136,10 +155,12 @@ class SentinelAuthentication implements Authentication
|
||||
return Sentinel::hasAccess($permissions);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Determine if the current user has access to the any given permissions
|
||||
* Determine if the current user has access to any given permissions
|
||||
*
|
||||
* @param array|string $permissions
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function hasAnyAccess($permissions)
|
||||
@@ -153,6 +174,7 @@ class SentinelAuthentication implements Authentication
|
||||
return Sentinel::hasAnyAccess($permissions);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check if the user is logged in.
|
||||
*
|
||||
@@ -163,15 +185,6 @@ class SentinelAuthentication implements Authentication
|
||||
return Sentinel::check();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the currently logged in user.
|
||||
*
|
||||
* @return \Modules\User\Entities\User|null
|
||||
*/
|
||||
public function user()
|
||||
{
|
||||
return Sentinel::getUser();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the ID for the currently authenticated user.
|
||||
@@ -182,4 +195,15 @@ class SentinelAuthentication implements Authentication
|
||||
{
|
||||
return optional($this->user())->id;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the currently logged-in user.
|
||||
*
|
||||
* @return User|null
|
||||
*/
|
||||
public function user()
|
||||
{
|
||||
return Sentinel::getUser();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,11 +9,13 @@ class CustomerService
|
||||
{
|
||||
private $auth;
|
||||
|
||||
|
||||
public function __construct(Authentication $auth)
|
||||
{
|
||||
$this->auth = $auth;
|
||||
}
|
||||
|
||||
|
||||
public function register($request)
|
||||
{
|
||||
return tap($this->auth->registerAndActivate($this->getCustomerData($request)), function ($user) {
|
||||
@@ -23,6 +25,7 @@ class CustomerService
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
private function getCustomerData($request)
|
||||
{
|
||||
return array_merge($request->billing, [
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
<?php
|
||||
|
||||
if (! function_exists('permission_value')) {
|
||||
if (!function_exists('permission_value')) {
|
||||
/**
|
||||
* Get the integer representation value of the permission.
|
||||
*
|
||||
* @param array $permissions
|
||||
* @param string $permission
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
function permission_value(array $permissions, $permission)
|
||||
@@ -14,9 +15,9 @@ if (! function_exists('permission_value')) {
|
||||
|
||||
if (is_null($value)) {
|
||||
return 0;
|
||||
} elseif ($value) {
|
||||
} else if ($value) {
|
||||
return 1;
|
||||
} elseif (! $value) {
|
||||
} else if (!$value) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user