Skip to content

Commit d7ba6c0

Browse files
committed
fix IsGithubDotComURL check
1 parent d8d4b9b commit d7ba6c0

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

coderd/userauth.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1096,7 +1096,10 @@ func (api *API) userOAuth2Github(rw http.ResponseWriter, r *http.Request) {
10961096
}
10971097
// If the user is logging in with github.com we update their associated
10981098
// GitHub user ID to the new one.
1099-
if externalauth.IsGithubDotComURL(api.GithubOAuth2Config.AuthCodeURL("")) && user.GithubComUserID.Int64 != ghUser.GetID() {
1099+
// We use AuthCodeURL from the OAuth2Config field instead of the one on
1100+
// GithubOAuth2Config because when device flow is configured, AuthCodeURL
1101+
// is overridden and returns a value that doesn't pass the URL check.
1102+
if externalauth.IsGithubDotComURL(api.GithubOAuth2Config.OAuth2Config.AuthCodeURL("")) && user.GithubComUserID.Int64 != ghUser.GetID() {
11001103
err = api.Database.UpdateUserGithubComUserID(ctx, database.UpdateUserGithubComUserIDParams{
11011104
ID: user.ID,
11021105
GithubComUserID: sql.NullInt64{

0 commit comments

Comments
 (0)