Skip to content

Instantly share code, notes, and snippets.

@raihan71
Last active July 4, 2020 08:06
Show Gist options
  • Save raihan71/7e5e48f10d1286147b46a551bdd230a6 to your computer and use it in GitHub Desktop.
Save raihan71/7e5e48f10d1286147b46a551bdd230a6 to your computer and use it in GitHub Desktop.
Mithun +91-9945610123 H.A13:28
users
id, username, email, password
roles: id, role_name, status
users_role_tbl: id, userId, roleId
Mithun H.A13:29
pages: home, about, contact
pages: id, pagename, status
3 pages can be accessed by superuser
2 pages from admin
1 page from user
0 page from others
Mithun H.A13:31
superuser can do all CRUD operation across all pages
admin can do all CRUD except home page, where admin cannot remove pages
users can read, update
others can just view all the pages except pages
Mithun H.A13:33
such access level
You13:35
access level :
id, permssion_id, status
You13:36
permission :
id, name, action, status
You13:38
permission_user :
id, permission_id, user_id
Mithun H.A13:40
permission_tbl: id, name, status
id:1, name: CREATE, status: A
id: 2, name: READ, status: A
3
4
users_role_tbl
Mithun H.A13:41
users_role_tbl: id, userId, roleId
user_access:tbl: id, users_role_tbl_id, permssion_id
Mithun H.A13:42
user_access:tbl: id, users_role_tbl_id, permssion_tbl_id, status
1, 1 -> Create
1, 2 -> Read
1, 4 -> Delete
Mithun H.A13:43
Raihan(User) -> Create
Mithun H.A13:51
After user logs in: Raihan
name
emailid
userid
role
permission:[]
Mithun H.A13:53
permission: {home: {create: true, read: true, update: true, delete: false}}
Mithun H.A13:54
{
"home": {
"create": true,
"read": true,
"update": true,
"delete": false
},
"about": {
"create": true,
"read": true,
"update": false,
"delete": false
},
"contact": {
"create": false,
"read": true,
"update": false,
"delete": false
}
}
Mithun H.A13:56
{
"userId": 123,
"name": "Raihan",
"email": "raihan@gmail.com",
"role": {
"name": "user",
"permissions": {
"home": {
"create": true,
"read": true,
"update": true,
"delete": false
},
"about": {
"create": true,
"read": true,
"update": false,
"delete": false
},
"contact": {
"create": false,
"read": true,
"update": false,
"delete": false
}
}
}
}
Mithun H.A13:59
/login
{
"userId": 123,
"name": "Raihan",
"jwt_token": "asdfasdlfk;ajsdfasdfa",
"email": "raihan@gmail.com",
"role": {
"name": "user",
"permissions": {
"home": {
"create": true,
"read": true,
"update": true,
"delete": false
},
"about": {
"create": true,
"read": true,
"update": false,
"delete": false
},
"contact": {
"create": false,
"read": true,
"update": false,
jwt_expiry_tme
Mithun H.A14:01
100 pages
Mithun H.A14:03
analyticsComponent
Mithun H.A14:07
/login
{
"userId": 123,
"name": "Raihan",
"jwt_token": "asdfasdlfk;ajsdfasdfa",
"email": "raihan@gmail.com",
"role": {
"name": "user",
"landing_page": "dashboard",
"permissions": {
"dashboard": {
"create": true,
"read": true,
"update": true,
"delete": false
}
}
}
}
Mithun H.A14:08
/about page
and your session got expired
or if you are in payments page
ur session is expired
/login?redirectionUrl=aboutPage
Mithun H.A14:09
"landing_page": redirectionUrl || "dashboard",
admin: "adminpage"
users: "dashboard"
Mithun H.A14:11
/fetchAllPermissions
/fetchAccessLevels
/fetchAccessLevels?roleName=user
Mithun H.A14:12
/fetchAccessLevels?roleName=user&token=jwt_token
{
"role": {
"name": "user",
"permissions": {
"home": {
"create": true,
"read": true,
"update": true,
"delete": false
},
"about": {
"create": true,
"read": true,
"update": false,
"delete": false
},
"contact": {
"create": false,
"read": true,
"update": false,
"delete": false
}
}
}
}
Mithun H.A14:13
elastic_search
for rapid_search
Mithun H.A14:15
access_permission_tbl
roleId: users,
permissions: {
"home": {
"create": true,
"read": true,
"update": true,
"delete": false
},
"about": {
"create": true,
"read": true,
"update": false,
"delete": false
},
"contact": {
"create": false,
"read": true,
"update": false,
"delete": false
}
}
Mithun H.A14:16
roldId, permissions
stringified json_format in a separate table
/login
Mithun H.A14:17
"about": {
"create": true,
"read": true,
"update": false,
"delete": false
},
/login
JSON.parse(permissions)
Mithun H.A14:18
data
JSON.parse(data.permissions)
data -> JSON format
data.permissions -> string
Mithun H.A14:21
{
"role": {
"name": "user",
"permissions": '{"home":{"create":true,"read":true,"update":true,"delete":false},"about":{"create":true,"read":true,"update":false,"delete":false},"contact":{"create":false,"read":true,"update":false,"delete":false}}'
}
}
Mithun H.A14:24
{
"role": {
"name": "user",
"landing_page": "home",
"landing_page_permission":{
"home": {
"create": true,
"read": true,
"update": true,
"delete": false
}
},
"permissions": {
"home": {
"create": true,
"read": true,
"update": true,
"delete": false
},
"about": {
"create": true,
"read": true,
"update": false,
"delete": false
},
"contact": {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment