python - 我在 DRF+Angular 中的实现无法区分角色
问题描述
我已经实现了一个使用 django 作为后端和 angular 作为前端的登录系统。
在后端,身份验证是通过与 auth/signup 关联的视图实现的
from django.contrib import admin
from django.urls import include, path
from rest_framework import routers
from shopping.views import listatodoseventos
from rest_framework_jwt.views import obtain_jwt_token, refresh_jwt_token
urlpatterns = [
path('admin/', admin.site.urls),
path('api-auth/', include('rest_framework.urls')),
path('events',listatodoseventos),
path('auth/', include('rest_auth.urls')),
path('auth/signup/', include('rest_auth.registration.urls')),
path('auth/refresh-token/', refresh_jwt_token)
]
在前端是通过这种方法完成的
signup(username:string, email:string, password1:string, password2:string){
//todo
return this.http.post(
this.apiRoot.concat('signup/'),
{username, email, password1, password2}
).pipe(
tap(response=>this.setSession(response)),
shareReplay()
);
}
It generates me these tables related with users.
I want to associate each user with a role.
But I don't know how to do that cause I don't know how to create entries in auth_user_groups
解决方案
推荐阅读
- python - 如何从 Pandas 数据框在 MySQL 数据库中创建新表
- r - Rcpp:动态声明 ListMatrix 的元素(NumericMatrix)
- scala - Scala playframework - 对象 java.lang.ProcessBuilder.Redirect 不是一个值
- python - Django-Channels 2 没有在“连接”中保留会话数据集
- java - Android 从 webhost 获取 json 添加标记 ERROR E/zygote64
- javascript - 无法通过 JQUERY 在动态添加的表行中添加 datetimepicker
- javascript - 使用 vanilla JS 的事件委托
- c++ - C ++ ofstream不会打开文件
- python - 在 Keras 中加载保存的模型(双向 LSTM)
- java - 为什么超类字段的泛型类型不会被擦除到子类型中的具体绑定?