Skip to content

Commit

Permalink
Remove ambiguous letters from the sample of letters for code generation
Browse files Browse the repository at this point in the history
  • Loading branch information
sinaeftekhar committed Sep 25, 2023
1 parent 2cdbd0a commit ad5cced
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions app/models/decidim/helsinki_smsauth/signin_code.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,16 @@ def generate!
private

def generated_code(code_length = 10)
characters = ("0".."9").to_a + ("A".."Z").to_a
characters.sample(code_length).join
clear_sample.sample(code_length).join
end

def clear_sample
sample = ("0".."9").to_a + ("A".."Z").to_a
sample - ambiguous_chars
end

def ambiguous_chars
%w(0 O I 1)
end

def increment_used_codes
Expand Down

0 comments on commit ad5cced

Please sign in to comment.