Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
taskonsite-архив-перенесен
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Packages
Packages
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Dmitry Korolev
taskonsite-архив-перенесен
Commits
84d833e0
Commit
84d833e0
authored
Feb 05, 2016
by
difox
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Authorization module
parent
55912306
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
30 additions
and
15 deletions
+30
-15
common/modules/rbac/models/AuthItem.php
common/modules/rbac/models/AuthItem.php
+3
-3
common/modules/users/models/User.php
common/modules/users/models/User.php
+12
-7
frontend/config/main.php
frontend/config/main.php
+4
-3
frontend/controllers/SiteController.php
frontend/controllers/SiteController.php
+11
-2
No files found.
common/modules/rbac/models/AuthItem.php
View file @
84d833e0
...
...
@@ -79,7 +79,7 @@ class AuthItem extends \common\components\ActiveRecordModel
}
public
function
getAssignment
()
{
return
$this
->
has
One
(
AuthAssignment
::
className
(),
[
'name'
=>
'item_
name'
]);
return
$this
->
has
Many
(
AuthAssignment
::
className
(),
[
'item_name'
=>
'
name'
]);
}
public
function
relations
()
...
...
@@ -97,7 +97,6 @@ class AuthItem extends \common\components\ActiveRecordModel
'auth_items_childs(parent, child)'
,
'condition'
=>
'type = "'
.
self
::
TYPE_TASK
.
'"'
),
'assignments'
=>
array
(
self
::
HAS_MANY
,
'AuthAssignment'
,
'itemname'
),
'users'
=>
array
(
self
::
HAS_MANY
,
'User'
,
'userid'
,
'through'
=>
'assignments'
)
);
}
...
...
@@ -188,7 +187,8 @@ class AuthItem extends \common\components\ActiveRecordModel
if
(
!
$roles
)
{
$roles
=
$this
->
findAllByAttributes
(
array
(
'type'
=>
self
::
TYPE_ROLE
//'type' => self::TYPE_ROLE
'rule_name'
=>
'group'
));
}
return
$roles
;
...
...
common/modules/users/models/User.php
View file @
84d833e0
...
...
@@ -355,8 +355,8 @@ class User extends \common\components\ActiveRecordModel implements IdentityInter
public
function
relations
()
{
return
array
(
'assignment'
=>
array
(
self
::
HAS_ONE
,
'AuthAssignment'
,
'userid'
),
'city'
=>
array
(
self
::
BELONGS_TO
,
'City'
,
'city_id'
)
'assignment'
=>
array
(
self
::
HAS_ONE
,
'AuthAssignment'
,
'user
_
id'
),
'city'
=>
array
(
self
::
BELONGS_TO
,
'City'
,
'city_id'
)
);
}
...
...
@@ -394,18 +394,23 @@ class User extends \common\components\ActiveRecordModel implements IdentityInter
public
function
getRole
()
{
/*$assigment = AuthAssignment::find(['userid' => $this->id])->one();
$auth
=
AuthItem
::
find
()
->
joinWith
(
'assignment'
,
true
)
->
andWhere
([
'rule_name'
=>
'group'
])
->
andWhere
([
'auth_assignment.user_id'
=>
$this
->
id
])
->
one
();
if (!$assigment)
return
$auth
->
name
;
/*$assigment = AuthAssignment::find(['userid' => $this->id])->one();
if (!$assigment)
{
$assigment
= new AuthAssignment();
$assigment = new AuthAssignment();
$assigment->item_name = AuthItem::ROLE_DEFAULT;
$assigment->user_id = $this->id;
$assigment->save(false);
}
return $assigment->role;
*/
return
'admin'
;
return $assigment->role;
return 'admin';
*/
}
public
function
getRoleName
()
...
...
frontend/config/main.php
View file @
84d833e0
...
...
@@ -81,7 +81,7 @@ return [
//'css_linebreak_pos' => false,
],
'user'
=>
[
'identityClass'
=>
'common\modules\
scoring\models\ScClient
'
,
'identityClass'
=>
'common\modules\
users\models\User
'
,
'loginUrl'
=>
[
'/site/login'
],
'enableAutoLogin'
=>
true
,
],
...
...
@@ -165,6 +165,7 @@ return [
'school'
=>
'school/course/index'
,
'school/course/<id>'
=>
'school/course/view'
,
'school/lesson/<id>'
=>
'school/lesson/view'
,
'login'
=>
'site/login'
,
'<page:(/)>'
=>
'content/page/view'
,
'<_m>/<_c>/<_a>/<id:\d+>'
=>
'<_m>/<_c>/<_a>'
,
...
...
@@ -178,10 +179,10 @@ return [
],
'authManager'
=>
[
'class'
=>
'yii\rbac\DbManager'
,
/*
'connectionID' => 'db',
'connectionID'
=>
'db'
,
'itemTable'
=>
'auth_items'
,
'assignmentTable'
=>
'auth_assignments'
,
'itemChildTable' => 'auth_item_child',
*/
'itemChildTable'
=>
'auth_item_child'
,
'defaultRoles'
=>
[
'user'
,
'moderator'
,
...
...
frontend/controllers/SiteController.php
View file @
84d833e0
...
...
@@ -3,7 +3,7 @@ namespace frontend\controllers;
use
common\modules\scoring\models\ScRequest
;
use
Yii
;
use
frontend\models\LoginForm
;
//
use frontend\models\LoginForm;
use
frontend\models\PasswordResetRequestForm
;
use
frontend\models\ResetPasswordForm
;
use
frontend\models\SignupForm
;
...
...
@@ -22,6 +22,7 @@ use common\modules\request\models\ScZodiac;
use
\yii\web\Response
;
use
\yii\widgets\ActiveForm
;
use
common\modules\scoring\models\ScClient
;
use
common\models\LoginForm
;
/**
* Site controller
...
...
@@ -115,6 +116,14 @@ class SiteController extends BaseController
}
public
function
actionLogin
()
{
//Yii::$app->user->getIdentity()->getRole()
$model
=
new
LoginForm
();
$model
->
load
(
Yii
::
$app
->
request
->
post
());
$model
->
login
();
}
/*public function actionLogin()
{
$this->layout = '//main-short';
$model = new \frontend\models\LoginForm();
...
...
@@ -178,7 +187,7 @@ class SiteController extends BaseController
'model' => $model,
]);
}
}
}
*/
public
function
actionLogout
()
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment