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
|
@ -27,6 +27,7 @@ import (
|
|||
|
||||
var (
|
||||
voice bool
|
||||
captcha string
|
||||
|
||||
RegisterAccountCmd = &cobra.Command{
|
||||
Use: "register [phone number]",
|
||||
|
@ -44,6 +45,7 @@ var (
|
|||
ID: requestID,
|
||||
Username: args[0],
|
||||
Voice: voice,
|
||||
Captcha: captcha,
|
||||
})
|
||||
if err != nil {
|
||||
log.Fatal("error sending request to signald: ", err)
|
||||
|
@ -51,9 +53,12 @@ var (
|
|||
c := make(chan v0.LegacyResponse)
|
||||
go common.Signald.Listen(c)
|
||||
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>")
|
||||
} 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)
|
||||
}
|
||||
},
|
||||
|
@ -62,4 +67,5 @@ var (
|
|||
|
||||
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().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"`
|
||||
Username string `json:"username,omitempty"`
|
||||
MessageBody string `json:"messageBody,omitempty"`
|
||||
RecipientAddress JsonAddress `json:"recipientAddress,omitempty"`
|
||||
RecipientAddress *JsonAddress `json:"recipientAddress,omitempty"`
|
||||
RecipientGroupID string `json:"recipientGroupId,omitempty"`
|
||||
Voice bool `json:"voice,omitempty"`
|
||||
Code string `json:"code,omitempty"`
|
||||
|
@ -32,6 +32,7 @@ type LegacyRequest struct {
|
|||
GroupName string `json:"groupName,omitempty"`
|
||||
Members []string `json:"members,omitempty"`
|
||||
Avatar string `json:"avatar,omitempty"`
|
||||
Captcha string `json:"captcha,omitempty"`
|
||||
}
|
||||
|
||||
type JsonAddress struct {
|
||||
|
|
Loading…
Reference in a new issue