【Rails】10個のdeviseモジュールの概要 2022年6月8日
【Rails】deviseのモジュールについて Database Authenticatable : hashes and stores a password in the database to validate the authenticity of a user while signing in. The authentication can be done both through POST requests or HTTP Basic Authentication.データベースに保存されたパスワードにて、ユーザが本当に登録されているかを確認してくれます。 これを使わないなら、deviseを入れる意味があるのかな??と思います。それくらいスタンダード? Omniauthable : adds OmniAuth (https://github.com/omniauth/omniauth ) support.Twitterでログインとか、Facebookでログインとかありますが、そういったSNS認証を追加するモジュールです。 Confirmable : sends emails with confirmation instructions and verifies whether an account is already confirmed during sign in.新しくユーザを登録するときに、メール認証を使う場合のモジュールです。 メールアドレスで情報を通知するときなど、あらかじめ使えるメールアドレスかどうか確認したいときに使います。 Recoverable : resets the user password and sends reset instructions.パスワードをリセット機能を実装するときに使います。 Registerable : handles signing up users through a registration process, also allowing them to edit and destroy their account.ユーザの新規登録処理を行って、ユーザ登録する時に使います。 ユーザのCRUDなども、deviseで実装する場合は、こちらを使用します。 ※ユーザのCRUDは自前で実装するというときなどは、こちらは使用しません。 Rememberable : manages generating and clearing a token for remembering the user from a saved cookie.ブラウザのクッキーにユーザのログイン情報を保持するときに使用します。 Trackable : tracks sign in count, timestamps and IP address.ログイン回数、ログイン日時、ログインIPアドレスなどを保持するときに使用します。 Timeoutable : expires sessions that have not been active in a specified period of time.ログインしたまま、一定時間経つと自動でログアウトさせるときに使用します。 デフォルトは30分です。 Validatable : provides validations of email and password. It’s optional and can be customized, so you’re able to define your own validations.メールアドレスや、パスワードのバリデーションを追加してくれます。 もちろん独自のバリデーションも追加できます。 Lockable : locks an account after a specified number of failed sign-in attempts. Can unlock via email or after a specified time period.指定した回数ログインに失敗すると、アカウントをロックします。 回数は指定できます。