projects
/
arvados.git
/ blobdiff
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch 'master'
[arvados.git]
/
src
/
store
/
auth
/
auth-reducer.ts
diff --git
a/src/store/auth/auth-reducer.ts
b/src/store/auth/auth-reducer.ts
index c5a485648f40e49029aead8bbfc23222eb7718d2..f6974fd2073be49a5c01fe6677bff22edbc4ae8d 100644
(file)
--- a/
src/store/auth/auth-reducer.ts
+++ b/
src/store/auth/auth-reducer.ts
@@
-2,15
+2,15
@@
//
// SPDX-License-Identifier: AGPL-3.0
//
// SPDX-License-Identifier: AGPL-3.0
-import actions, { AuthAction
, UserDetailsResponse
} from "./auth-action";
+import actions, { AuthAction } from "./auth-action";
import { User } from "../../models/user";
import { authService } from "../../services/services";
import { User } from "../../models/user";
import { authService } from "../../services/services";
-import { removeServerApiAuthorizationHeader, setServerApiAuthorizationHeader } from "../../common/server-api";
+import { removeServerApiAuthorizationHeader, setServerApiAuthorizationHeader } from "../../common/
api/
server-api";
export interface AuthState {
user?: User;
apiToken?: string;
export interface AuthState {
user?: User;
apiToken?: string;
-}
;
+}
const authReducer = (state: AuthState = {}, action: AuthAction) => {
return actions.match(action, {
const authReducer = (state: AuthState = {}, action: AuthAction) => {
return actions.match(action, {
@@
-22,6
+22,9
@@
const authReducer = (state: AuthState = {}, action: AuthAction) => {
INIT: () => {
const user = authService.getUser();
const token = authService.getApiToken();
INIT: () => {
const user = authService.getUser();
const token = authService.getApiToken();
+ if (token) {
+ setServerApiAuthorizationHeader(token);
+ }
return {user, apiToken: token};
},
LOGIN: () => {
return {user, apiToken: token};
},
LOGIN: () => {
@@
-35,12
+38,7
@@
const authReducer = (state: AuthState = {}, action: AuthAction) => {
authService.logout();
return {...state, apiToken: undefined};
},
authService.logout();
return {...state, apiToken: undefined};
},
- USER_DETAILS_SUCCESS: (ud: UserDetailsResponse) => {
- const user = {
- email: ud.email,
- firstName: ud.first_name,
- lastName: ud.last_name
- };
+ USER_DETAILS_SUCCESS: (user: User) => {
authService.saveUser(user);
return {...state, user};
},
authService.saveUser(user);
return {...state, user};
},