Class: Google::Login
- Inherits:
-
Object
- Object
- Google::Login
- Defined in:
- app/managers/google/login.rb
Instance Attribute Summary collapse
-
#auth_header ⇒ Object
Returns the value of attribute auth_header.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Login
constructor
A new instance of Login.
- #process ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Login
Returns a new instance of Login.
5 6 7 8 9 |
# File 'app/managers/google/login.rb', line 5 def initialize(={}) @info = [:resource] @user_type = [:user_type] || 'User' end |
Instance Attribute Details
#auth_header ⇒ Object
Returns the value of attribute auth_header.
3 4 5 |
# File 'app/managers/google/login.rb', line 3 def auth_header @auth_header end |
Instance Method Details
#process ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'app/managers/google/login.rb', line 11 def process return false if @user_type.constantize.where(email: @info['email']).where.not(provider: :google).count > 0 user = @user_type.constantize.find_or_create_by(uid: @info['user']['id']) do |user| user.email = @info['user']['email'] user.password = build_pasword() user.name = @info['user']['name'] user.remote_avatar_url = @info['user']['photo'] user.provider = :google end build_token(user) user.reload end |