displayregisterstructure update

This commit is contained in:
2018-12-05 22:27:10 -06:00
parent bf171689b0
commit ddf97199cf
2 changed files with 24 additions and 5 deletions

View File

@@ -8,6 +8,7 @@ use Auth;
use DB;
use App\Models\Corporation\CorpStructure;
use App\Library\Esi;
class RegisterStructureController extends Controller
{
@@ -17,7 +18,12 @@ class RegisterStructureController extends Controller
}
public function displayRegisterStructure() {
return view('structures.register');
//Check to see if the user has the read corp journal esi scope before allowing to register a structure
if(Auth()->user()->hasEsiScope('esi-wallet.read_corporation_wallets.v1')) {
return view('structures.register');
} else {
return view('dashboard')->with('error', 'You need to setup your esi scope for read corporation wallets');
}
}
public function storeStructure(Request $request) {

View File

@@ -51,15 +51,19 @@ class User extends Authenticatable
}
public function role() {
return $this->hasOne('App\Models\UserRole', 'character_id');
return $this->hasOne('App\Models\User\UserRole', 'character_id');
}
public function permissions() {
return $this->hasMany('App\Models\UserPermission', 'character_id');
return $this->hasMany('App\Models\User\UserPermission', 'character_id');
}
public function esitoken() {
return $this->hasOne('App\Models\EsiToken', 'character_id', 'character_id');
return $this->hasOne('App\Models\Esi\EsiToken', 'character_id', 'character_id');
}
public function esiScopes() {
return $this->hasMany('App\Models\Esi\EsiScope', 'character_id');
}
public function hasPermission($permission) {
@@ -72,13 +76,22 @@ class User extends Authenticatable
}
public function hasEsiScope($scope) {
$found = EsiScope::where(['character_id' => $this->character_id, 'scope' => $scope])->get(['scope']);
if(isset($found[0]->scope) && $found[0]->scope == $scope) {
return true;
} else {
return false;
}
}
public function hasRole($role) {
//If the user is a super user then he has all roles
if($this->hasSuperUser()) {
return true;
}
$found = UserRole::where(['character_id' => $this->character_id, 'role' => $role])->get();
$found = UserRole::where(['character_id' => $this->character_id, 'role' => $role])->get(['role']);
if(isset($found[0]) && $found[0]->role == $role) {
return true;