Created
October 22, 2019 16:04
-
-
Save excid3/ce5d866045f8ff9b12dd0edf1cd082ca to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class User | |
def github_student_url | |
# The School ID GitHub gave you | |
school_id = "your-school-id" | |
# The secret key GitHub gave you | |
secret_key = "secret-key" | |
# The ID of the student in your database | |
student_id = id.to_s | |
# Generate the signature | |
signature = OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new('sha256'), secret_key, school_id + student_id) | |
"https://education.github.com/student/verify?school_id=#{school_id}&student_id=#{student_id}&signature=#{signature}" | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%= link_to "GitHub Student", @user.github_student_url %> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment