Conversation
| return false unless backup_codes.present? | ||
|
|
||
| valid_code = backup_codes.find do |backup_code| | ||
| backup_code = BCrypt::Password.new(backup_code) if self.class.otp_backup_codes_encrypted |
There was a problem hiding this comment.
Metrics/LineLength: Line is too long. [98/80]
| self.plain_backup_codes = backup_codes | ||
|
|
||
| backup_codes = backup_codes.map do |code| | ||
| cost = ActiveModel::OneTimePassword.min_bcrypt_cost ? BCrypt::Engine::MIN_COST : BCrypt::Engine.cost |
There was a problem hiding this comment.
Metrics/LineLength: Line is too long. [112/80]
| self.otp_regenerate_secret if !otp_column | ||
| self.otp_regenerate_counter if otp_counter_based && !otp_counter | ||
| otp_regenerate_backup_codes if backup_codes_enabled? | ||
| self.otp_regenerate_backup_codes if backup_codes_enabled? |
There was a problem hiding this comment.
Style/RedundantSelf: Redundant self detected.
| self.otp_backup_codes_column_name = (options[:backup_codes_column_name] || OTP_DEFAULT_BACKUP_CODES_COLUMN_NAME).to_s | ||
| self.otp_backup_codes_count = options[:backup_codes_count] || OTP_DEFAULT_BACKUP_CODES_COUNT | ||
| self.otp_one_time_backup_codes = options[:one_time_backup_codes] || OTP_BACKUP_CODES_ENABLED_BY_DEFAULT | ||
| self.otp_backup_codes_encrypted = options.fetch(:backup_codes_encrypted, OTP_BACKUP_CODES_ENCRYPTED_BY_DEFAULT) |
There was a problem hiding this comment.
Metrics/LineLength: Line is too long. [119/80]
| @@ -1,5 +1,6 @@ | |||
| require "active_model" | |||
| require "active_support/core_ext/module/attribute_accessors" | |||
| require "bcrypt" | |||
There was a problem hiding this comment.
Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.
| attr_accessor :otp_secret_key, :otp_backup_codes, :email | ||
|
|
||
| has_one_time_password one_time_backup_codes: true | ||
| has_one_time_password one_time_backup_codes: true, backup_codes_encrypted: false |
There was a problem hiding this comment.
Metrics/LineLength: Line is too long. [82/80]
| @@ -0,0 +1,11 @@ | |||
| class UserWithEncryptedCodes | |||
There was a problem hiding this comment.
Style/FrozenStringLiteralComment: Missing magic comment # frozen_string_literal: true.
|
@gooroodev can you review this PR please? |
|
Hey @admsev , thanks for summoning me! Summary of Changes
Issues, Bugs, and Typos
General Review of Code Quality and Style
OverallThe pull request introduces a valuable feature by adding encryption for backup codes using BCrypt. The implementation is clean, and the tests ensure that the feature works as expected. The minor issues identified can be easily fixed to improve the robustness of the code. Yours, Gooroo.dev |
No description provided.