leaflet_svelte/docs/diagrams/seq-auth.puml
2026-06-17 00:20:55 +09:00

41 lines
1.3 KiB
Text
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

@startuml seq-auth
title Аутентификация: проверка сессии, вход, выход
autonumber
actor "Пользователь" as user
participant "LoginForm /\nguard.ts" as ui
participant "authApi" as authapi
participant "client.ts\nrequest<T>()" as client
participant "Backend\n(Django)" as be
== Проверка сессии при открытии защищённой страницы ==
ui -> authapi : requireAuthenticated()
authapi -> client : session()
client -> be : GET /api/session/
be --> client : { isAuthenticated }
client --> authapi : SessionInfo
alt не аутентифицирован
authapi --> ui : goto('/login')
end
== Вход ==
user -> ui : ввод логина и пароля
ui -> authapi : login(username, password)
authapi -> client : post('/login/', {username, password})
client -> be : POST /api/login/
be --> client : 200 { detail } | 400/401 ApiError
client --> authapi : результат
authapi -> client : whoami()
client -> be : GET /api/whoami/
be --> client : { username }
client --> ui : WhoAmI
ui --> user : переход на рабочую страницу
== Выход ==
user -> ui : «Выйти»
ui -> authapi : logout()
authapi -> client : post('/logout/', {})
client -> be : POST /api/logout/
be --> client : 204
client --> ui : сброс состояния, goto('/login')
@enduml