简体   繁体   中英

How can I pass username and password from input value securely to redux store/reducer in reactjs?

I want to know what the best practice is when doing this. I want to take the username and password inputted and pass it to my reducer which will send api request to aws cognito to verify credentials.

Can I just pass the dispatch the action with the user and pass values to my reducer?

You can definitely pass the username and password as params to an action that does the call to AWS Cognito (which it sounds like you're planning on doing), but just don't store the password in a reducer as state. Store the credentials returned if successful in the reducer state.

If you're using something like redux-persist to persist the tokens in state, it's definitely another reason not to store the password.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM