defmodule GitGudWeb.UserLive.SecurityLog do
@moduledoc """
`/users/settings/security-log[/:category[/before|after/:id]]` — your
account's history (`GitGud.Audit`, `{:user, user}`): sign-ins and
failed ones, sign-outs, re-authentication, password and email
changes, two-factor, security keys, access tokens, SSH keys and your
own runners — and what an org's admins or moderators did to you
(invited, removed, banned).
In sudo mode, like the token and SSH key pages: the log says where
you sign in from. Each entry you made yourself shows the address and
browser it came from; those of entries someone else made about you
stay theirs.
"""
use GitGudWeb, :live_view
alias GitGudWeb.AuditLive.Page
# Account entries, your own runners, and the categories of what can
# be done to someone.
@categories ~w(account runners members moderation)
@impl true
def mount(_params, _session, socket) do
user = socket.assigns.current_scope.user
{:ok,
socket
|> assign(:page_title, "Security log")
|> Page.setup(@categories, refines: [], own_requests: user.id)}
end
@impl true
def handle_params(params, uri, socket) do
user = socket.assigns.current_scope.user
Page.params(socket, params, uri, ~p"/users/settings/security-log", {:user, user})
end
@impl true
def handle_info({:audit, id}, socket), do: Page.live(socket, id, true)
@impl true
def render(assigns) do
~H"""
<Layouts.app flash={@flash} current_scope={@current_scope}>
<div class="space-y-6 max-w-3xl">
<header class="space-y-1">
<h1 class="text-xl font-semibold">Security log</h1>
<p class="text-sm opacity-70">
Sign-ins, credentials and changes to your account, and what an
organization's admins did about you — newest first. Your own
entries show where they came from.
</p>
</header>
<Page.body
base={@base}
filters={@filters}
filter_form={@filter_form}
categories={@categories}
refines={@refines}
own_requests={@own_requests}
entries={@streams.entries}
older={@older}
newer={@newer}
/>
</div>
</Layouts.app>
"""
end
end
neiam
/gitgud
Git Gud
public · Issues · Pulls · Labels · Forks · Compare · Actions success · Badges · Packages
⭐
1
Log in to mark this repository.
2.2 KiB · text
History
b868907