From a6096ece56400de9107f9b1180f16082fbb6f8e4 Mon Sep 17 00:00:00 2001 From: Raigiku Date: Mon, 10 Jun 2024 20:16:10 +0200 Subject: [PATCH 1/2] add confirmation redirect url for signup --- endpoints/signup.go | 11 ++++++++++- types/api.go | 10 +++++----- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/endpoints/signup.go b/endpoints/signup.go index f9ba247..6dcfed5 100644 --- a/endpoints/signup.go +++ b/endpoints/signup.go @@ -16,7 +16,7 @@ const signupPath = "/signup" // POST /signup // -// Register a new user with an email and password. +// Register a new user with an email, password and optional redirect url after email confirmation func (c *Client) Signup(req types.SignupRequest) (*types.SignupResponse, error) { body, err := json.Marshal(req) if err != nil { @@ -28,6 +28,15 @@ func (c *Client) Signup(req types.SignupRequest) (*types.SignupResponse, error) return nil, err } + if req.ConfirmationRedirectUrl != "" { + q := r.URL.Query() + q.Add("redirect_to", req.ConfirmationRedirectUrl) + r.URL.RawQuery = q.Encode() + + // Set up a client that will not follow the redirect. + c.client = noRedirClient(c.client) + } + resp, err := c.client.Do(r) if err != nil { return nil, err diff --git a/types/api.go b/types/api.go index 95fed2e..c8aba12 100644 --- a/types/api.go +++ b/types/api.go @@ -425,11 +425,11 @@ type SettingsResponse struct { } type SignupRequest struct { - Email string `json:"email,omitempty"` - Phone string `json:"phone,omitempty"` - Password string `json:"password,omitempty"` - Data map[string]interface{} `json:"data,omitempty"` - + Email string `json:"email,omitempty"` + Phone string `json:"phone,omitempty"` + Password string `json:"password,omitempty"` + Data map[string]interface{} `json:"data,omitempty"` + ConfirmationRedirectUrl string `json:"-"` // Provide Captcha token if enabled. SecurityEmbed } From 099309d3da3d20acfa581f9ff5b091eda29ee614 Mon Sep 17 00:00:00 2001 From: Raigiku Date: Mon, 10 Jun 2024 20:18:36 +0200 Subject: [PATCH 2/2] revert comment --- endpoints/signup.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/endpoints/signup.go b/endpoints/signup.go index 6dcfed5..b3c29f8 100644 --- a/endpoints/signup.go +++ b/endpoints/signup.go @@ -16,7 +16,7 @@ const signupPath = "/signup" // POST /signup // -// Register a new user with an email, password and optional redirect url after email confirmation +// Register a new user with an email and password. func (c *Client) Signup(req types.SignupRequest) (*types.SignupResponse, error) { body, err := json.Marshal(req) if err != nil {