mirror of
https://github.com/signaller-matrix/signaller.git
synced 2024-11-22 02:12:20 +00:00
refactor: Make "get login flows" using models package
This commit is contained in:
parent
b140a4f726
commit
b0ac28ab22
@ -8,6 +8,8 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/nxshock/signaller/internal/models/common"
|
||||||
|
|
||||||
"github.com/nxshock/signaller/internal/models"
|
"github.com/nxshock/signaller/internal/models"
|
||||||
login "github.com/nxshock/signaller/internal/models/login"
|
login "github.com/nxshock/signaller/internal/models/login"
|
||||||
register "github.com/nxshock/signaller/internal/models/register"
|
register "github.com/nxshock/signaller/internal/models/register"
|
||||||
@ -35,21 +37,14 @@ 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":
|
||||||
{
|
{
|
||||||
type LoginFlow struct {
|
response := login.GetLoginReply{
|
||||||
Type string `json:"type"`
|
Flows: []login.Flow{
|
||||||
|
login.Flow{Type: common.AuthenticationTypePassword},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
type Response struct {
|
|
||||||
Flows []LoginFlow `json:"flows"`
|
|
||||||
}
|
|
||||||
|
|
||||||
response := Response{
|
|
||||||
Flows: []LoginFlow{
|
|
||||||
LoginFlow{Type: string(M_LOGIN_PASSWORD)}}}
|
|
||||||
|
|
||||||
sendJsonResponse(w, http.StatusOK, response)
|
sendJsonResponse(w, http.StatusOK, response)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://models.org/docs/spec/client_server/latest#post-models-client-r0-login
|
// https://models.org/docs/spec/client_server/latest#post-models-client-r0-login
|
||||||
case "POST":
|
case "POST":
|
||||||
{
|
{
|
||||||
@ -69,7 +64,8 @@ func LoginHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
|
|
||||||
response := login.LoginReply{
|
response := login.LoginReply{
|
||||||
UserID: request.Identifier.User,
|
UserID: request.Identifier.User,
|
||||||
AccessToken: token}
|
AccessToken: token,
|
||||||
|
}
|
||||||
|
|
||||||
sendJsonResponse(w, http.StatusOK, response)
|
sendJsonResponse(w, http.StatusOK, response)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user