halogenandtoast/oath

What am I missing?

HuckyDucky opened this issue · 2 comments

I added the gem, followed the instructions, and my password is being saved as plain text in password_digest. Is there some special syntactic sugar I need to create a user with a password? There's no encryption or anything. I even used generator:

rails g monban:scaffold

Come to think of it, other than the validations, there's nothing in the User model telling it to do anything special with this gem. I'm going to read the code, but I thought with a a gem that added password_digest, it would be doing something with that field. Am I maybe supposed to use has_secure_password, and monban just helps with the controller helpers? It's possible I am missing the point of this gem.

OK, I got it. To create a user in my db/seeds.rb file, or in the console:

Monban.config.sign_up_service.new(email: "me@mydomain.com", password: "fancytpassword").perform

Yup, or if you haven't changed the service you can do

Monban::Services::SignUp.new(email: "foo@example.com", password: "password").perform

TECHNICALLY you could in your console do

import Monban::ControllerHelpers
sign_up(email: "foo@example.com", password: "password")

but there are some controller helper methods that won't work due to depending on the session.