File tree Expand file tree Collapse file tree 2 files changed +19
-13
lines changed
src/integrations/api/instance/auth Expand file tree Collapse file tree 2 files changed +19
-13
lines changed Original file line number Diff line number Diff line change @@ -24,6 +24,15 @@ export async function onInstanceLoginSubmit({
2424 instanceClient,
2525 entityId,
2626} : InstanceLoginCredentials ) : Promise < LoginInfoResponse > {
27+ const auth = {
28+ username,
29+ password,
30+ } ;
31+ if ( authStore . checkForBasicAuth ( entityId ) ) {
32+ instanceClient . defaults . auth = auth ;
33+ instanceClient . defaults . withCredentials = false ;
34+ }
35+
2736 const { data : { message } } = await instanceClient . post ( '/' , {
2837 operation : 'login' ,
2938 username,
@@ -44,23 +53,20 @@ export async function onInstanceLoginSubmit({
4453 }
4554
4655 try {
47- const auth = {
48- username,
49- password,
50- } ;
51- delete instanceClient . defaults . auth ;
56+ instanceClient . defaults . auth = auth ;
57+ instanceClient . defaults . withCredentials = false ;
5258 const user = await getInstanceUserInfo ( {
5359 instanceClient,
5460 auth,
5561 } ) ;
56- instanceClient . defaults . auth = auth ;
57- instanceClient . defaults . withCredentials = false ;
5862 authStore . flagForBasicAuth ( entityId , auth ) ;
5963 return {
6064 message,
6165 user,
6266 } ;
6367 } catch ( err ) {
68+ instanceClient . defaults . auth = undefined ;
69+ instanceClient . defaults . withCredentials = true ;
6470 if ( isLocalStudio ) {
6571 throw err ;
6672 }
Original file line number Diff line number Diff line change @@ -56,18 +56,18 @@ async function onInstanceResetPassword({
5656 active : true ,
5757 instanceClient,
5858 } ) ;
59- // since we created a new user, we should clean up the old one
60- await onDeleteUser ( {
61- username : defaultClusterUsername ,
62- instanceClient,
63- } ) ;
64- /// and login with the new one.
59+ // since we created a new user, we should log in with the new one
6560 await onInstanceLoginSubmit ( {
6661 username : desiredUsername ,
6762 password : newPassword ,
6863 instanceClient,
6964 entityId : clusterId ,
7065 } ) ;
66+ // clean up the old one
67+ await onDeleteUser ( {
68+ username : defaultClusterUsername ,
69+ instanceClient,
70+ } ) ;
7171 }
7272 // and finally, tell the central manager that we changed their password.
7373 await resetPasswordUpdater ( clusterId ) ;
You can’t perform that action at this time.
0 commit comments