Add captcha support to register command
captcha_required detection doesn't work unfortunately, as the captcha required message doesn't unmarshal due to the "data" field being a string
This commit is contained in:
parent
6b58faf101
commit
83cf9efc94
2 changed files with 11 additions and 4 deletions
|
@ -26,7 +26,8 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
voice bool
|
voice bool
|
||||||
|
captcha string
|
||||||
|
|
||||||
RegisterAccountCmd = &cobra.Command{
|
RegisterAccountCmd = &cobra.Command{
|
||||||
Use: "register [phone number]",
|
Use: "register [phone number]",
|
||||||
|
@ -44,6 +45,7 @@ var (
|
||||||
ID: requestID,
|
ID: requestID,
|
||||||
Username: args[0],
|
Username: args[0],
|
||||||
Voice: voice,
|
Voice: voice,
|
||||||
|
Captcha: captcha,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal("error sending request to signald: ", err)
|
log.Fatal("error sending request to signald: ", err)
|
||||||
|
@ -51,9 +53,12 @@ var (
|
||||||
c := make(chan v0.LegacyResponse)
|
c := make(chan v0.LegacyResponse)
|
||||||
go common.Signald.Listen(c)
|
go common.Signald.Listen(c)
|
||||||
response := signald.GetLegacyResponse(c, requestID)
|
response := signald.GetLegacyResponse(c, requestID)
|
||||||
if response.Type == "verification_required" {
|
switch response.Type {
|
||||||
|
case "verification_required":
|
||||||
log.Println("verification code requested. submit with: signaldctl account verify", args[0], "<code>")
|
log.Println("verification code requested. submit with: signaldctl account verify", args[0], "<code>")
|
||||||
} else {
|
case "captcha_required":
|
||||||
|
log.Println("captcha required. Please provide a captcha token with the --captcha argument (see https://gitlab.com/signald/signald/-/wikis/Captchas)")
|
||||||
|
default:
|
||||||
log.Fatalf("unexpected response from signald when requesting verification code: %+v", response)
|
log.Fatalf("unexpected response from signald when requesting verification code: %+v", response)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -62,4 +67,5 @@ var (
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
RegisterAccountCmd.Flags().BoolVarP(&voice, "voice", "V", false, "request verification code be sent via an automated voice call (code is sent via SMS by default)")
|
RegisterAccountCmd.Flags().BoolVarP(&voice, "voice", "V", false, "request verification code be sent via an automated voice call (code is sent via SMS by default)")
|
||||||
|
RegisterAccountCmd.Flags().StringVarP(&captcha, "captcha", "c", "", "a captcha token may be required to register, see https://gitlab.com/signald/signald/-/wikis/Captchas for how to get one")
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,7 @@ type LegacyRequest struct {
|
||||||
ID string `json:"id,omitempty"`
|
ID string `json:"id,omitempty"`
|
||||||
Username string `json:"username,omitempty"`
|
Username string `json:"username,omitempty"`
|
||||||
MessageBody string `json:"messageBody,omitempty"`
|
MessageBody string `json:"messageBody,omitempty"`
|
||||||
RecipientAddress JsonAddress `json:"recipientAddress,omitempty"`
|
RecipientAddress *JsonAddress `json:"recipientAddress,omitempty"`
|
||||||
RecipientGroupID string `json:"recipientGroupId,omitempty"`
|
RecipientGroupID string `json:"recipientGroupId,omitempty"`
|
||||||
Voice bool `json:"voice,omitempty"`
|
Voice bool `json:"voice,omitempty"`
|
||||||
Code string `json:"code,omitempty"`
|
Code string `json:"code,omitempty"`
|
||||||
|
@ -32,6 +32,7 @@ type LegacyRequest struct {
|
||||||
GroupName string `json:"groupName,omitempty"`
|
GroupName string `json:"groupName,omitempty"`
|
||||||
Members []string `json:"members,omitempty"`
|
Members []string `json:"members,omitempty"`
|
||||||
Avatar string `json:"avatar,omitempty"`
|
Avatar string `json:"avatar,omitempty"`
|
||||||
|
Captcha string `json:"captcha,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type JsonAddress struct {
|
type JsonAddress struct {
|
||||||
|
|
Loading…
Reference in a new issue