From 318c85ab65ee8ca222a2f9a972121532dc412cb0 Mon Sep 17 00:00:00 2001 From: diamondburned Date: Mon, 26 Oct 2020 22:17:38 -0700 Subject: [PATCH] Added Namer and Description into Authenticator This commit embeds the Namer interface into Authenticator as well as adding the new Description method, both of which returns a text.Rich. These methods are added to provide contextual clues to the user about each Authenticator method. Frontends can use the Name as the title, so the name should be short, concise, and not include the name of the service. --- cchat.go | 6 ++++++ repository/main.go | 19 +++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/cchat.go b/cchat.go index cd7de73..a9b0170 100644 --- a/cchat.go +++ b/cchat.go @@ -202,12 +202,18 @@ type Attachments interface { // break // success // } type Authenticator interface { + // Namer returns a short and concise name of this Authenticator method. The name + // should not include the name of the Service. + Namer + // Authenticate will be called with a list of values with indices correspond to // the returned slice of AuthenticateEntry. Authenticate([]string) (Session, error) // Blocking // AuthenticateForm should return a list of authentication entries for the // frontend to render. AuthenticateForm() []AuthenticateEntry + // Description returns the description of this authenticator method. + Description() text.Rich } // Author is the interface for an identifiable author. The interface defines diff --git a/repository/main.go b/repository/main.go index e4726e3..ae35c45 100644 --- a/repository/main.go +++ b/repository/main.go @@ -706,7 +706,26 @@ var Main = Packages{ } `}, Name: "Authenticator", + Embeds: []EmbeddedInterface{{ + Comment: Comment{` + Namer returns a short and concise name of this Authenticator + method. The name should not include the name of the Service. + `}, + InterfaceName: "Namer", + }}, Methods: []Method{ + GetterMethod{ + method: method{ + Comment: Comment{` + Description returns the description of this + authenticator method. + `}, + Name: "Description", + }, + Returns: []NamedType{{ + Type: MakeQual("text", "Rich"), + }}, + }, GetterMethod{ method: method{ Comment: Comment{`