Skip to content

Commit 0ac9630

Browse files
committed
auth: fix HTTP methods
1 parent 3ea7eea commit 0ac9630

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

auth.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ type User struct {
4343
func (a *Auth) SignUp(ctx context.Context, credentials UserCredentials) (*User, error) {
4444
reqBody, _ := json.Marshal(credentials)
4545
reqURL := fmt.Sprintf("%s/%s/signup", a.client.BaseURL, AuthEndpoint)
46-
req, err := http.NewRequestWithContext(ctx, "POST", reqURL, bytes.NewBuffer(reqBody))
46+
req, err := http.NewRequestWithContext(ctx, http.MethodPost, reqURL, bytes.NewBuffer(reqBody))
4747
if err != nil {
4848
return nil, err
4949
}
@@ -73,7 +73,7 @@ type authenticationError struct {
7373
func (a *Auth) SignIn(ctx context.Context, credentials UserCredentials) (*AuthenticatedDetails, error) {
7474
reqBody, _ := json.Marshal(credentials)
7575
reqURL := fmt.Sprintf("%s/%s/token?grant_type=password", a.client.BaseURL, AuthEndpoint)
76-
req, err := http.NewRequestWithContext(ctx, "POST", reqURL, bytes.NewBuffer(reqBody))
76+
req, err := http.NewRequestWithContext(ctx, http.MethodPost, reqURL, bytes.NewBuffer(reqBody))
7777
if err != nil {
7878
return nil, err
7979
}
@@ -95,7 +95,7 @@ func (a *Auth) SignIn(ctx context.Context, credentials UserCredentials) (*Authen
9595
func (a *Auth) RefreshUser(ctx context.Context, userToken string, refreshToken string) (*AuthenticatedDetails, error) {
9696
reqBody, _ := json.Marshal(map[string]string{"refresh_token": refreshToken})
9797
reqURL := fmt.Sprintf("%s/%s/token?grant_type=refresh_token", a.client.BaseURL, AuthEndpoint)
98-
req, err := http.NewRequestWithContext(ctx, "POST", reqURL, bytes.NewBuffer(reqBody))
98+
req, err := http.NewRequestWithContext(ctx, http.MethodPost, reqURL, bytes.NewBuffer(reqBody))
9999
if err != nil {
100100
return nil, err
101101
}
@@ -118,7 +118,7 @@ func (a *Auth) RefreshUser(ctx context.Context, userToken string, refreshToken s
118118
func (a *Auth) SendMagicLink(ctx context.Context, email string) error {
119119
reqBody, _ := json.Marshal(map[string]string{"email": email})
120120
reqURL := fmt.Sprintf("%s/%s/magiclink", a.client.BaseURL, AuthEndpoint)
121-
req, err := http.NewRequestWithContext(ctx, "GET", reqURL, bytes.NewBuffer(reqBody))
121+
req, err := http.NewRequestWithContext(ctx, http.MethodPost, reqURL, bytes.NewBuffer(reqBody))
122122
if err != nil {
123123
return err
124124
}
@@ -162,7 +162,7 @@ func (a *Auth) SignInWithProvider(opts ProviderSignInOptions) (*ProviderSignInDe
162162
// User retrieves the user information based on the given token
163163
func (a *Auth) User(ctx context.Context, userToken string) (*User, error) {
164164
reqURL := fmt.Sprintf("%s/%s/user", a.client.BaseURL, AuthEndpoint)
165-
req, err := http.NewRequestWithContext(ctx, "GET", reqURL, nil)
165+
req, err := http.NewRequestWithContext(ctx, http.MethodGet, reqURL, nil)
166166
if err != nil {
167167
return nil, err
168168
}
@@ -185,7 +185,7 @@ func (a *Auth) User(ctx context.Context, userToken string) (*User, error) {
185185
func (a *Auth) UpdateUser(ctx context.Context, userToken string, updateData map[string]interface{}) (*User, error) {
186186
reqBody, _ := json.Marshal(updateData)
187187
reqURL := fmt.Sprintf("%s/%s/user", a.client.BaseURL, AuthEndpoint)
188-
req, err := http.NewRequestWithContext(ctx, "PUT", reqURL, bytes.NewBuffer(reqBody))
188+
req, err := http.NewRequestWithContext(ctx, http.MethodPut, reqURL, bytes.NewBuffer(reqBody))
189189
if err != nil {
190190
return nil, err
191191
}
@@ -209,7 +209,7 @@ func (a *Auth) UpdateUser(ctx context.Context, userToken string, updateData map[
209209
func (a *Auth) ResetPasswordForEmail(ctx context.Context, email string) error {
210210
reqBody, _ := json.Marshal(map[string]string{"email": email})
211211
reqURL := fmt.Sprintf("%s/%s/recover", a.client.BaseURL, AuthEndpoint)
212-
req, err := http.NewRequestWithContext(ctx, "POST", reqURL, bytes.NewBuffer(reqBody))
212+
req, err := http.NewRequestWithContext(ctx, http.MethodPost, reqURL, bytes.NewBuffer(reqBody))
213213
if err != nil {
214214
return err
215215
}
@@ -224,7 +224,7 @@ func (a *Auth) ResetPasswordForEmail(ctx context.Context, email string) error {
224224
// SignOut revokes the users token and session.
225225
func (a *Auth) SignOut(ctx context.Context, userToken string) error {
226226
reqURL := fmt.Sprintf("%s/%s/logout", a.client.BaseURL, AuthEndpoint)
227-
req, err := http.NewRequestWithContext(ctx, "GET", reqURL, nil)
227+
req, err := http.NewRequestWithContext(ctx, http.MethodPost, reqURL, nil)
228228
if err != nil {
229229
return err
230230
}
@@ -242,7 +242,7 @@ func (a *Auth) SignOut(ctx context.Context, userToken string) error {
242242
func (a *Auth) InviteUserByEmail(ctx context.Context, email string) (*User, error) {
243243
reqBody, _ := json.Marshal(map[string]string{"email": email})
244244
reqURL := fmt.Sprintf("%s/%s/invite", a.client.BaseURL, AuthEndpoint)
245-
req, err := http.NewRequestWithContext(ctx, "POST", reqURL, bytes.NewBuffer(reqBody))
245+
req, err := http.NewRequestWithContext(ctx, http.MethodPost, reqURL, bytes.NewBuffer(reqBody))
246246
if err != nil {
247247
return nil, err
248248
}

0 commit comments

Comments
 (0)