Skip to content

Commit

Permalink
Add user getter
Browse files Browse the repository at this point in the history
  • Loading branch information
TimMikeladze committed Jan 13, 2017
1 parent 6261ad6 commit 4fe8cc7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
8 changes: 7 additions & 1 deletion src/client/AccountsClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import type {
CreateUserType,
PasswordLoginUserType,
LoginReturnType,
UserObjectType,
} from '../common/types';

const isValidUserObject = (user: PasswordLoginUserType) => has(user, 'user') || has(user, 'email') || has(user, 'id');
Expand Down Expand Up @@ -51,7 +52,9 @@ export class AccountsClient {
getState(): Map<string, any> {
return this.store.getState().get('accounts');
}

user(): UserObjectType {
return this.getState().get('user').toJS();
}
async createUser(user: CreateUserType, callback: ?Function): Promise<void> {
if (!user || user.password === undefined) {
throw new AccountsError({ message: 'Unrecognized options for create user request [400]' });
Expand Down Expand Up @@ -124,6 +127,9 @@ const Accounts = {
...options,
}, transport);
},
user(): UserObjectType {
return this.instance.user();
},
options(): Object {
return this.instance.options;
},
Expand Down
4 changes: 2 additions & 2 deletions src/client/module.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import { Map } from 'immutable';
const PATH = 'js-accounts/';
const LOGIN = `${PATH}LOGIN`;
const SET_USER = `${PATH}SET_USER`;
const LOGGING_IN = `${PATH}/LOGGING_IN`;
const LOGGING_IN = `${PATH}LOGGING_IN`;

const initialState = Map({
isLoading: false,
user: null,
user: Map(),
loggingIn: false,
});

Expand Down

0 comments on commit 4fe8cc7

Please sign in to comment.