login: wrap some common errors to return 400 instead of 500 (#114)
This commit is contained in:
@@ -19,6 +19,7 @@ package connector
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"maunium.net/go/mautrix/bridgev2"
|
||||
@@ -38,6 +39,24 @@ const (
|
||||
LoginStepIDComplete = "fi.mau.telegram.login.complete"
|
||||
)
|
||||
|
||||
var (
|
||||
ErrInvalidPassword = bridgev2.RespError{
|
||||
ErrCode: "FI.MAU.TELEGRAM.INVALID_PASSWORD",
|
||||
Err: "Invalid password",
|
||||
StatusCode: http.StatusBadRequest,
|
||||
}
|
||||
ErrPhoneCodeInvalid = bridgev2.RespError{
|
||||
ErrCode: "FI.MAU.TELEGRAM.PHONE_CODE_INVALID",
|
||||
Err: "Invalid phone code",
|
||||
StatusCode: http.StatusBadRequest,
|
||||
}
|
||||
ErrSignUpNotSupported = bridgev2.RespError{
|
||||
ErrCode: "FI.MAU.TELEGRAM.SIGN_UP_NOT_SUPPORTED",
|
||||
Err: "New account creation is not supported",
|
||||
StatusCode: http.StatusBadRequest,
|
||||
}
|
||||
)
|
||||
|
||||
func (tg *TelegramConnector) GetLoginFlows() []bridgev2.LoginFlow {
|
||||
return []bridgev2.LoginFlow{
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user