Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
def to_token_string
key.chars.zip(@secret.chars).join
end
def self.from_token_string(token_string)
begin
key, secret = token_string.chars.each_slice(2).to_a.transpose.map(&:join)
candidate = self.where(key: key).first
rescue
return nil
end
return nil unless candidate && (candidate.secret == secret)
return candidate
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment