Repository navigation
Expand file tree
/
Copy pathreset_password.go
More file actions
51 lines (46 loc) · 1.73 KB
/
Copy pathreset_password.go
File metadata and controls
51 lines (46 loc) · 1.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package authorizer
import (
"context"
"net/http"
authorizerv1 "github.com/authorizerdev/authorizer-proto-go/authorizer/v1"
"google.golang.org/protobuf/proto"
)
// ResetPasswordRequest defines attributes for reset_password request
type ResetPasswordRequest struct {
Token *string `json:"token,omitempty"`
Password string `json:"password"`
ConfirmPassword string `json:"confirm_password"`
OTP *string `json:"otp,omitempty"`
PhoneNumber *string `json:"phone_number,omitempty"`
}
// ResetPasswordInput is deprecated: Use ResetPasswordRequest instead
type ResetPasswordInput = ResetPasswordRequest
// ResetPassword is method attached to AuthorizerClient.
// It performs reset_password mutation on authorizer instance.
// It takes ResetPasswordRequest reference as parameter and returns Response reference or error.
func (c *AuthorizerClient) ResetPassword(req *ResetPasswordRequest) (*Response, error) {
var res Response
err := c.execute(methodSpec{
name: "ResetPassword",
graphql: &GraphQLRequest{
Query: `mutation resetPassword($data: ResetPasswordRequest!) { reset_password(params: $data) { message } }`,
Variables: map[string]interface{}{"data": req},
},
graphqlField: "reset_password",
restMethod: http.MethodPost,
restPath: "/v1/reset_password",
restBody: req,
restResp: func() proto.Message { return &authorizerv1.ResetPasswordResponse{} },
grpcCall: func(ctx context.Context, cli authorizerv1.AuthorizerServiceClient) (interface{}, error) {
var in authorizerv1.ResetPasswordRequest
if err := remarshal(req, &in); err != nil {
return nil, err
}
return cli.ResetPassword(ctx, &in)
},
}, nil, &res)
if err != nil {
return nil, err
}
return &res, nil
}