1.0.15 • Published 3 years ago

react-amplify-wrapper v1.0.15

Weekly downloads
16
License
ISC
Repository
-
Last release
3 years ago

react-amplify-wrapper

You must add an Amplify config to the project where you are are importing this package:

// TODO: put link to that here...

UN_email - username (email split at the @), handled at each instance by a .split('@')[0], // revisit if necessary, it was needed in BT

Sign Up

signUp()

AuthService.signUp

{SIGN_UP} => (
    action: {
        UN_email,
        password,
        email,
        firstName, 
        lastName
    }
).then(res => {CONFIRM_SIGN_UP, res}
).catch(err => {SIGN_IN_FAILED, err})

confirmSignUp()

AuthService.confirmSignUp

{CONFIRM_SIGN_UP} => (
    state: {
        UN_email,
    }, action: {
        confirmCode
    }
).then(res => {SIGN_UP_SUCCESSFUL, res}
).catch(err => {
    if (err == 'ExpiredCodeException') {RESEND_CONFIRMATION_CODE, err}
    else {SIGN_UP_FAILED, err}
})

resendConfirmationCode()

AuthService.resendConfirmationCode

{RESEND_CONFIRMATION_CODE} => (
    action: {
        UN_email,   
    }
).then(res => {CONFIRM_SIGN_UP, res}
).catch(err => {RESEND_CONFIRMATION_CODE_FAILED, err })

signUpSuccessfulSignIn()

AuthService.signUpSuccesfulSignIn

{SIGN_IN_SUCCESSFUL} => (
    state: {
        UN_email,
        password
    }
).catch(err => {SIGN_IN_FAILED})

Sign In

signIn()

AuthService.signIn

{SIGN_IN} => (
    { action: { email, password } } 
).try(res => {
    if (res == 'NEW_PASSWORD_REQUIRED') { NEW_PASSWORD_REQUIRED, res}
    else {SIGN_IN_SUCCESSFUL, res}
}
).catch(err => {
    if (err == 'UserNotConfirmedException') {CONFIRM_SIGN_UP, err}
    else {SIGN_IN_FAILED, err}
} )

newPasswordRequired()

AuthService.newPasswordRequired

{NEW_PASSWORD_REQUIRED} => (
    { state: { user }; action: { password }}
).then(res => {SIGN_IN_SUCCESSFUL, res}
).catch(err => {NEW_PASSWORD_REQUIRED_FAILED, err})

Sign Out

signOut()

AuthService.signOut

{SIGN_OUT} => (
).then(res => {SIGN_OUT_SUCCESSFUL, res}
).catch(err => {SIGN_OUT_FAILED, err}

Password

forgotPassword()

AuthService.forgotPassword

{FORGOT_PASSWORD} => (
    { action: email }
).then(res => FORGOT_PASSWORD_SENT, res
).catch(err => FORGOT_PASSWORD_FAILED, err)

forgotPasswordSubmit()

AuthService.forgotPasswordSubmit

{FORGOT_PASSWORD_SUBMIT} => (
    { state: { email }, action: { code, newPassword } }
).then(res => {
    {SIGN_IN, email, newPassword}
    {FORGOT_PASSWORD_SENT, res}
}).catch(err => FORGOT_PASSWORD_FAILED, err)

changePassword()

AuthService.changePassword

{CHANGE_PASSWORD} => (
    { action: { oldPassword, newPassword }}
).then(res => {CHANGE_PASSWORD_SUCCESSFUL, res}
).catch(err => {CHANGE_PASSWORD_FAILED, err})

Change Attributes

changeAttributes()

AuthService.changeAttributes

{CHANGE_ATTRIBUTES} => (
    { state: { userId }, action: { name, email }}
).then(res => {CHANGE_ATTRIBUTES_SUCCESSFUL, res}
).then(err => {CHANGE_ATTRIBUTES_ERROR, err})