|
@@ -4,6 +4,7 @@ namespace App\Modules\Admin\Services;
|
|
|
|
|
|
use App\Base\BaseService;
|
|
use App\Base\BaseService;
|
|
use App\Exceptions\ClientException;
|
|
use App\Exceptions\ClientException;
|
|
|
|
+use App\Models\Auth\AdminPermission;
|
|
use App\Models\User\User;
|
|
use App\Models\User\User;
|
|
use Illuminate\Support\Facades\Auth;
|
|
use Illuminate\Support\Facades\Auth;
|
|
|
|
|
|
@@ -40,10 +41,22 @@ class AuthService extends BaseService
|
|
"phone" => $u->phone,
|
|
"phone" => $u->phone,
|
|
"email" => $u->email,
|
|
"email" => $u->email,
|
|
"group" => $u->group->name,
|
|
"group" => $u->group->name,
|
|
- "role" => \Arr::get($u->extra, "permissions"),
|
|
|
|
|
|
+ "role" => $this->role($u),
|
|
];
|
|
];
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ public function role(User $u)
|
|
|
|
+ {
|
|
|
|
+ $permissions = \Arr::get($u->extra, "permissions");
|
|
|
|
+ return array_map(function ($pid) {
|
|
|
|
+ $per = AdminPermission::find($pid);
|
|
|
|
+ return [
|
|
|
|
+ "id" => $per->id,
|
|
|
|
+ "name" => $per->name,
|
|
|
|
+ ];
|
|
|
|
+ }, $permissions);
|
|
|
|
+ }
|
|
|
|
+
|
|
public function changePassword($data)
|
|
public function changePassword($data)
|
|
{
|
|
{
|
|
$u = Auth::user();
|
|
$u = Auth::user();
|