Class: Ibrain::Auth::User
- Inherits:
-
Base
- Object
- Base
- Ibrain::Auth::User
- Includes:
- Devise::JWT::RevocationStrategies::JTIMatcher
- Defined in:
- app/models/ibrain/auth/user.rb
Instance Attribute Summary collapse
-
#jwt_token ⇒ Object
Returns the value of attribute jwt_token.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#jwt_token ⇒ Object
Returns the value of attribute jwt_token.
6 7 8 |
# File 'app/models/ibrain/auth/user.rb', line 6 def jwt_token @jwt_token end |
Class Method Details
.ibrain_find(params, available_columns) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'app/models/ibrain/auth/user.rb', line 30 def ibrain_find(params, available_columns) matched_value = params[:username] || params[:email] if matched_value.present? query = available_columns.map do |column_name| <<~RUBY #{column_name} = '#{matched_value}' RUBY end.join(' OR ') where(query).first end end |
.social_find_or_initialize(params) ⇒ Object
44 45 46 47 48 49 |
# File 'app/models/ibrain/auth/user.rb', line 44 def (params) user = find_by(provider: params[:provider], uid: params[:uid]) return user if user.present? create!(params) end |
Instance Method Details
#jwt_payload ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'app/models/ibrain/auth/user.rb', line 16 def jwt_payload # for hasura hasura_keys = { 'https://hasura.io/jwt/claims': { 'x-hasura-allowed-roles': Ibrain.user_class.roles.keys, 'x-hasura-default-role': role, 'x-hasura-user-id': id.to_s } } super.merge({ 'role' => role }, hasura_keys) end |