Afrikaans
Akan
Albanian
Amharic
Arabic
Armenian
Azerbaijani
Basque
Belarusian
Bemba
Bengali
Bihari
Bosnian
Breton
Bulgarian
Cambodian
Catalan
Cebuano
Cherokee
Chichewa
Chinese (Simplified)
Chinese (Traditional)
Corsican
Croatian
Czech
Danish
Dutch
Esperanto
Estonian
Ewe
Faroese
Filipino
Finnish
French
Frisian
Ga
Galician
Georgian
German
Greek
Guarani
Gujarati
Haitian Creole
Hausa
Hawaiian
Hebrew
Hindi
Hmong
Hungarian
Icelandic
Igbo
Indonesian
Interlingua
Irish
Italian
Japanese
Javanese
Kannada
Kazakh
Kinyarwanda
Kirundi
Kongo
Korean
Krio (Sierra Leone)
Kurdish
Kurdish (Soranรฎ)
Kyrgyz
Laothian
Latin
Latvian
Lingala
Lithuanian
Lozi
Luganda
Luo
Luxembourgish
Macedonian
Malagasy
Malay
Malayalam
Maltese
Maori
Marathi
Mauritian Creole
Moldavian
Mongolian
Myanmar (Burmese)
Montenegrin
Nepali
Nigerian Pidgin
Northern Sotho
Norwegian
Norwegian (Nynorsk)
Occitan
Oriya
Oromo
Pashto
Polish
Portuguese (Brazil)
Portuguese (Portugal)
Punjabi
Quechua
Romanian
Romansh
Runyakitara
Russian
Samoan
Scots Gaelic
Serbian
Serbo-Croatian
Sesotho
Setswana
Seychellois Creole
Shona
Sindhi
Sinhalese
Slovak
Slovenian
Somali
Spanish
Spanish (Latin American)
Sundanese
Swahili
Swedish
Tajik
Tamil
Tatar
Telugu
Thai
Tigrinya
Tonga
Tshiluba
Tumbuka
Turkish
Turkmen
Twi
Uighur
Ukrainian
Urdu
Uzbek
Vietnamese
Welsh
Wolof
Xhosa
Yiddish
Yoruba
Zulu
Now that we saw how we can send a request
with help of the token to a protected resource,
let's come back to the front end
and let's work on the feedback we provide to the user here.
For example, I wanna redirect after we changed the password.
I also want to redirect after we logged in.
And I then also wanna make the log out button
work and so on.
But we'll get there step-by-step.
Let's work on the log in redirection.
In the AuthForm component, I basically wanna redirect here
in this case, that we do have a token
and we do log the user in, in our context API.
Now redirecting is rather straight forward in the end.
I'm using react router here
and we can redirect then in this case by importing
something from react router dom.
And that something which we import here
is the used history hook.
With this hook, we can create a history object
by calling use history.
And we can then use this history object,
here, to call replace,
which redirects the user to a different page
and replace simply means that the user
can't use the back button thereafter to go back
to the previous page.
And here we could redirect the user to the starting page
with just slash for example.
If I do that, you should see that if I now do log in again
with that user, with that new password,
I'm redirected once that succeeded.
So that's rather straightforward.
Now, I also want to redirect after we changed the password.
And of course that works in exactly the same way.
We can go to the profile form
and also import use history here
from react router dom.
And then also create this history object here
by calling use history.
And then once we know that we succeeded here,
we can call history, replace,
and then go somewhere else
for example, again, to the starting page.
Of course here you also don't have
to redirect the user.
It would be fine to stay on this page
and present some success message with you as state
you could manage some states which you then
use to outputs a message if you want to
but here I'll go for the redirect, but that's of course
totally up to you, whether you want to do that.
And if I quickly test this year
by going back to that original password which I used before,
that seems to work.
So that's all working.
Now let's work on the log out functionality.
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.