events: rename context.token to context.secret

This commit is contained in:
Jens Langhammer 2021-02-09 20:10:43 +01:00
parent 71c9108f89
commit a7d0a50859
3 changed files with 12 additions and 6 deletions

View File

@ -49,5 +49,7 @@ class TokenViewSet(ModelViewSet):
if not tokens.exists():
raise Http404
token = tokens.first()
Event.new(EventAction.SECRET_VIEW, token=token).from_http(request)
Event.new( # noqa # nosec
EventAction.SECRET_VIEW, secret=token
).from_http(request)
return Response(TokenViewSerializer({"key": token.key}).data)

View File

@ -10,9 +10,13 @@ def token_view_to_secret_view(apps: Apps, schema_editor: BaseDatabaseSchemaEdito
db_alias = schema_editor.connection.alias
Event = apps.get_model("authentik_events", "Event")
Event.objects.using(db_alias).filter(action="token_view").update(
action=EventAction.SECRET_VIEW
)
events = Event.objects.using(db_alias).filter(action="token_view")
for event in events:
event.context["secret"] = event.context.pop("token")
event.action = EventAction.SECRET_VIEW
Event.objects.using(db_alias).bulk_update(events, ["context", "action"])
class Migration(migrations.Migration):

View File

@ -91,8 +91,8 @@ export class EventInfo extends LitElement {
<ak-expand>${this.defaultResponse()}</ak-expand>`;
case "secret_view":
return html`
<h3>${gettext("Token:")}</h3>
${this.getModelInfo(this.event.context.token as EventContext)}`;
<h3>${gettext("Secret:")}</h3>
${this.getModelInfo(this.event.context.secret as EventContext)}`;
case "property_mapping_exception":
return html`<div class="pf-l-flex">
<div class="pf-l-flex__item">