Rails 6 API Tutorial - Using has_secure_password for Authentication p.22

preview_player
Показать описание
In this video series we will build a Rails API from scratch. Backend APIs are useful for serving data to frontend applications, mobile apps or other backend services.

This video covers:
00:00 - Introduction
00:38 - Adding a new password field
01:32 - Using has_secure_password
01:52 - Using bcrypt for the hashing algorithm
02:58 - Adding a password_digest field
03:54 - Adding has_secure_password to the User model
04:23 - Testing user passwords in the rails console
05:15 - Updating authentication specs with the new password field
06:50 - Adding a new test case for when password is invalid
08:50 - Adding logic to check the user's password, to the authentication controller
10:22 - Adding an AuthenticationError class
11:25 - Rescuing AuthenticationError with rescue_from and returning a 401 (unauthorized) status code
12:56 - Tidying up the controller
14:24 - Testing with cURL
16:35 - Some thoughts on other Rails authentication frameworks

Рекомендации по теме
Комментарии
Автор

Another great video. Three thumbs up for TDD through it.

Amplifity
Автор

Your tutorials are amazing, I have learned a whole lot from them, the TDD makes it even clearer. You're the best

acushlakoncepts
Автор

Thanks man, this series helped me a lot ❤

ahmedmustafa
Автор

This tutorial is so great. I will definitely post it on my LinkedIn.

Олексій-Куц
Автор

Very nice, but I dare say that rails does not decode the hash, but encode the input password with a hash function and compare it with the hash in the database. Hash functions are designed in such a way that there is a very small chance that the encoded hashes will match. (Sorry for my bad English)

cssex
Автор

Great series! You should do Udemy courses. BTW how do you recommend to invalidate tokens? A blocklist?

darkpill
Автор

Great video and series. But I think if the user is nil, the app will crash 500. You need the &. after user in "raise AuthenticationError unless

coop
Автор

JWT Token is random each time, how can there by an equality test?

ryanb