File tree Expand file tree Collapse file tree 4 files changed +43
-2
lines changed Expand file tree Collapse file tree 4 files changed +43
-2
lines changed Original file line number Diff line number Diff line change @@ -100,6 +100,8 @@ export const createNewClient = () => Function;
100
100
declare module "./client/base" {
101
101
interface BaseAPI {
102
102
getAxios ( ) : AxiosInstance ;
103
+ getConfiguration ( ) : Configuration | undefined ;
104
+ setConfiguration ( configuration : Configuration ) : void ;
103
105
}
104
106
}
105
107
@@ -108,8 +110,39 @@ BaseAPI.prototype.getAxios = function getAxios(this: BaseAPI): AxiosInstance {
108
110
return this . axios ;
109
111
} ;
110
112
113
+ /** Returns the configuration */
114
+ BaseAPI . prototype . getConfiguration = function getConfiguration ( this : BaseAPI ) : Configuration | undefined {
115
+ return this . configuration ;
116
+ } ;
117
+
118
+ /** Sets the configuration */
119
+ BaseAPI . prototype . setConfiguration = function setConfiguration ( this : BaseAPI , configuration : Configuration ) : void {
120
+ this . configuration = configuration ;
121
+ } ;
122
+
123
+ // Reloads the configuration for all APIs
124
+ const reloadConfiguration = ( ) => {
125
+ [
126
+ sessionsApi ,
127
+ devicesApi ,
128
+ containersApi ,
129
+ systemApi ,
130
+ namespacesApi ,
131
+ apiKeysApi ,
132
+ sshApi ,
133
+ tagsApi ,
134
+ usersApi ,
135
+ mfaApi ,
136
+ billingApi ,
137
+ rulesApi ,
138
+ ] . forEach ( ( api ) => {
139
+ api . setConfiguration ( configuration ) ;
140
+ } ) ;
141
+ } ;
142
+
111
143
export {
112
144
configuration ,
145
+ reloadConfiguration ,
113
146
sessionsApi ,
114
147
devicesApi ,
115
148
containersApi ,
Original file line number Diff line number Diff line change @@ -5,6 +5,10 @@ import * as apiAuth from "../api/auth";
5
5
import * as apiNamespace from "../api/namespaces" ;
6
6
import { IUserLogin } from "@/interfaces/IUserLogin" ;
7
7
import { State } from ".." ;
8
+ import {
9
+ configuration as apiConfiguration ,
10
+ reloadConfiguration as reloadApiConfiguration ,
11
+ } from "@/api/http" ;
8
12
9
13
const { reset, toggle } = useChatWoot ( ) ;
10
14
export interface AuthState {
@@ -211,7 +215,8 @@ export const auth: Module<AuthState, State> = {
211
215
async loginToken ( context , token ) {
212
216
context . commit ( "authRequest" ) ;
213
217
214
- localStorage . setItem ( "token" , token ) ;
218
+ apiConfiguration . accessToken = token ;
219
+ reloadApiConfiguration ( ) ;
215
220
216
221
try {
217
222
const resp = await apiAuth . info ( ) ;
Original file line number Diff line number Diff line change 1
- import { configuration } from "@/api/http" ;
1
+ import { configuration , reloadConfiguration } from "@/api/http" ;
2
2
3
3
const apiPlugin = ( store ) => {
4
4
store . subscribe ( ( mutation , state ) => {
5
5
if ( mutation . type === "auth/authSuccess" ) {
6
6
configuration . accessToken = state . auth . token ;
7
+ reloadConfiguration ( ) ;
7
8
}
8
9
} ) ;
9
10
} ;
Original file line number Diff line number Diff line change @@ -193,6 +193,8 @@ onMounted(async () => {
193
193
await store .dispatch (" namespaces/clearNamespaceList" );
194
194
await store .dispatch (" auth/logout" );
195
195
await store .dispatch (" auth/loginToken" , route .query .token );
196
+
197
+ window .location .href = " /" ;
196
198
});
197
199
198
200
const login = async () => {
You can’t perform that action at this time.
0 commit comments