package web
import "git.zb-server.de/ZB-Server/uptimesebi/internal/i18n"
// Me is the signed-in user as the console templates see it.
type Me struct {
// IsOwner refers to the active organization.
IsOwner bool
ActiveSlug string
Email string
DisplayName string
TOTP bool
ActiveOrg string
Orgs []Org
// Can holds the permissions in the active organization.
Can map[string]bool
// Policy is the error code of an unmet sign-in policy of the active
// organization, or empty.
Policy string
// RecoveryCodesLeft counts unused TOTP recovery codes.
RecoveryCodesLeft int
// IsAdmin marks platform admins.
IsAdmin bool
// HasPassword is false for accounts that only sign in through SSO.
HasPassword bool
// OrgSuspended is set when platform admins suspended the active
// organization, with SuspendedReason as they gave it.
OrgSuspended bool
SuspendedReason string
// DeletesOrgs names the organizations the account owns; deleting it
// deletes them, with all their monitors.
DeletesOrgs []string
}
// Org is one entry of the organization switcher.
type Org struct {
ID string
Name string
Slug string
IsOwner bool
}
templ consoleShell(p Page, me Me) {
@Layout(p) {
@brandLockup("/")
if len(me.Orgs) > 1 {
} else if len(me.Orgs) == 1 {
{ me.Orgs[0].Name }
}
+
}
switch me.Policy {
case "totp_required_by_org":
@policyBanner("error.totp_required_by_org", "console.totp_missing_action", "/settings/security")
case "sso_required_by_org":
@policyBanner("error.sso_required_by_org", "console.sso_required_action", "/sso/"+me.ActiveSlug)
}
@flash(p)
{ children... }
}
}
// Identity is an SSO sign-in linked to the user in the active organization.
type Identity struct {
Provider string
Email string
}
// PlatformIdentities are the platform providers an account signs in with
// and those it could link.
type PlatformIdentities struct {
Linked []LinkedIdentity
Available []IDPButton
}
// LinkedIdentity is a platform provider linked to the account.
type LinkedIdentity struct {
ProviderID, Name, Email string
}
templ Security(p Page, me Me, identities []Identity, canLink bool, activity []AuditEntry, platform PlatformIdentities) {
@consoleShell(p, me) {
@auditList(activity)
@accountDataSection(me)
}
}
// recoveryOutput is filled by app.js with codes returned by the API; they
// are shown once and never rendered by the server.
templ recoveryOutput() {