lol_auth 0.1.10 → 0.1.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/lol_auth/users_controller.rb +14 -2
- data/app/managers/apple/login.rb +43 -0
- data/config/routes.rb +2 -0
- data/lib/lol_auth/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3aaaa250f2e7c3e807e6d0c95ecedaa139240be735efda9a88a1065ca79161b1
|
4
|
+
data.tar.gz: cea1792e29bcf9acf219b9678641403a894a2f0f3326912687b3a99c14324c32
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 88d5778d02a9a1522b7c404ff2abe07097a10efd9f9c6ea9fcc31ff3eafcf5f74f655c14bda7fda826436e91ded0ea2c74428d85a3ee1f92d18cf0568820461b
|
7
|
+
data.tar.gz: a504fa61aa7844e4d9a8429fd73f3d4a0764a668c2d12d37a47af1ccc1e02e5eb4d40a36b846ace77e52e4dedcd216653d36ebf7655f80104709b38126c90f31
|
@@ -2,7 +2,7 @@ require_dependency "lol_auth/application_controller"
|
|
2
2
|
|
3
3
|
module LolAuth
|
4
4
|
class UsersController < ApplicationController
|
5
|
-
skip_before_action :authenticate_api_v1_user!, only: [:facebook_signin]
|
5
|
+
skip_before_action :authenticate_api_v1_user!, only: [:facebook_signin, :apple_signin]
|
6
6
|
|
7
7
|
def facebook_signin
|
8
8
|
@manager = Facebook::Login.new()
|
@@ -14,7 +14,19 @@ module LolAuth
|
|
14
14
|
response.headers.merge!(@manager.auth_header)
|
15
15
|
|
16
16
|
render :success, status: 201
|
17
|
-
|
17
|
+
end
|
18
|
+
|
19
|
+
def apple_signin
|
20
|
+
@manager = Apple::Login.new(params)
|
21
|
+
|
22
|
+
@user = @manager.process()
|
23
|
+
|
24
|
+
sign_in(:user, @user, store: false, bypass: true)
|
25
|
+
|
26
|
+
response.headers.merge!(@manager.auth_header)
|
27
|
+
|
28
|
+
render :success, status: 201
|
29
|
+
end
|
18
30
|
end
|
19
31
|
|
20
32
|
def update_avatar
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module Apple
|
2
|
+
class Login
|
3
|
+
attr_accessor :auth_header
|
4
|
+
|
5
|
+
def initialize(options={})
|
6
|
+
@info = options[:resource]
|
7
|
+
|
8
|
+
@user_type = options[:user_type] || 'User'
|
9
|
+
end
|
10
|
+
|
11
|
+
def process
|
12
|
+
user = @user_type.constantize.find_or_create_by(uid: @info['email']) do |user|
|
13
|
+
user.email = @info['email']
|
14
|
+
user.password = build_pasword()
|
15
|
+
user.name = @info['name']
|
16
|
+
user.provider = :apple
|
17
|
+
end
|
18
|
+
|
19
|
+
build_token(user)
|
20
|
+
|
21
|
+
user.reload
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
def build_pasword
|
26
|
+
Devise.friendly_token[0,20]
|
27
|
+
end
|
28
|
+
|
29
|
+
def build_token(user)
|
30
|
+
client_id = SecureRandom.urlsafe_base64(nil, false)
|
31
|
+
token = SecureRandom.urlsafe_base64(nil, false)
|
32
|
+
|
33
|
+
user.tokens[client_id] = {
|
34
|
+
token: BCrypt::Password.create(token),
|
35
|
+
expiry: (Time.now + DeviseTokenAuth.token_lifespan).to_i
|
36
|
+
}
|
37
|
+
|
38
|
+
user.save
|
39
|
+
|
40
|
+
@auth_header = user.create_new_auth_token(client_id)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
data/config/routes.rb
CHANGED
data/lib/lol_auth/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lol_auth
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eduardo Zaghi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-12-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -198,6 +198,7 @@ files:
|
|
198
198
|
- app/helpers/lol_auth/users_helper.rb
|
199
199
|
- app/jobs/lol_auth/application_job.rb
|
200
200
|
- app/mailers/lol_auth/application_mailer.rb
|
201
|
+
- app/managers/apple/login.rb
|
201
202
|
- app/managers/facebook/base.rb
|
202
203
|
- app/managers/facebook/login.rb
|
203
204
|
- app/managers/user_reset_password_manager.rb
|