diff --git a/appview/oauth/accounts.go b/appview/oauth/accounts.go index 1b62f8cb..681861c9 100644 --- a/appview/oauth/accounts.go +++ b/appview/oauth/accounts.go @@ -23,14 +23,11 @@ type AccountRegistry struct { } type MultiAccountUser struct { - Active *User + Active User Accounts []AccountInfo } func (m *MultiAccountUser) Did() string { - if m.Active == nil { - return "" - } return m.Active.Did } @@ -122,7 +119,7 @@ func (o *OAuth) GetMultiAccountUser(r *http.Request) *MultiAccountUser { registry := o.GetAccounts(r) return &MultiAccountUser{ - Active: &User{ + Active: User{ Did: sess.Data.AccountDID.String(), }, Accounts: registry.Accounts, diff --git a/appview/oauth/accounts_test.go b/appview/oauth/accounts_test.go index 7df95fbc..6d57536e 100644 --- a/appview/oauth/accounts_test.go +++ b/appview/oauth/accounts_test.go @@ -210,21 +210,3 @@ func TestAccountRegistry_FindAccount(t *testing.T) { } }) } - -func TestMultiAccountUser_Did(t *testing.T) { - t.Run("with active user", func(t *testing.T) { - user := &MultiAccountUser{ - Active: &User{Did: "did:plc:test"}, - } - if user.Did() != "did:plc:test" { - t.Errorf("Did() = %s, want did:plc:test", user.Did()) - } - }) - - t.Run("with nil active", func(t *testing.T) { - user := &MultiAccountUser{Active: nil} - if user.Did() != "" { - t.Errorf("Did() = %s, want empty string", user.Did()) - } - }) -} diff --git a/appview/pages/pages.go b/appview/pages/pages.go index d8c9f475..4d5bdb11 100644 --- a/appview/pages/pages.go +++ b/appview/pages/pages.go @@ -230,10 +230,10 @@ func (p *Pages) Favicon(w io.Writer) error { } type LoginParams struct { - ReturnUrl string - ErrorCode string - AddAccount bool - LoggedInUser *oauth.MultiAccountUser + ReturnUrl string + ErrorCode string + AddAccount bool + Accounts []oauth.AccountInfo } func (p *Pages) Login(w io.Writer, params LoginParams) error { diff --git a/appview/pages/templates/user/login.html b/appview/pages/templates/user/login.html index 22ce49ec..b91eeaf2 100644 --- a/appview/pages/templates/user/login.html +++ b/appview/pages/templates/user/login.html @@ -31,14 +31,13 @@ {{ end }} - {{ if and .LoggedInUser .LoggedInUser.Accounts }} - {{ $accounts := .LoggedInUser.Accounts }} + {{ if .Accounts }}
Saved accounts
- {{ range $accounts }} + {{ range .Accounts }}