Merge pull request #2496 from mozilla/cover-set-current-user-2495
Remove setCurrentUser
This commit is contained in:
Коммит
e008ef1388
|
@ -4,6 +4,8 @@ This will outline what is required to add a page to the project. A basic knowled
|
|||
[react](https://facebook.github.io/react/docs/getting-started.html) and
|
||||
[redux](http://redux.js.org/) is assumed.
|
||||
|
||||
**Note:** This page is very out-of-date and does not reflect our practices anymore. We now use [redux-saga](https://github.com/redux-saga/redux-saga) for API requests. See `amo/components/Categories.js` for a more modern example of a component that makes API/async requests for data.
|
||||
|
||||
## Structure
|
||||
|
||||
A basic app structure will look like this:
|
||||
|
|
|
@ -4,7 +4,6 @@ import {
|
|||
LOG_OUT_USER,
|
||||
SET_AUTH_TOKEN,
|
||||
SET_CLIENT_APP,
|
||||
SET_CURRENT_USER,
|
||||
SET_LANG,
|
||||
SET_USER_AGENT,
|
||||
} from 'core/constants';
|
||||
|
@ -82,15 +81,3 @@ export function loadEntities(entities: Array<Object>): LoadEntitiesAction {
|
|||
payload: { entities },
|
||||
};
|
||||
}
|
||||
|
||||
export type SetCurrentUserAction = {|
|
||||
payload: {| username: string |},
|
||||
type: string,
|
||||
|};
|
||||
|
||||
export function setCurrentUser(username: string): SetCurrentUserAction {
|
||||
return {
|
||||
type: SET_CURRENT_USER,
|
||||
payload: { username },
|
||||
};
|
||||
}
|
||||
|
|
|
@ -105,7 +105,6 @@ export const SEARCH_LOADED = 'SEARCH_LOADED';
|
|||
export const SEARCH_STARTED = 'SEARCH_STARTED';
|
||||
export const SET_AUTH_TOKEN = 'SET_AUTH_TOKEN';
|
||||
export const SET_CLIENT_APP = 'SET_CLIENT_APP';
|
||||
export const SET_CURRENT_USER = 'SET_CURRENT_USER';
|
||||
export const SET_ERROR = 'SET_ERROR';
|
||||
export const SET_LANG = 'SET_LANG';
|
||||
export const SET_USER_AGENT = 'SET_USER_AGENT';
|
||||
|
|
|
@ -4,7 +4,6 @@ import log from 'core/logger';
|
|||
import {
|
||||
LOG_OUT_USER,
|
||||
SET_AUTH_TOKEN,
|
||||
SET_CURRENT_USER,
|
||||
} from 'core/constants';
|
||||
|
||||
function getUserIdFromAuthToken(token) {
|
||||
|
@ -37,8 +36,6 @@ export default function authentication(state = {}, action) {
|
|||
// because the server is responsible for that.
|
||||
userId: getUserIdFromAuthToken(payload.token),
|
||||
};
|
||||
case SET_CURRENT_USER:
|
||||
return { ...state, username: payload.username };
|
||||
case LOG_OUT_USER:
|
||||
return {};
|
||||
default:
|
||||
|
|
|
@ -14,17 +14,6 @@ describe('authentication reducer', () => {
|
|||
expect(auth(state, { type: 'UNRELATED' })).toBe(state);
|
||||
});
|
||||
|
||||
it('sets the user on SET_CURRENT_USER', () => {
|
||||
const username = 'my-username';
|
||||
expect(auth(undefined, { type: 'SET_CURRENT_USER', payload: { username } })).toEqual({ username });
|
||||
});
|
||||
|
||||
it('maintains the token when adding a username', () => {
|
||||
const username = 'name-of-user';
|
||||
const token = userAuthToken();
|
||||
expect(auth({ token }, { type: 'SET_CURRENT_USER', payload: { username } })).toEqual({ token, username });
|
||||
});
|
||||
|
||||
describe('set and reduce auth token', () => {
|
||||
const setAndReduceToken = (token) => auth(undefined, setAuthToken(token));
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче