Update login method structures and comments

This commit is contained in:
nxshock 2019-07-20 11:30:16 +05:00
parent 35f75a6ddd
commit 32637e5c37
2 changed files with 32 additions and 7 deletions

View File

@ -37,7 +37,7 @@ func LoginHandler(w http.ResponseWriter, r *http.Request) {
// https://models.org/docs/spec/client_server/latest#get-models-client-r0-login // https://models.org/docs/spec/client_server/latest#get-models-client-r0-login
case "GET": case "GET":
{ {
response := login.GetLoginReply{ response := login.GetReply{
Flows: []login.Flow{ Flows: []login.Flow{
login.Flow{Type: common.AuthenticationTypePassword}, login.Flow{Type: common.AuthenticationTypePassword},
}, },
@ -62,7 +62,7 @@ func LoginHandler(w http.ResponseWriter, r *http.Request) {
return return
} }
response := login.LoginReply{ response := login.PostReply{
UserID: request.Identifier.User, UserID: request.Identifier.User,
AccessToken: token, AccessToken: token,
} }

View File

@ -4,17 +4,42 @@ import (
common "github.com/nxshock/signaller/internal/models/common" common "github.com/nxshock/signaller/internal/models/common"
) )
type LoginReply struct { // PostReply is returned reply from POST login method
AccessToken string `json:"access_token"` // https://matrix.org/docs/spec/client_server/latest#get-matrix-client-r0-login
HomeServer string `json:"home_server,omitempty"` // TODO: check api type PostReply struct {
UserID string `json:"user_id"` UserID string `json:"user_id"` // The fully-qualified Matrix ID that has been registered.
AccessToken string `json:"access_token"` // An access token for the account. This access token can then be used to authorize other requests.
DeviceID string `json:"device_id"` // ID of the logged-in device. Will be the same as the corresponding parameter in the request, if one was specified.
WellKnown DiscoveryInformation `json:"well_known,omitempty"` // Optional client configuration provided by the server. If present, clients SHOULD use the provided object to reconfigure themselves, optionally validating the URLs within. This object takes the same form as the one returned from .well-known autodiscovery.
} }
// DiscoveryInformation is client configuration provided by the server
// https://matrix.org/docs/spec/client_server/latest#get-matrix-client-r0-login
type DiscoveryInformation struct {
HomeServer HomeserverInformation `json:"m.homeserver"` // Required. Used by clients to discover homeserver information.
IdentityServer IdentityServerInformation `json:"m.identity_server,omitempty"` // Used by clients to discover ide
}
// HomeserverInformation is used by clients to discover homeserver information
// https://matrix.org/docs/spec/client_server/latest#get-matrix-client-r0-login
type HomeserverInformation struct {
BaseURL string `json:"base_url"` // Required. The base URL for the homeserver for client-server connections.
}
// IdentityServerInformation is used by clients to discover identity server information.
// https://matrix.org/docs/spec/client_server/latest#get-matrix-client-r0-login
type IdentityServerInformation struct {
BaseURL string `json:"base_url"` // Required. The base URL for the homeserver for client-server connections.
}
// Flow is the homeserver's supported login types
// https://matrix.org/docs/spec/client_server/latest#get-matrix-client-r0-login
type Flow struct { type Flow struct {
Type common.AuthenticationType `json:"type"` Type common.AuthenticationType `json:"type"`
} }
// GetReply is returned reply from GET login method
// https://matrix.org/docs/spec/client_server/latest#get-matrix-client-r0-login // https://matrix.org/docs/spec/client_server/latest#get-matrix-client-r0-login
type GetLoginReply struct { type GetReply struct {
Flows []Flow `json:"flows"` // The homeserver's supported login types Flows []Flow `json:"flows"` // The homeserver's supported login types
} }