Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 17 additions & 14 deletions server/handle_oauth_authorize.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,13 @@ func (s *Server) handleOauthAuthorizeGet(e echo.Context) error {
// render page for logged out dev
if s.config.Version == "dev" && parRequest.ClientID == "" {
return e.Render(200, "authorize.html", map[string]any{
"Scopes": []string{"atproto", "transition:generic"},
"AppName": "DEV MODE AUTHORIZATION PAGE",
"Handle": "paula.cocoon.social",
"RequestUri": "",
"Accounts": []string{},
"ActiveDid": "",
"Scopes": []string{"atproto", "transition:generic"},
"AppName": "DEV MODE AUTHORIZATION PAGE",
"Handle": "paula.cocoon.social",
"RequestUri": "",
"Accounts": []string{},
"ActiveDid": "",
"HasLoginHint": false,
})
}
return helpers.InputError(e, to.StringPtr("no request uri and invalid parameters"))
Expand Down Expand Up @@ -134,7 +135,8 @@ func (s *Server) handleOauthAuthorizeGet(e echo.Context) error {
return helpers.ServerError(e, to.StringPtr(err.Error()))
}

if req.Parameters.LoginHint != nil && *req.Parameters.LoginHint != "" {
hasLoginHint := req.Parameters.LoginHint != nil && *req.Parameters.LoginHint != ""
if hasLoginHint {
did, err := s.resolveLoginHintToDid(ctx, *req.Parameters.LoginHint)
if err != nil || !slices.Contains(getSessionDids(sess), did) {
return e.Redirect(303, "/account/signin?"+e.QueryParams().Encode())
Expand All @@ -159,13 +161,14 @@ func (s *Server) handleOauthAuthorizeGet(e echo.Context) error {
appName := client.Metadata.ClientName

data := map[string]any{
"Scopes": scopes,
"AppName": appName,
"RequestUri": input.RequestUri,
"QueryParams": e.QueryParams().Encode(),
"Handle": repo.Actor.Handle,
"Accounts": accounts,
"ActiveDid": repo.Repo.Did,
"Scopes": scopes,
"AppName": appName,
"RequestUri": input.RequestUri,
"QueryParams": e.QueryParams().Encode(),
"Handle": repo.Actor.Handle,
"Accounts": accounts,
"ActiveDid": repo.Repo.Did,
"HasLoginHint": hasLoginHint,
}

return e.Render(200, "authorize.html", data)
Expand Down
2 changes: 1 addition & 1 deletion server/templates/authorize.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ <h2>Authorizing with {{ .AppName }}</h2>
You are signed in as <b>{{ .Handle }}</b>.
<a href="/account/signout?{{ .QueryParams }}">Sign out this account</a>
</p>
{{ if gt (len .Accounts) 1 }}
{{ if and (not .HasLoginHint) (gt (len .Accounts) 1) }}
<form action="/account/switch" method="post">
<input type="hidden" name="query_params" value="{{ .QueryParams }}" />
<input type="hidden" name="next" value="/oauth/authorize" />
Expand Down
Loading