File tree Expand file tree Collapse file tree 1 file changed +2
-2
lines changed
Expand file tree Collapse file tree 1 file changed +2
-2
lines changed Original file line number Diff line number Diff line change @@ -4,13 +4,13 @@ defmodule NervesHub.Support.Utils do
44 alias NervesHub.Accounts.UserToken
55 alias NervesHub.Repo
66 alias NervesHub.Utils.Base62
7- alias Plug.Crypto.KeyGenerator
7+ alias Plug.Crypto.KeyGenerator , as: CryptoKeyGenerator
88
99 def create_v1_user_token! ( user ) do
1010 secret =
1111 << user . name :: binary , user . email :: binary , DateTime . to_unix ( DateTime . utc_now ( ) ) :: 32 >>
1212
13- << initial :: 160 >> = KeyGenerator . generate ( secret , "user-#{ user . id } " , length: 20 )
13+ << initial :: 160 >> = CryptoKeyGenerator . generate ( secret , "user-#{ user . id } " , length: 20 )
1414 << rand :: 30 - bytes , _ :: binary >> = Base62 . encode ( initial ) |> String . pad_leading ( 30 , "0" )
1515 crc = :erlang . crc32 ( rand ) |> Base62 . encode ( ) |> String . pad_leading ( 6 , "0" )
1616 token = "nhu_#{ rand } #{ crc } "
You can’t perform that action at this time.
0 commit comments