Skip to content

Commit

Permalink
Update test007 pasword use migration
Browse files Browse the repository at this point in the history
  • Loading branch information
zw963 committed May 25, 2024
1 parent 1a9d7ee commit a14c063
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
10 changes: 10 additions & 0 deletions db/migrations/20240525130632_change_test007_password_for_user.cr
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
class ChangeTest007PasswordForUser::V20240525130632 < Avram::Migrator::Migration::V1
def migrate
user = UserQuery.new.email("[email protected]").first
SaveUser.update!(user, password: "1234567")
end

def rollback
# drop table_for(Thing)
end
end
2 changes: 1 addition & 1 deletion shard.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ shards:

avram: # Overridden
git: https://github.com/luckyframework/avram.git
version: 1.2.0+git.commit.1326a8ea7583b91169993194802bb0875172a9c3
version: 1.2.0+git.commit.af42b9449a8cccb21632dac3a239d5849428ff9f

backtracer:
git: https://github.com/sija/backtracer.cr.git
Expand Down
13 changes: 13 additions & 0 deletions src/operations/save_user.cr
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
class SaveUser < User::SaveOperation
upsert_lookup_columns email
attribute password : String

before_save do
password.value.try do |password_value|
encrypted_password.value = Crypto::Bcrypt::Password.create(
password_value,
cost: Authentic.settings.encryption_cost
).to_s
end
end
end

0 comments on commit a14c063

Please sign in to comment.