Merge pull request #15 from puck/fix-api-generation
PostgreSQL: Fix returning an API Key that was size + 1
This commit is contained in:
commit
94e937e35e
@ -3,7 +3,7 @@ module KeyUtilities
|
|||||||
# generates a database unique api key
|
# generates a database unique api key
|
||||||
def generate_api_key(size = 16)
|
def generate_api_key(size = 16)
|
||||||
alphanumerics = ('0'..'9').to_a + ('A'..'Z').to_a
|
alphanumerics = ('0'..'9').to_a + ('A'..'Z').to_a
|
||||||
k = (0..size).map {alphanumerics[Kernel.rand(36)]}.join
|
k = (0..(size - 1)).map {alphanumerics[Kernel.rand(36)]}.join
|
||||||
|
|
||||||
# if key exists in database, regenerate key
|
# if key exists in database, regenerate key
|
||||||
k = generate_api_key if ApiKey.find_by_api_key(k)
|
k = generate_api_key if ApiKey.find_by_api_key(k)
|
||||||
|
Loading…
Reference in New Issue
Block a user