-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
113 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { Auth } from '@aws-amplify/auth'; | ||
|
||
export interface UseConfirmSignupCodeProps { | ||
onSuccess?: (values: any) => Promise<void>; | ||
successMsg?: string; | ||
} | ||
|
||
interface ConfirmCodeProps { | ||
username: string; | ||
code: string; | ||
} | ||
|
||
export const useConfirmSignupCode = ({ onSuccess, successMsg }: UseConfirmSignupCodeProps = {}): (( | ||
values: ConfirmCodeProps, | ||
) => Promise<string | undefined>) => async ({ username, code }) => { | ||
return Auth.confirmSignUp(username.trim().toLowerCase(), code).then(async (response) => { | ||
onSuccess && (await onSuccess(response)); | ||
return successMsg; | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,22 @@ | ||
import { Auth } from '@aws-amplify/auth'; | ||
|
||
export interface UseLoginProps { | ||
onLogin?: (values: any) => Promise<void>; | ||
onSuccessLoginMsg?: string; | ||
onSuccess?: (values: any) => Promise<void>; | ||
successMsg?: string; | ||
} | ||
|
||
export interface LoginProps { | ||
email: string; | ||
password: string; | ||
} | ||
|
||
export const useLogin = ( | ||
options?: UseLoginProps, | ||
): ((values: LoginProps) => Promise<string | undefined>) => async ({ email, password }) => | ||
export const useLogin = ({ onSuccess, successMsg }: UseLoginProps = {}): (( | ||
values: LoginProps, | ||
) => Promise<string | undefined>) => async ({ email, password }) => | ||
Auth.signIn({ | ||
username: email.trim().toLowerCase(), | ||
password, | ||
}).then(async (user) => { | ||
options?.onLogin && (await options.onLogin(user)); | ||
return options?.onSuccessLoginMsg; | ||
}).then(async (response) => { | ||
onSuccess && (await onSuccess(response)); | ||
return successMsg; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import { Auth } from '@aws-amplify/auth'; | ||
|
||
export const useRequestConfirmationCode = () => async (email: string) => Auth.resendSignUp(email); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { Auth } from '@aws-amplify/auth'; | ||
|
||
export interface UseSendResentPasswordProps { | ||
onSuccess?: (values: any) => Promise<void>; | ||
successMsg?: string; | ||
} | ||
|
||
export interface SendResetPasswordProps { | ||
username: string; | ||
} | ||
|
||
export const useRequestResetCode = ({ onSuccess, successMsg }: UseSendResentPasswordProps = {}): (( | ||
values: SendResetPasswordProps, | ||
) => Promise<string | undefined>) => async ({ username }) => { | ||
return Auth.forgotPassword(username.trim().toLowerCase()).then(async () => { | ||
onSuccess && (await onSuccess({})); | ||
return successMsg; | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { Auth } from '@aws-amplify/auth'; | ||
|
||
export interface SseSetNewPasswordProps { | ||
onSuccess?: (values: any) => Promise<void>; | ||
successMsg?: string; | ||
} | ||
|
||
interface NewPasswordProps { | ||
username: string; | ||
code: string; | ||
password: string; | ||
} | ||
|
||
export const useSetNewPassword = ({ onSuccess, successMsg }: SseSetNewPasswordProps = {}): (( | ||
values: NewPasswordProps, | ||
) => Promise<string | undefined>) => async ({ username, code, password }) => { | ||
return Auth.forgotPasswordSubmit(username.trim().toLowerCase(), code, password).then( | ||
async (response) => { | ||
onSuccess && (await onSuccess(response)); | ||
return successMsg; | ||
}, | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters