Skip to content

Commit

Permalink
Merge pull request #19 from katafrakt/crystal-35
Browse files Browse the repository at this point in the history
Make it work in Crystal 0.35.1
  • Loading branch information
msa7 authored Sep 24, 2020
2 parents 88d6678 + f481620 commit bbd322b
Show file tree
Hide file tree
Showing 8 changed files with 67 additions and 56 deletions.
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
dist: xenial
language: crystal
crystal:
- latest
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: '3'

services:
app:
image: crystallang/crystal:0.29.0
image: crystallang/crystal:0.35.1
working_dir: /app
environment:
EDA_ENV: ${MULTI_AUTH_ENV}
Expand Down
2 changes: 1 addition & 1 deletion shard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version: 1.0.0
authors:
- Sergey Makridenkov <[email protected]>

crystal: 0.29.0
crystal: 0.35.1

license: MIT

Expand Down
23 changes: 12 additions & 11 deletions src/multi_auth/providers/facebook.cr
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,20 @@ class MultiAuth::Provider::Facebook < MultiAuth::Provider
end

private class FbUser
include JSON::Serializable

property raw_json : String?
property access_token : OAuth2::AccessToken?
property picture_url : String?

JSON.mapping(
id: String,
name: String,
last_name: String?,
first_name: String?,
email: String?,
location: String?,
about: String?,
website: String?
)
property id : String
property name : String
property last_name : String?
property first_name : String?
property email : String?
property location : String?
property about : String?
property website : String?
end

private def fetch_fb_user(code)
Expand Down Expand Up @@ -75,7 +75,8 @@ class MultiAuth::Provider::Facebook < MultiAuth::Provider
key,
secret,
redirect_uri: redirect_uri,
token_uri: "/v2.9/oauth/access_token"
token_uri: "/v2.9/oauth/access_token",
auth_scheme: :request_body
)
end
end
27 changes: 15 additions & 12 deletions src/multi_auth/providers/github.cr
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,22 @@ class MultiAuth::Provider::Github < MultiAuth::Provider
end

private class GhUser
include JSON::Serializable

property raw_json : String?
property access_token : OAuth2::AccessToken?

JSON.mapping(
id: {type: String, converter: String::RawConverter},
name: String,
email: String?,
login: String,
location: String?,
bio: String?,
avatar_url: String?,
blog: String?,
html_url: String?
)
@[JSON::Field(converter: String::RawConverter)]
property id : String

property name : String
property email : String?
property login : String
property location : String?
property bio : String?
property avatar_url : String?
property blog : String?
property html_url : String?
end

private def fetch_gh_user(code)
Expand All @@ -65,7 +67,8 @@ class MultiAuth::Provider::Github < MultiAuth::Provider
key,
secret,
authorize_uri: "/login/oauth/authorize",
token_uri: "/login/oauth/access_token"
token_uri: "/login/oauth/access_token",
auth_scheme: :request_body
)
end
end
3 changes: 2 additions & 1 deletion src/multi_auth/providers/google.cr
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ class MultiAuth::Provider::Google < MultiAuth::Provider
key,
secret,
token_uri: "/oauth2/v4/token",
redirect_uri: redirect_uri
redirect_uri: redirect_uri,
auth_scheme: :request_body
)

access_token = client.get_access_token_using_authorization_code(params["code"])
Expand Down
22 changes: 12 additions & 10 deletions src/multi_auth/providers/twitter.cr
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,21 @@ class MultiAuth::Provider::Twitter < MultiAuth::Provider
end

private class TwUser
include JSON::Serializable

property raw_json : String?
property access_token : OAuth::AccessToken?

JSON.mapping(
id: {type: String, converter: String::RawConverter},
name: String,
screen_name: String,
location: String?,
description: String?,
url: String?,
profile_image_url: String?,
email: String?
)
@[JSON::Field(converter: String::RawConverter)]
property id : String

property name : String
property screen_name : String
property location : String?
property description : String?
property url : String?
property profile_image_url : String?
property email : String?
end

private def fetch_tw_user(oauth_token, oauth_verifier)
Expand Down
41 changes: 21 additions & 20 deletions src/multi_auth/providers/vk.cr
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,13 @@ class MultiAuth::Provider::Vk < MultiAuth::Provider
end

class VkTitle
JSON.mapping(
title: String
)
include JSON::Serializable
property title : String
end

class VkUser
include JSON::Serializable

property raw_json : String?
property access_token : OAuth2::AccessToken?
property email : String?
Expand All @@ -51,25 +52,24 @@ class MultiAuth::Provider::Vk < MultiAuth::Provider
"#{last_name} #{first_name}"
end

JSON.mapping(
id: {type: String, converter: String::RawConverter},
last_name: String?,
first_name: String?,
site: String?,
city: VkTitle?,
country: VkTitle?,
domain: String?,
about: String?,
photo_max_orig: String?,
mobile_phone: String?,
home_phone: String?
)
@[JSON::Field(converter: String::RawConverter)]
property id : String

property last_name : String?
property first_name : String?
property site : String?
property city : VkTitle?
property country : VkTitle?
property domain : String?
property about : String?
property photo_max_orig : String?
property mobile_phone : String?
property home_phone : String?
end

class VkResponse
JSON.mapping(
response: Array(VkUser),
)
include JSON::Serializable
property response : Array(VkUser)
end

private def fetch_vk_user(code)
Expand Down Expand Up @@ -99,7 +99,8 @@ class MultiAuth::Provider::Vk < MultiAuth::Provider
secret,
redirect_uri: redirect_uri,
authorize_uri: "/authorize",
token_uri: "/access_token"
token_uri: "/access_token",
auth_scheme: :request_body
)
end
end

0 comments on commit bbd322b

Please sign in to comment.