Em sử dụng JWT.
Share & grow the worlds knowledge!
We want to connect the people who have knowledge to the people who need it, to bring together people with different perspectives so they can understand each other better, and to empower everyone to share their knowledge.
Sử lí khi User có Sự thay đổi Role trong JWT
Em chào anh em có câu hỏi là. Một User đăng nhập vào hệ thống và sử dụng User có các quền ví dụ như Admin,User trong trường hợp mà cắt quyền Admin thì làm sao để hệ thống cắt quền Admin của user đó luôn ạ,
Remain: 5
1 Answer

tvd12
Teacher
tvd12
Teacher
Ý em là xử lý nhỉ?
Em có thể tạo các bảng trong cơ sở dữ liệu kiểu này:
CREATE TABLE IF NOT EXISTS ezy_users ( id bigint unsigned NOT NULL AUTO_INCREMENT, uuid varchar(128) COLLATE utf8mb4_unicode_520_ci NOT NULL, username varchar(128) COLLATE utf8mb4_unicode_520_ci NOT NULL, display_name varchar(250) COLLATE utf8mb4_unicode_520_ci, password varchar(255) COLLATE utf8mb4_unicode_520_ci NOT NULL, email varchar(120) COLLATE utf8mb4_unicode_520_ci, phone varchar(20) COLLATE utf8mb4_unicode_520_ci, url varchar(120) COLLATE utf8mb4_unicode_520_ci, avatar_image_id bigint, cover_image_id bigint, activation_key varchar(255) COLLATE utf8mb4_unicode_520_ci, status varchar(25) COLLATE utf8mb4_unicode_520_ci NOT NULL DEFAULT 'INACTIVATED', created_at datetime NOT NULL DEFAULT '2021-01-01 00:00:00', updated_at datetime NOT NULL DEFAULT '2021-01-01 00:00:00', PRIMARY KEY (id), UNIQUE KEY key_uuid (uuid), UNIQUE KEY key_username (username), UNIQUE KEY key_email (email), UNIQUE KEY key_phone (phone), UNIQUE KEY key_activation_key (activation_key), INDEX index_status (status), INDEX index_created_at (created_at) ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_520_ci; CREATE TABLE IF NOT EXISTS ezy_user_role_names ( id bigint unsigned NOT NULL AUTO_INCREMENT, name varchar(45) NOT NULL COLLATE utf8mb4_unicode_520_ci NOT NULL, display_name varchar(60) COLLATE utf8mb4_unicode_520_ci NOT NULL, created_at datetime NOT NULL, updated_at datetime NOT NULL, PRIMARY KEY (id), UNIQUE KEY key_name (name), UNIQUE KEY key_display_name (display_name) ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_520_ci; CREATE TABLE IF NOT EXISTS ezy_user_roles ( role_id bigint unsigned NOT NULL, user_id bigint unsigned NOT NULL, created_at datetime NOT NULL, PRIMARY KEY (role_id, user_id), INDEX index_role_id (role_id), INDEX index_user_id (user_id) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_520_ci;
Thì từ tên quyền em sẽ tìm được ra roleId. Khi em xóa quyền admin của user, em có thể tìm kiếm các quyền khác mà em muốn xóa khỏi user, ví dụ:
roleIds = select id from ezy_user_role_names where name in ('user', 'admin'); delete from ezy_user_roles where userId = ? and role_id in :roleIds
-
0
- Reply
- Questions 937
- Answers 2.0K
- Best Answers 115
- Users 405
Related Questions
Recent Activities
-
Voted up question. January 9, 2023 at 2:54 pm
-
Voted up question. January 9, 2023 at 2:54 pm
-
Voted up question. January 9, 2023 at 2:54 pm
-
Voted up question. January 9, 2023 at 2:54 pm
-
Voted up question. January 9, 2023 at 2:54 pm
Top Members
Trending Tags
php
laravel
react-native
qr
stresstest
thiết kế tầng trong dự án
controllerservice
serialization
wordpress
xss
programming-language
facebook
vietqr
network
room database
restful
map
video call
tcp
webrtc
câu hỏi
excel-object-mapper
vuejs
jquery
đồ án tốt nghiệp
lỗi font
oracle
postman
cron
elasticsearch
di
ioc
format json
get file zip
zip file
resttemplate
design patterns
architecture
scheduled spring boot
datetime
#formatdate
paginaiton
microservices
communication
multi-threading
synchronize
otp message
send mail
ssl email
send email
jsonproperty
join
json to object
scheduled
solution
spring websocket cors
refactor
export compliance
config-css
spring websocket
stream api
webflux
mobile
push-noti
jenkins
repository
replica
jotform
refresh token
access token
maria db
junit-test
gorilla
procedure
filter
exception
null
exception handler
upload
resilence4j
bucket4j
readmoretextview
regex
email
qrcode
list
.net
.net oop
partition
oop
c# .net
executor
threadpool
mq
message queue
app
background
h2 database
gallery
deadlock
transaction
monitoring
main
jsp
servlet
tomcat
node.js
watermark
pdf
excel
profile
properties
image
authentication
plugin
udp
access app
project management
estimation
database migration
migration
crawl data
graduation thesis
utf-8 file
validate date
connection pool
thread pool
concurrent
convert date to number
load balancer
nginx
synchronized
lock
graphql
stress test
test
json file
networking
handy terminal
study
computer science
webassembly
assembly
nan
cookie
session
mail template
mail
cosmos-sdk
push notification
socket server
round robin
jetbrains
validate
btree
glide
floating point
artificial intelligence
ai
private_key
duration
hyperloglog
gateway
dns
exception handle
transfer
deploy contract
uniswap
s3
web
ezymq-kafka
ezyredis
soap
transfer git
mongo
integration-test
branch
boot-nodes
springwebflux mysql
index
lưu trữ
dữ liệu lớn
spring-boot-test
macos
apache poi
guide
keycloak
queue
multiple tenant
spring security
extensions
pancakeswap
structure trong spring boot
postgresql
totp
n
cloud reliability
python
golang
bash script
messaging
reactive
roadmap
anti-flooding
cosmos
jvm
abstract class
interface
log4j
non-blocking io
career path
singleton
web3 client
zookeeper
soft delete
centos
ansible
binding
tracking location
socket
optimize
resource
eclip
naming convention
naming
game-room
game-server
log4j-core
jsp & servlet
java core
system environment variables
load-balancing
pgpool
datasource
spring data jpa
schedule
thread
rest
grapql
asyncawait
multithread
math
vector
hibernateconfig
javaw
sjis
shift jis
stream
blog
java spring
nodejs
hibernate
ipfs
issue
build
bundle
vue cli
vue
webpack
fulltextsearch
view
sql
css
html
dex
decentralized exchange
ethereum login
javascript
keep promise
https
nft game
login
thymeleaf
erc721
contract
erc20
web3
smart contract
ropssten
ropsten
metamask
windows 11
bitcoin
eth
ethereum
flutter
isolate
backend nestjs
java web
springsecurity
machine learning
backend
spring aop
winforms
deep learning
model
spring redis
request
pre
nio
io
batch
unit test
slack
log
indexing
sql server
devops
cors
big project
work
frontend
api
cache
draw.io
content-disposition
reactjs download
datastructure
javacore
distraction programing
callback
async
promise
threadjava
unity
orm
rust
pointer
panic
merge
commit
.net core
js
kerberos
security
go
netcore
sosanh
rabbitmq
grpc
ezyhttp
python unicode
front-end
fe
docker
buffered
server
exyfox
career
spring-jpa
jpa
du học
job
bean
spring
reactjs
fullstack
c#
kotlin
sse
websocket
mysql
springboot
rxjava
future
push message android
recyclerview
android
cast
intellij
maven
netty
multithreading
msgpack
json
design-pattern
library
spring boot
redis
hazelcast
atomicboolean
volatile
storage
it
git
caching
chat
game
nft
blockchain
freetank
game-box
jwt
microservice
search
kafka
get
upload file
download
http
opensource
cloud
languague
programming
database
pagination
editor
stackask
question
ezyfox-boot
ezyfox-server
ezyfox
phỏng vấn
java
ezyfoxserver