chyz 1.0.13-rc.12 → 1.0.13-rc.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -19,6 +19,7 @@ import {JwtHttpBearerAuth} from "../../filters/auth";
19
19
  import {ValidationHttpException} from "../../base";
20
20
  import {ForbiddenHttpException} from "../../base";
21
21
  import {ProductsClass} from "../Models/Products";
22
+ import {AccessControl} from "../../filters";
22
23
 
23
24
 
24
25
  @controller("/api")
@@ -35,22 +36,18 @@ class ApiController extends Controller {
35
36
  "class": JwtHttpBearerAuth,
36
37
  // "auth": this.myCheck
37
38
  },
38
- // 'access': {
39
- // 'class': AccessControl,
40
- // 'only': ['login', 'logout', 'signup'],
41
- // 'rules': [
42
- // {
43
- // 'allow': true,
44
- // 'actions': ['login', 'index'],
45
- // 'roles': ['?'],
46
- // },
47
- // {
48
- // 'allow': true,
49
- // 'actions': ['logout', "logout2"],
50
- // 'roles': ['@'],
51
- // }
52
- // ]
53
- // }
39
+ 'access': {
40
+ 'class': AccessControl,
41
+ 'only': ['order/list' ],
42
+ 'rules': [
43
+
44
+ {
45
+ 'allow': true,
46
+ 'actions': ['order/list' ],
47
+ 'roles': ['edis-manager'],
48
+ }
49
+ ]
50
+ }
54
51
  }]
55
52
  }
56
53
 
@@ -114,7 +111,7 @@ class ApiController extends Controller {
114
111
  @get("order/list")
115
112
  async listOrder(req: Request, res: Response) {
116
113
  const {Products}: { Products: ProductsClass } = ModelManager;
117
- let product = await Products.findAll({include: [ModelManager.ProductModels.model()]});
114
+ let product = await Products.findAll( );
118
115
  return res.json(product)
119
116
 
120
117
  }
@@ -0,0 +1,50 @@
1
+ /*
2
+ * Copyright (c) 2021. Chy Bilgisayar Bilisim
3
+ * Author: Cihan Ozturk
4
+ * E-mail: cihan@chy.com.tr
5
+ * Github:https://github.com/cihan53/
6
+ */
7
+
8
+ import {DataTypes, Model, ModelManager, Relation} from "../../base";
9
+
10
+ export class AuthAssignmentClass extends Model {
11
+ [x: string]: any;
12
+
13
+ tableName() {
14
+ return 'auth_assignment';
15
+ }
16
+ attributes() {
17
+ return {
18
+
19
+ // Model attributes are defined here
20
+ item_name: {
21
+ type: DataTypes.STRING,
22
+ primaryKey:true,
23
+ allowNull: false
24
+ },
25
+ user_id : {
26
+ type: DataTypes.STRING,
27
+ allowNull: false
28
+ }
29
+
30
+ }
31
+ }
32
+
33
+ init(){
34
+ super.init();
35
+ this.model().removeAttribute('id')
36
+ }
37
+
38
+ relations(): Relation[] {
39
+ return [
40
+ {
41
+ type: "hasMany",
42
+ foreignKey: "name",
43
+ sourceKey:'item_name',
44
+ model: ModelManager.AuthItem.model()
45
+ }
46
+ ]
47
+ }
48
+
49
+ }
50
+
@@ -0,0 +1,59 @@
1
+ /*
2
+ * Copyright (c) 2021. Chy Bilgisayar Bilisim
3
+ * Author: Cihan Ozturk
4
+ * E-mail: cihan@chy.com.tr
5
+ * Github:https://github.com/cihan53/
6
+ */
7
+
8
+
9
+
10
+ import {DataTypes, Model, ModelManager, Relation} from "../../base";
11
+
12
+ export class AuthItemClass extends Model {
13
+ [x: string]: any;
14
+
15
+ tableName() {
16
+ return 'auth_item';
17
+ }
18
+
19
+ attributes() {
20
+ return {
21
+ // Model attributes are defined here
22
+ name: {
23
+ type: DataTypes.STRING,
24
+ primaryKey:true,
25
+ allowNull: false
26
+ },
27
+ type: {
28
+ type: DataTypes.INTEGER,
29
+ allowNull: false
30
+ },
31
+ description: {
32
+ type: DataTypes.STRING,
33
+ allowNull: false
34
+ },
35
+ rule_name: {
36
+ type: DataTypes.STRING,
37
+ allowNull: false
38
+ }
39
+
40
+ }
41
+ }
42
+
43
+ init() {
44
+ super.init();
45
+ this.model().removeAttribute('id')
46
+ }
47
+
48
+ relations(): Relation[] {
49
+ return [
50
+ {
51
+ type: "hasOne",
52
+ foreignKey: "item_name",
53
+ model: ModelManager.AuthAssignment.model()
54
+ }
55
+ ]
56
+ }
57
+
58
+ }
59
+
@@ -0,0 +1,49 @@
1
+ /*
2
+ * Copyright (c) 2021. Chy Bilgisayar Bilisim
3
+ * Author: Cihan Ozturk
4
+ * E-mail: cihan@chy.com.tr
5
+ * Github:https://github.com/cihan53/
6
+ */
7
+
8
+
9
+ import {DataTypes, Model, ModelManager, Relation} from "../../base";
10
+
11
+ export class AuthItemChildClass extends Model {
12
+ [x: string]: any;
13
+
14
+ tableName() {
15
+ return 'auth_item_child';
16
+ }
17
+
18
+ attributes() {
19
+ return {
20
+ // Model attributes are defined here
21
+ parent: {
22
+ type: DataTypes.STRING,
23
+ primaryKey: true,
24
+ allowNull: false
25
+ },
26
+ child: {
27
+ type: DataTypes.STRING,
28
+ allowNull: false
29
+ }
30
+ }
31
+ }
32
+
33
+ init() {
34
+ super.init();
35
+ this.model().removeAttribute('id')
36
+ }
37
+
38
+ relations(): Relation[] {
39
+ return [
40
+ {
41
+ type: "hasOne",
42
+ foreignKey: "item_name",
43
+ model: ModelManager.AuthAssignment.model()
44
+ }
45
+ ]
46
+ }
47
+
48
+ }
49
+
package/Examples/index.ts CHANGED
@@ -7,17 +7,22 @@
7
7
 
8
8
 
9
9
  import {BaseChyz} from "../index";
10
+
10
11
  require('dotenv-flow').config();
11
12
  import Chyz from "../Chyz";
12
13
  import {WebUser} from "../web/WebUser";
13
14
  import {User} from "./Models/User";
14
15
  import {DbConnection} from "../base";
16
+ import {AuthManager} from "../rbac/AuthManager";
15
17
 
16
18
 
17
19
  let config = {
18
20
  port: process.env.PORT,
19
21
  controllerpath: "C:\\PROJELER\\github\\Chy-Nodejs-Framework\\Examples\\Controllers",
20
22
  components: {
23
+ authManager: {
24
+ class: AuthManager,
25
+ },
21
26
  db: {
22
27
  class: DbConnection,
23
28
  database: process.env.DBDATABASE,