When using with_authentication I see validations errors raised as I build and save the model from params because the digest is empty. I'm guessing this is generated via custom assign of password method in superclass(es).
# Sample Kemal pseudocode
payload = {
username: env.params.body["username"].as(String),
email: env.params.body["email"].as(String),
password: env.params.body["password"].as(String),
password_confirmation: env.params.body["password_confirmation"].as(String),
}
user = User.build(payload)
user.save
# Validation errror raised => [\"Password can't be blank\"]
I have to manually assign the password + confirmation fields directly for this to work:
# Sample Kemal pseudocode
payload = {
username: env.params.body["username"].as(String),
email: env.params.body["email"].as(String),
}
user = User.build(payload)
user.password = env.params.body["password"].as(String)
user.password_confirmation = env.params.body["password_confirmation"].as(String)
user.save
# Record persisted successfully
Is this the intended behavior/style that should be used? Could accepting this form of record build+save be a feature request you would consider desirable for the project?
If there's a better or suggested approach (thinking ahead of password updating that I haven't worked on yet) I'd love to hear/read about them 🙂
When using
with_authentication
I see validations errors raised as I build and save the model from params because the digest is empty. I'm guessing this is generated via custom assign of password method in superclass(es).I have to manually assign the password + confirmation fields directly for this to work:
Is this the intended behavior/style that should be used? Could accepting this form of record build+save be a feature request you would consider desirable for the project?
If there's a better or suggested approach (thinking ahead of password updating that I haven't worked on yet) I'd love to hear/read about them 🙂