MCPcopy Index your code
hub / github.com/coder/coder / LoginWithPassword

Method LoginWithPassword

codersdk/users.go:899–914  ·  view source on GitHub ↗

LoginWithPassword creates a session token authenticating with an email and password. Call `SetSessionToken()` to apply the newly acquired token to the client.

(ctx context.Context, req LoginWithPasswordRequest)

Source from the content-addressed store, hash-verified

897// LoginWithPassword creates a session token authenticating with an email and password.
898// Call `SetSessionToken()` to apply the newly acquired token to the client.
899func (c *Client) LoginWithPassword(ctx context.Context, req LoginWithPasswordRequest) (LoginWithPasswordResponse, error) {
900 res, err := c.Request(ctx, http.MethodPost, "/api/v2/users/login", req)
901 if err != nil {
902 return LoginWithPasswordResponse{}, err
903 }
904 defer res.Body.Close()
905 if res.StatusCode != http.StatusCreated {
906 return LoginWithPasswordResponse{}, ReadBodyAsError(res)
907 }
908 var resp LoginWithPasswordResponse
909 err = json.NewDecoder(res.Body).Decode(&resp)
910 if err != nil {
911 return LoginWithPasswordResponse{}, err
912 }
913 return resp, nil
914}
915
916func (c *Client) RequestOneTimePasscode(ctx context.Context, req RequestOneTimePasscodeRequest) error {
917 res, err := c.Request(ctx, http.MethodPost, "/api/v2/users/otp/request", req)

Callers 15

TestServerFunction · 0.95
TestUserLoginFunction · 0.80
TestUserLogoutFunction · 0.80
TestUserForgotPasswordFunction · 0.80
TestPostLoginFunction · 0.80
TestUpdateUserPasswordFunction · 0.80
TestWorkspacesByUserFunction · 0.80
TestDormantUserFunction · 0.80
CreateFirstUserFunction · 0.80
createAnotherUserRetryFunction · 0.80
RunFunction · 0.80

Calls 3

RequestMethod · 0.95
ReadBodyAsErrorFunction · 0.85
CloseMethod · 0.65

Tested by 12

TestServerFunction · 0.76
TestUserLoginFunction · 0.64
TestUserLogoutFunction · 0.64
TestUserForgotPasswordFunction · 0.64
TestPostLoginFunction · 0.64
TestUpdateUserPasswordFunction · 0.64
TestWorkspacesByUserFunction · 0.64
TestDormantUserFunction · 0.64
TestLoginFunction · 0.64
TestResetPasswordFunction · 0.64
TestEnterpriseUserLoginFunction · 0.64