Skip to content

Commit

Permalink
feat: add new method to gather token, fix typo
Browse files Browse the repository at this point in the history
  • Loading branch information
lewtakm committed Feb 19, 2021
1 parent 267fba6 commit 22bc471
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/hooks/useConfirmSignupCode.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Auth } from '@aws-amplify/auth';

export interface UseConfirmSignupCodeProps {
onSuccess?: (values: any) => Promise<void>;
onSuccess?: (...values: any[]) => Promise<void>;
successMsg?: string;
}

Expand Down
6 changes: 3 additions & 3 deletions src/hooks/useSetNewPassword.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import { Auth } from '@aws-amplify/auth';

export interface SeSetNewPasswordProps {
export interface SetNewPasswordProps {
onSuccess?: (values: any) => Promise<void>;
successMsg?: string;
}

interface NewPasswordProps {
export interface NewPasswordProps {
username: string;
code: string;
password: string;
}

export const useSetNewPassword = ({ onSuccess, successMsg }: SeSetNewPasswordProps = {}): ((
export const useSetNewPassword = ({ onSuccess, successMsg }: SetNewPasswordProps = {}): ((
values: NewPasswordProps,
) => Promise<string | undefined>) => async ({ username, code, password }) => {
return Auth.forgotPasswordSubmit(username.trim().toLowerCase(), code, password).then(
Expand Down
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export { useRequestConfirmationCode } from './hooks/useRequestConfirmationCode';
export { useConfirmSignupCode } from './hooks/useConfirmSignupCode';
export { useRequestResetCode } from './hooks/useRequestResetCode';
export { useSetNewPassword } from './hooks/useSetNewPassword';
export { getToken } from './providers/auth/getToken';
export { PageLoading } from './components/PageLoading/PageLoading';
export { Card } from './components/Card/Card';
export { Form } from './components/Form/Form';
Expand Down
7 changes: 7 additions & 0 deletions src/providers/auth/getToken.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { Auth } from '@aws-amplify/auth';

export const getToken = async () => {
const session = await Auth.currentSession();
const JwtToken = session.getIdToken().getJwtToken();
return JwtToken;
};

0 comments on commit 22bc471

Please sign in to comment.