And once we have registered user of course we also would want to set up our log in functionality where
if the user has already registered.
Well now we would just like to sign in and the functionality is going to be very very similar.
And again we're going to start with using the log and user function that we imported.
And of course that is done if the member has already registered.
So let me uncommon this.
And then again we're going to pass in the object or in this case I'm looking for only email as well
as the password.
And again it's gonna be the same thing where if the IS members true then of course our response is gonna
be equal to a log in user.
OK.
Before that we use the register but our logic after that is not going to change if it is success.
We're gonna do something we can navigate away from page.
Currently we're just showing our user object but eventually of course we're going to do something.
If not if we're not able to log in well then we're just going to show some kind of alert.
All right.
Now let's save log in.
That is correct.
And now let's head over back to our strappy log in user so log in user again is empty and like I said
it's going to be very very similar to what we already had.
So you could technically copy paste.
But in my case I'm just going to rewrite this axioms from axioms.
Then we're also gonna have a URL import your URL so let's navigate to utilize then once we're new tools
we're gonna look for your URL then the function is gonna be of course a single.
So we're gonna go with a sync function then we're going to log in the user log in user again I'm gonna
pass in the object because I just don't like to deal with an order of my arguments password and then
within the function body.
Well first of all maybe export export default log in user log in user and then within a function body
again we're gonna have a response so concert response is equal to a weight.
So we're gonna wait till our promise is settled and then we're going to use x years post request and
then the URL in this case again is going to be a template string and we're gonna pass in our You are
all variable.
So let me grab first my variable your URL and then the path is off and then a local.
So instead of register we're just adding a local and then we're still passing in the data.
So there's going to be a data object with a property name is identifier like I mentioned in the last
video when working with strappy we have two options.
We could either use the email or we could use the user name.
Now in my case I set it up everything as email just for simplicity's sake but in general if you'd want
you can pass in either of these two values.
That's the reason why within the log and user in fact the property is not email where it's not a user
name.
The property is identifier if by her like so.
And then in case of course I'm going to set the C equal to email.
That's the reason why you could set this up to as a user name as well.
And then let's also add the password.
Now in this case of course I'm going I'm using iOS 6 thing where since the parameter values exactly
the same as my password.
Now that's the reason why can I have a shortcut.
And also I'm going to use catch.
So right away I'm going to change that catch and we're just going to console log there.
So let's look for a log.
Let's delete a semicolon and let's control log there and just like register user we're just gonna return
response whatever that response is either it's gonna be undefined or in fact is gonna be our object
now head over back to a log in J.
Yes.
And I guess let's start out.
I'm gonna we're gonna have either success with our user object or there's gonna be undefined and we're
gonna have an error and since our only user of course is John well I'm gonna try to log in as John so
that gmail dot com hopefully my password is gonna be correct.
So my simple password and success I have the success where I successfully logged in as John.
Now of course nothing happens on my front end.
We haven't attached that functionality to anything.
What we have right now but I can clearly see that I'm getting back a nice response where I have my data
and I have my token.
Now let's also try to do that by let's say forgetting our password.
So in this case I'm just going to type some kind of I don't know dummy password like so and then of
course I'm gonna get an error because I wasn't able to in fact log in.
So once we take a look at that then we can start working on setting up our user on the front end.
So now that we know that we can log in our user in the stripy as well as register user in a strappy
now of course we can start setting up our user where we're controlling of what we're displaying for
the user on our front end.