Skip to content

Change parameter type in updateUser method #15

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 2, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -48,7 +48,7 @@ yarn add react-netlify-identity
- `logoutUser()`
- `requestPasswordRecovery(email: string)`
- `recoverAccount(token: string, remember?: boolean | undefined)`
- `updateUser(fields: Object)`
- `updateUser(fields: { data: object })`
- `getFreshJWT()`
- `authedFetch(endpoint: string, obj = {})` (a thin axios-like wrapper over `fetch` that has the user's JWT attached, for convenience pinging Netlify Functions with Netlify Identity)

6 changes: 3 additions & 3 deletions src/index.tsx
Original file line number Diff line number Diff line change
@@ -43,7 +43,7 @@ export type ReactNetlifyIdentityAPI = {
token: string,
remember?: boolean | undefined
) => Promise<User>;
updateUser: (fields: Object) => Promise<User | undefined>;
updateUser: (fields: { data: object }) => Promise<User | undefined>;
getFreshJWT: () => Promise<string>;
authedFetch: {
get: (endpoint: string, obj?: {}) => Promise<any>;
@@ -153,12 +153,12 @@ export function useNetlifyIdentity(
goTrueInstance.requestPasswordRecovery(email);
const recoverAccount = (token: string, remember?: boolean | undefined) =>
goTrueInstance.recover(token, remember);
const updateUser = (fields: Object) => {
const updateUser = (fields: { data: object }) => {
if (user == null) {
throw new Error('No current user found - are you logged in?');
} else {
return user!
.update(fields) // e.g. { email: "[email protected]", password: "password" }
.update(fields) // e.g. { data: { email: "[email protected]", password: "password" } }
.then(_setUser);
}
};