Class: User::Operation::ExternalSignIn
- Inherits:
-
Trailblazer::Operation
- Object
- Trailblazer::Operation
- User::Operation::ExternalSignIn
- Defined in:
- app/concepts/morpho/user/operation/external_sign_in.rb
Instance Method Summary collapse
- #authentication_token(options) ⇒ Object
- #find_authentication(options) ⇒ Object
- #find_user(options) ⇒ Object
- #generate_refresh_token(options) ⇒ Object
- #not_registered(options) ⇒ Object
- #not_signed_in(options) ⇒ Object
- #not_signed_up(options) ⇒ Object
- #not_valid(options) ⇒ Object
- #register(options) ⇒ Object
- #register_last_login_activity(options) ⇒ Object
- #sign_in(options) ⇒ Object
- #sign_up(options) ⇒ Object
- #validate(options) ⇒ Object
Instance Method Details
#authentication_token(options) ⇒ Object
78 79 80 |
# File 'app/concepts/morpho/user/operation/external_sign_in.rb', line 78 def authentication_token (, **) ['token'] = Morpho::JWT::Payload.new(['user.model']) end |
#find_authentication(options) ⇒ Object
19 20 21 22 23 24 |
# File 'app/concepts/morpho/user/operation/external_sign_in.rb', line 19 def find_authentication (, **) ['authentication.model'] = Morpho::Authentication.find_by( uid: ['data']['uid'], provider: ['data']['provider'] ) end |
#find_user(options) ⇒ Object
26 27 28 |
# File 'app/concepts/morpho/user/operation/external_sign_in.rb', line 26 def find_user (, **) ['user.model'] = Morpho::User.find_by(email: ['data']['email']) end |
#generate_refresh_token(options) ⇒ Object
54 55 56 |
# File 'app/concepts/morpho/user/operation/external_sign_in.rb', line 54 def generate_refresh_token (, **) ['user.model'].generate_refresh_token! end |
#not_registered(options) ⇒ Object
70 71 72 |
# File 'app/concepts/morpho/user/operation/external_sign_in.rb', line 70 def not_registered (, **) ['error'] = :not_registered end |
#not_signed_in(options) ⇒ Object
66 67 68 |
# File 'app/concepts/morpho/user/operation/external_sign_in.rb', line 66 def not_signed_in (, **) ['error'] = :not_signed_in end |
#not_signed_up(options) ⇒ Object
74 75 76 |
# File 'app/concepts/morpho/user/operation/external_sign_in.rb', line 74 def not_signed_up (, **) ['error'] = :not_signed_up end |
#not_valid(options) ⇒ Object
62 63 64 |
# File 'app/concepts/morpho/user/operation/external_sign_in.rb', line 62 def not_valid (, **) ['error'] = :not_valid end |
#register(options) ⇒ Object
36 37 38 39 40 41 42 |
# File 'app/concepts/morpho/user/operation/external_sign_in.rb', line 36 def register (, **) if ['user.model'] && !['authentication.model'] provider = ['data']['provider'].downcase ['user.model'].add_provider_to_user(provider, ['data']['uid']) end end |
#register_last_login_activity(options) ⇒ Object
58 59 60 |
# File 'app/concepts/morpho/user/operation/external_sign_in.rb', line 58 def register_last_login_activity (, **) ['user.model'].register_last_login_activity!(['ip']) end |
#sign_in(options) ⇒ Object
30 31 32 33 34 |
# File 'app/concepts/morpho/user/operation/external_sign_in.rb', line 30 def sign_in (, **) if ['authentication.model'] ['user.model'] = ['authentication.model'].user end end |
#sign_up(options) ⇒ Object
44 45 46 47 48 49 50 51 52 |
# File 'app/concepts/morpho/user/operation/external_sign_in.rb', line 44 def sign_up (, **) if !['user.model'] && !['authentication.model'] provider = ['data']['provider'].downcase ['user.model'] = Morpho::User.create_from_provider(provider, ['data']['uid'], { email: ['data']['email'] }) end end |