From c8b6e0c35d74b19f9ebcbdb1ed25f7161468ea2f Mon Sep 17 00:00:00 2001 From: icurfer Date: Thu, 24 Apr 2025 11:22:30 +0900 Subject: [PATCH] update --- users/admin.py | 23 +++++++++++++++++++---- version | 2 +- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/users/admin.py b/users/admin.py index 471b01b..df8be79 100644 --- a/users/admin.py +++ b/users/admin.py @@ -1,30 +1,45 @@ from django.contrib import admin from django.contrib.auth.admin import UserAdmin from .models import CustomUser +from rest_framework_simplejwt.tokens import RefreshToken class CustomUserAdmin(UserAdmin): model = CustomUser - list_display = ('email', 'name', 'grade', 'is_active', 'is_staff') + list_display = ('email', 'name', 'grade', 'is_active', 'is_staff', 'jwt_preview') list_filter = ('grade', 'is_active', 'is_staff') search_fields = ('email', 'name') ordering = ('email',) - readonly_fields = ('created_at',) + readonly_fields = ('created_at', 'last_login', 'jwt_preview') # ✅ jwt_preview 추가 fieldsets = ( (None, {'fields': ('email', 'password')}), ('Personal Info', {'fields': ('name', 'grade')}), ('Permissions', {'fields': ('is_active', 'is_staff', 'is_superuser', 'groups', 'user_permissions')}), ('Important dates', {'fields': ('last_login', 'created_at')}), + ('JWT Token Preview', {'fields': ('jwt_preview',)}), # ✅ 별도 섹션으로 추가 ) add_fieldsets = ( (None, { 'classes': ('wide',), - 'fields': ('email', 'name', 'grade', 'password1', 'password2', 'is_active', 'is_staff', 'is_superuser')} - ), + 'fields': ( + 'email', 'name', 'grade', 'password1', 'password2', + 'is_active', 'is_staff', 'is_superuser' + ), + }), ) + def jwt_preview(self, obj): + try: + refresh = RefreshToken.for_user(obj) + access_token = str(refresh.access_token) + return access_token[:30] + "..." # ✅ 일부만 보여줌 + except Exception: + return "N/A" + + jwt_preview.short_description = "JWT Access Preview" + admin.site.register(CustomUser, CustomUserAdmin) diff --git a/version b/version index bd52db8..05b19b1 100644 --- a/version +++ b/version @@ -1 +1 @@ -0.0.0 \ No newline at end of file +0.0.4 \ No newline at end of file