Skip to content

Generate verify account email token/key for testing verify-account request #285

Discussion options

You must be logged in to vote

Thanks for your contribution! I guess you too went for a mail-checking solution, sadly unavailable for me.

I did solve it tho, by replicating the rodauth implementation on simple aux method. It isn't pretty but it works for me.

def verify_account_token(unverified_account_email)
    unverified_account = Account.find_by(email: unverified_account_email)
    token = transform_key_to_verification_token(unverified_account.verification_key.key)
    "#{unverified_account.id}_#{token}"
  end

  def transform_key_to_verification_token(key)
    hmac = OpenSSL::HMAC.digest(OpenSSL::Digest.new('SHA256'),  <SECRET>)
    s = [hmac].pack('m')
    s.chomp!("=\n")
    s.tr!('+/', '-_')
    s
  end

Replies: 3 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@FelipeBodelon
Comment options

Answer selected by FelipeBodelon
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants