@@ -1140,25 +1140,7 @@ func (r *httpRoutes) CreateAuth0Connector(ctx echo.Context) error {
11401140 r .logger .Error ("failed to create dex client" , zap .Error (err ))
11411141 return echo .NewHTTPError (http .StatusBadRequest , "failed to create dex client" )
11421142 }
1143- res , err := dexClient .CreateConnector (context .TODO (), dexreq )
1144- if err != nil {
1145- r .logger .Error ("failed to create dex connector" , zap .Error (err ))
1146- return echo .NewHTTPError (http .StatusBadRequest , "failed to create dex connector" )
1147- }
1148- if res .AlreadyExists {
1149- return echo .NewHTTPError (http .StatusBadRequest , "connector already exists" )
1150- }
1151- err = r .db .CreateConnector (& db.Connector {
1152- LastUpdate : time .Now (),
1153- ConnectorID : "auth0" ,
1154- ConnectorType : "oidc" ,
1155- ConnectorSubType : "auth0" ,
1156- })
1157- if err != nil {
1158- r .logger .Error ("failed to create connector" , zap .Error (err ))
1159- return echo .NewHTTPError (http .StatusBadRequest , "failed to create connector" )
1160- }
1161- publicUris := req .PublickURIS
1143+ publicUris := req .PublicURIS
11621144 publicClientResp , _ := dexClient .GetClient (context .TODO (), & dexApi.GetClientReq {
11631145 Id : "public-client" ,
11641146 })
@@ -1229,6 +1211,27 @@ func (r *httpRoutes) CreateAuth0Connector(ctx echo.Context) error {
12291211 }
12301212 }
12311213
1214+
1215+ res , err := dexClient .CreateConnector (context .TODO (), dexreq )
1216+ if err != nil {
1217+ r .logger .Error ("failed to create dex connector" , zap .Error (err ))
1218+ return echo .NewHTTPError (http .StatusBadRequest , "failed to create dex connector" )
1219+ }
1220+ if res .AlreadyExists {
1221+ return echo .NewHTTPError (http .StatusBadRequest , "connector already exists" )
1222+ }
1223+ err = r .db .CreateConnector (& db.Connector {
1224+ LastUpdate : time .Now (),
1225+ ConnectorID : "auth0" ,
1226+ ConnectorType : "oidc" ,
1227+ ConnectorSubType : "auth0" ,
1228+ })
1229+ if err != nil {
1230+ r .logger .Error ("failed to create connector" , zap .Error (err ))
1231+ return echo .NewHTTPError (http .StatusBadRequest , "failed to create connector" )
1232+ }
1233+
1234+
12321235 // restart dex pod on connector creation
12331236 err = utils .RestartDexPod ()
12341237 if err != nil {
0 commit comments