Login workflow (#137)
* Use collection label instead of name on the CollectionPage * Added Avatar and logout menu item * [feat](login) Added userpic with a logout action in the dropdown. - Display logged in user in the AppHeader - Implemented logout action and store + tests - Better styles for GitHub sign in screen Closes #100 * Better styles for the AppHeader
This commit is contained in:
committed by
Cássio Souza
parent
1c4751f479
commit
4d696f2253
@ -1,6 +1,5 @@
|
||||
import expect from 'expect';
|
||||
import Immutable from 'immutable';
|
||||
import { authenticating, authenticate, authError } from '../../actions/auth';
|
||||
import { authenticating, authenticate, authError, logout } from '../../actions/auth';
|
||||
import auth from '../auth';
|
||||
|
||||
describe('auth', () => {
|
||||
@ -33,8 +32,14 @@ describe('auth', () => {
|
||||
auth(undefined, authError(new Error('Bad credentials')))
|
||||
).toEqual(
|
||||
Immutable.Map({
|
||||
error: 'Error: Bad credentials'
|
||||
error: 'Error: Bad credentials',
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
it('should handle logout', () => {
|
||||
const initialState = Immutable.fromJS({ user: { email: 'joe@example.com' } });
|
||||
const newState = auth(initialState, logout());
|
||||
expect(newState.get('user')).toBeUndefined();
|
||||
});
|
||||
});
|
||||
|
@ -1,5 +1,5 @@
|
||||
import Immutable from 'immutable';
|
||||
import { AUTH_REQUEST, AUTH_SUCCESS, AUTH_FAILURE } from '../actions/auth';
|
||||
import { AUTH_REQUEST, AUTH_SUCCESS, AUTH_FAILURE, LOGOUT } from '../actions/auth';
|
||||
|
||||
const auth = (state = null, action) => {
|
||||
switch (action.type) {
|
||||
@ -9,6 +9,8 @@ const auth = (state = null, action) => {
|
||||
return Immutable.fromJS({ user: action.payload });
|
||||
case AUTH_FAILURE:
|
||||
return Immutable.Map({ error: action.payload.toString() });
|
||||
case LOGOUT:
|
||||
return state.remove('user');
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
|
Reference in New Issue
Block a user