Skip to content

Commit 955b588

Browse files
committed
feat: add ConvertUserLoginType func to codersdk
1 parent 0b5f27f commit 955b588

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

codersdk/users.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -679,6 +679,26 @@ func (c *Client) ConvertLoginType(ctx context.Context, req ConvertLoginRequest)
679679
return resp, nil
680680
}
681681

682+
// ConvertUserLoginType will send a request to convert the user from password
683+
// based authentication to oauth based. The response has the oauth state code
684+
// to use in the oauth flow.
685+
func (c *Client) ConvertUserLoginType(ctx context.Context, user string, req ConvertLoginRequest) (OAuthConversionResponse, error) {
686+
res, err := c.Request(ctx, http.MethodPost, fmt.Sprintf("/api/v2/users/%s/convert-login", user), req)
687+
if err != nil {
688+
return OAuthConversionResponse{}, err
689+
}
690+
defer res.Body.Close()
691+
if res.StatusCode != http.StatusCreated {
692+
return OAuthConversionResponse{}, ReadBodyAsError(res)
693+
}
694+
var resp OAuthConversionResponse
695+
err = json.NewDecoder(res.Body).Decode(&resp)
696+
if err != nil {
697+
return OAuthConversionResponse{}, err
698+
}
699+
return resp, nil
700+
}
701+
682702
// Logout calls the /logout API
683703
// Call `ClearSessionToken()` to clear the session token of the client.
684704
func (c *Client) Logout(ctx context.Context) error {

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy