下面是描述用户如何登录应用程序的序列图:
@startuml
autonumber
actor Individual as individual <<registered>>
boundary "Sign In Page" as signInPage <<ui>>
control "Auth Service" as auth
entity User as user
database Repository as repo
individual -> signInPage ++ : enter username or email
individual -> signInPage : enter password
individual -> signInPage : sign in
signInPage -> auth ++ : auth user
auth -> repo ++ : get user by username or email
return user
auth -> auth ++-- : granted = user exists and credentials are correct
return granted
alt granted is true
autonumber stop
autonumber 9 1
signInPage -> signInPage ++-- : redirect to home page
signInPage --> individual : home page
else granted is false
autonumber stop
autonumber 9 1
signInPage -> signInPage ++-- : redirect to error page
return error page
end
@enduml
上图已正确渲染...
但是
alt
的实现至少是丑陋的。如果授予访问权限,Sign In Page
应重定向至主页;否则,如果访问被拒绝,Sign In Page
将重定向到错误页面。正如你所看到的,为了处理手动activation
,在alt
部分我必须向Individual
发回一条消息,而在else
部分我必须使用return
语句。有没有更好的方式来表示这一点?
这是基于我对上述问题的评论的答案。
@startuml
'round the notes to look like activity boxes
skinparam roundcorner 10
autonumber
actor Individual as individual <<registered>>
boundary "Sign In Page" as signInPage <<ui>>
control "Auth Service" as auth
entity User as user
database Repository as repo
individual -> signInPage ++ : enter username or email
individual -> signInPage : enter password
individual -> signInPage : sign in
signInPage -> auth ++ : auth user
auth -> repo ++ : get user by username or email
return user
rnote over auth: granted = user exists\nand credentials\nare correct
return granted
rnote over signInPage: page = granted ?\nlogin page :\nerror page
return page
@enduml