Skip to content

fix: avoid processing updates to usernames #3571

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 18, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
set correct login type for OIDC
  • Loading branch information
sreya committed Aug 18, 2022
commit e09966d2e81e61b62dfbf7b2849399db969f6d6b
8 changes: 4 additions & 4 deletions coderd/userauth.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,8 @@ func (api *API) userOAuth2Github(rw http.ResponseWriter, r *http.Request) {
if link.LinkedID == "" {
link, err = api.Database.UpdateUserLinkedID(ctx, database.UpdateUserLinkedIDParams{
UserID: user.ID,
LinkedID: githubLinkedID(ghUser),
LoginType: database.LoginTypeGithub,
LinkedID: githubLinkedID(ghUser),
})
if err != nil {
httpapi.Write(rw, http.StatusInternalServerError, codersdk.Response{
Expand Down Expand Up @@ -437,8 +437,8 @@ func (api *API) userOIDC(rw http.ResponseWriter, r *http.Request) {
if link.LinkedID == "" {
link, err = api.Database.UpdateUserLinkedID(ctx, database.UpdateUserLinkedIDParams{
UserID: user.ID,
LoginType: database.LoginTypeOIDC,
LinkedID: oidcLinkedID(idToken),
LoginType: database.LoginTypeGithub,
})
if err != nil {
httpapi.Write(rw, http.StatusInternalServerError, codersdk.Response{
Expand Down Expand Up @@ -477,8 +477,8 @@ func (api *API) userOIDC(rw http.ResponseWriter, r *http.Request) {
// longer sign in until an administrator finds the offending built-in
// user and changes their username.
user, err = api.Database.UpdateUserProfile(ctx, database.UpdateUserProfileParams{
ID: user.ID,
Email: claims.Email,
ID: user.ID,
Email: claims.Email,
// TODO: This should run in a transaction.
Username: user.Username,
UpdatedAt: database.Now(),
Expand Down