We start by defining our actions, as these will be important when defining the reducer function.
Let's define the actions now:
- First, we are going to need an action to allow a user to log in, by providing a username value and a password value:
{ type: 'LOGIN', username: 'Daniel Bugl', password: 'notsosecure' }
- Then, we are also going to need a REGISTER action, which, in our case, is going to be similar to the LOGIN action, because we did not implement any registration logic yet:
{ type: 'REGISTER', username: 'Daniel Bugl', password: 'notsosecure', passwordRepeat: 'notsosecure' }
- Finally, we are going to need a LOGOUT action, which is simply going to log out the currently logged-in user:
{ type: 'LOGOUT' }
Now, we have defined all the required user-related actions and we can move on to defining the reducer function.